11
static inline void usage( char *name )
16
for( c = name+1; *c; c++)
18
if( *(c-1) == '/' ) base = c;
21
printf( "usage: %s options (* = mandatory)\n"
25
"\t-x # number of moons in x axis (for multihead configurations)\n"
26
"\t-y # number of moons in y axis (for multihead configurations)\n"
27
"\t-s # star density\n"
28
"\t-b black (no earthlight)\n", base );
32
int main( int argc, char *argv[] )
39
char *filename = NULL;
41
image_t *image = NULL;
54
while ((c = getopt (argc, argv, "w:h:x:y:s:f:b")) != EOF)
59
width = strtol( optarg, NULL, 0 );
62
height = strtol( optarg, NULL, 0 );
65
xmoons = strtol( optarg, NULL, 0 );
68
ymoons = strtol( optarg, NULL, 0 );
71
stars = strtol( optarg, NULL, 0 );
80
printf("unknown option: '%c'\n", c);
84
if( !width || !height || !filename )
86
printf( "you need to specify at least width, height and filename\n" );
91
image = imagecreate( width, height );
92
if( (width < (moon->width) * xmoons) ||
93
(height < (moon->height) * ymoons) )
95
printf("image too small to fit moon%s, creating stars only\n",
96
(xmoons * ymoons > 1) ? "s" : "");
97
scarymonster( image, stars * 2 );
101
scarymonster( image, stars );
102
for( y = (height/ymoons)/2; y < height; y += (height/ymoons) )
104
for( x = (width/xmoons)/2; x < width; x += (width/xmoons) )
106
mooncopy( image, moon, x, y, black );
110
pngwrite( image, filename );
111
imagedestroy( image );