diff options
Diffstat (limited to 'generator')
-rw-r--r-- | generator/ppmpat.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/generator/ppmpat.c b/generator/ppmpat.c index f4190d6c..9e2f6d05 100644 --- a/generator/ppmpat.c +++ b/generator/ppmpat.c @@ -770,7 +770,7 @@ squig( pixels, cols, rows, maxval ) x1 = rand() % cols; y1 = 0; if ( x1 < cols / 2 ) - xc[0] = rand() % ( x1 * 2 ); + xc[0] = rand() % ( x1 * 2 + 1); else xc[0] = cols - 1 - rand() % ( ( cols - x1 ) * 2 ); yc[0] = rand() % rows; @@ -788,7 +788,7 @@ squig( pixels, cols, rows, maxval ) x2 = rand() % cols; y2 = 0; if ( x2 < cols / 2 ) - xc[SQ_POINTS - 1] = rand() % ( x2 * 2 ); + xc[SQ_POINTS - 1] = rand() % ( x2 * 2 + 1); else xc[SQ_POINTS - 1] = cols - 1 - rand() % ( ( cols - x2 ) * 2 ); yc[SQ_POINTS - 1] = rand() % rows; @@ -807,7 +807,7 @@ squig( pixels, cols, rows, maxval ) y1 = rand() % rows; xc[0] = rand() % cols; if ( y1 < rows / 2 ) - yc[0] = rand() % ( y1 * 2 ); + yc[0] = rand() % ( y1 * 2 + 1); else yc[0] = rows - 1 - rand() % ( ( rows - y1 ) * 2 ); x2 = cols - 1; @@ -825,7 +825,7 @@ squig( pixels, cols, rows, maxval ) y2 = rand() % rows; xc[SQ_POINTS - 1] = rand() % cols; if ( y2 < rows / 2 ) - yc[SQ_POINTS - 1] = rand() % ( y2 * 2 ); + yc[SQ_POINTS - 1] = rand() % ( y2 * 2 + 1); else yc[SQ_POINTS - 1] = rows - 1 - rand() % ( ( rows - y2 ) * 2 ); x1 = cols - 1; @@ -1006,6 +1006,11 @@ main(int argc, char ** argv) { if ( argn != argc ) pm_usage( usage); + if (cols < 1) + pm_error("width must be at least 1"); + if (rows < 1) + pm_error("height must be at least 1"); + srand( (int) ( time( 0 ) ^ getpid( ) ) ); pixels = ppm_allocarray( cols, rows ); |