![]() |
|
#11
|
||||
|
||||
|
Quote:
Its a small program, but saving ticks is always welcome. I changed it in my common library as well....waiting for the other shoe to drop...
__________________
Everyone can build in Winter and all citizens have v4 rights! Begin your own Winter village, secret hideout, nature preserve or your hearts desire! There is a vast array of open land in this unique building environment. All the familiar objects of Alpha, with the unique objects of Winter. Don't like blinding snow? Just click on some Shades and find quick access to Ladybunnys OY and MaXPolys new OY. Need a more current list of assets? Just visit virlands.com/winter/materials.php
|
|
#12
|
||||
|
||||
|
I always enjoy seeing how compactly I can write something in C/C++. Most of it isn't readable, but I've learned a lot in the process.
__________________
Become a fan of AWGames on Facebook today! -- http://www.theenginerd.com/ - Random programming stuff and tools for AW |
|
#13
|
||||
|
||||
|
Well, finally figured it out and got a Times font to work. Made it much nicer. Thanks for the ideas and help!
I hardcoded Y to 85 because I was getting really odd results, but it didn't matter since Y shouldn't change anyways for a given font size. This uses the Windows GD lib, the Windows Freetype Lib, and I used the DEV C++ IDE/gcc compiler. Code:
#include <stdio.h>
#include <stdlib.h>
#include <gd.h>
#define IMG_DIMENSION 128
#define FONT_SIZE 50.0
#define MAX_TERRAIN 501
int myRandom(int range_min, int range_max)
{return (rand() % ((range_max - range_min) + 1)) + range_min;}
int main(int argc, char *argv[])
{
gdImagePtr im;
FILE *fp;
int imgcount =0;
int imgcolor =0;
int black =0;
int white =0;
int numc =0;
int offset =0;
int *err;
int brect[8];
int x, y =0;
char text[10];
char filename[32];
char *f = "times.ttf";
srand(time(NULL));
rand();
im = gdImageCreateTrueColor(IMG_DIMENSION,IMG_DIMENSION); //create image space
if (!im) {printf("Cannot create image.\n");return 1;}
black = gdImageColorAllocate(im, 12, 12, 12); //shadow
white = gdImageColorAllocate(im, 255, 255, 255); //foreground
do { //***Main Loop
imgcolor = gdImageColorAllocate(im,myRandom(16,64),myRandom(100,222),myRandom(16,64));
gdImageFilledRectangle(im,0,0,IMG_DIMENSION,IMG_DIMENSION,imgcolor);
imgcolor = gdImageColorAllocate(im,myRandom(16,222),myRandom(16,222),myRandom(16,222));
gdImageFilledRectangle(im,13,13,IMG_DIMENSION-14,IMG_DIMENSION-14,imgcolor);
sprintf(text,"%d",imgcount); //change int to string
err = gdImageStringFT(NULL,&brect[0],0,f,FONT_SIZE,0.0,0,0,text); //NULL, we only want to fill brect[]!
if (err) {printf("Cannot create font image.\n");return 1;}
x = 2+(IMG_DIMENSION-(brect[2]-brect[6]))/2;
y = 85; //(IMG_DIMENSION-(brect[3]-brect[7]))/2; <---GOOOFY results!
err = gdImageStringFT(im,&brect[0],black,f,FONT_SIZE,0.0,x,y,text); //shadow
if (err) {printf("Cannot create font image.\n");return 1;}
err = gdImageStringFT(im,&brect[0],white,f,FONT_SIZE,0.0,x-1,y-1,text); //white
if (err) {printf("Cannot create font image.\n");return 1;}
sprintf(filename,"terrain%d.jpg",imgcount);
fp = fopen(filename, "wb");
if (!fp) {
printf("Cannot open terrain%d.jpg for writing.\n",imgcount);
return 1;
}
gdImageJpeg(im, fp, 100);
fclose(fp);
imgcount++;
} while(imgcount < MAX_TERRAIN); //***End Main Loop
gdImageDestroy(im); //destroy image space
printf("done.");
system("PAUSE");
return 0;
}
__________________
Everyone can build in Winter and all citizens have v4 rights! Begin your own Winter village, secret hideout, nature preserve or your hearts desire! There is a vast array of open land in this unique building environment. All the familiar objects of Alpha, with the unique objects of Winter. Don't like blinding snow? Just click on some Shades and find quick access to Ladybunnys OY and MaXPolys new OY. Need a more current list of assets? Just visit virlands.com/winter/materials.php
|
|
#14
|
||||
|
||||
|
__________________
Everyone can build in Winter and all citizens have v4 rights! Begin your own Winter village, secret hideout, nature preserve or your hearts desire! There is a vast array of open land in this unique building environment. All the familiar objects of Alpha, with the unique objects of Winter. Don't like blinding snow? Just click on some Shades and find quick access to Ladybunnys OY and MaXPolys new OY. Need a more current list of assets? Just visit virlands.com/winter/materials.php
|
![]() |
| Tags |
| talisan, terrain, terrain tools |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|