23
24
printf( "this is pngphoon version " VERSION "\n\n"
24
"usage: %s options (* = mandatory)\n"
28
"\t-x # number of moons in x axis (for multihead configurations)\n"
29
"\t-y # number of moons in y axis (for multihead configurations)\n"
30
"\t-s # star density\n"
31
"\t-b black (no earthlight)\n", base );
25
"usage: %s options (* = mandatory)\n"
29
"\t-x # number of moons in x axis (for multihead configurations)\n"
30
"\t-y # number of moons in y axis (for multihead configurations)\n"
31
"\t-s # star density\n"
32
"\t-b black (no earthlight)\n"
33
"\t-q quiet (disable warnings)\n", base );
35
37
int main( int argc, char *argv[] )
42
char *filename = NULL;
44
image_t *image = NULL;
45
char *filename = NULL;
47
image_t *image = NULL;
57
while ((c = getopt (argc, argv, "w:h:x:y:s:f:b")) != EOF)
60
while ((c = getopt (argc, argv, "w:h:x:y:s:f:bq")) != EOF)
62
width = strtol( optarg, NULL, 0 );
65
height = strtol( optarg, NULL, 0 );
68
xmoons = strtol( optarg, NULL, 0 );
71
ymoons = strtol( optarg, NULL, 0 );
74
stars = strtol( optarg, NULL, 0 );
83
printf("unknown option: '%c'\n", c);
65
width = strtol( optarg, NULL, 0 );
68
height = strtol( optarg, NULL, 0 );
71
xmoons = strtol( optarg, NULL, 0 );
74
ymoons = strtol( optarg, NULL, 0 );
77
stars = strtol( optarg, NULL, 0 );
89
fail("unknown option: '%c'\n", c);
87
93
if( !width || !height || !filename )
89
printf( "you need to specify at least width, height and filename\n" );
95
fail( "you need to specify at least width, height and filename\n" );
93
98
moon = mooncreate();
100
if( width < moon->width )
102
warn( "image not wide enough for anything, just creating stars\n" );
106
if( width < moon->width * xmoons )
108
warn( "decreasing number of moons in x axis from %d ", xmoons );
109
while( width < moon->width * --xmoons );
110
warn( "to %d moons.\n", xmoons );
114
if( height < moon->height )
116
warn( "image not high enough for moon, using truncate mode\n" );
117
drawheight = moon->height;
122
if( height < moon->height * ymoons )
124
warn( "decreasing number of moons in y axis from %d ", ymoons );
125
/* this is not nice, but works: decreasing number of moons until they fit */
126
while( width < (moon->width * --ymoons) );
127
warn( "to %d moons.\n", ymoons );
95
image = imagecreate( width, height );
96
if( (width < (moon->width) * xmoons) ||
97
(height < (moon->height) * ymoons) )
99
printf("image too small to fit moon%s, creating stars only\n",
100
(xmoons * ymoons > 1) ? "s" : "");
131
image = imagecreate( width, drawheight );
132
if( xmoons * ymoons )
134
scarymonster( image, stars );
135
for( y = (drawheight/ymoons)/2; y < height; y += (drawheight/ymoons) )
137
for( x = (width/xmoons)/2; x < width; x += (width/xmoons) )
139
mooncopy( image, moon, x, y, black );
101
145
scarymonster( image, stars * 2 );
105
scarymonster( image, stars );
106
for( y = (height/ymoons)/2; y < height; y += (height/ymoons) )
108
for( x = (width/xmoons)/2; x < width; x += (width/xmoons) )
110
mooncopy( image, moon, x, y, black );
114
pngwrite( image, filename );
147
pngwrite( image, filename, height );
115
148
imagedestroy( image );
116
149
moondestroy( moon );