adding PRNG initialisation

This commit is contained in:
tth 2019-09-11 13:45:18 +02:00
parent ee3c2c4cbc
commit 342fc4a721

View File

@ -2,6 +2,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <time.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -14,7 +15,9 @@ int verbosity;
static int get_type(char *name) static int get_type(char *name)
{ {
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name); fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
#endif
#define TEST(str) ( ! strcmp(name, str) ) #define TEST(str) ( ! strcmp(name, str) )
if TEST("black") return T_BLACK; if TEST("black") return T_BLACK;
@ -38,14 +41,15 @@ int main(int argc, char *argv[])
int foo, opt; int foo, opt;
int width, height; int width, height;
char *fname; char *fname;
float fvalue; float fvalue = 0.00001;
int type = 0; int type = 0;
FloatImg fimg; FloatImg fimg;
while ((opt = getopt(argc, argv, "ht:v")) != -1) { while ((opt = getopt(argc, argv, "hk:t:v")) != -1) {
switch(opt) { switch(opt) {
case 'h': help(0); break; case 'h': help(0); break;
case 'k': fvalue = atof(optarg); break;
case 't': type = get_type(optarg); break; case 't': type = get_type(optarg); break;
case 'v': verbosity++; break; case 'v': verbosity++; break;
} }
@ -67,6 +71,8 @@ width = atoi(argv[optind+1]); height = atoi(argv[optind+2]);
if (verbosity) fprintf(stderr, "making '%s' %d x %d\n", fname, width, height); if (verbosity) fprintf(stderr, "making '%s' %d x %d\n", fname, width, height);
srand48(getpid() ^ time(NULL));
foo = fimg_create(&fimg, width, height, 3); foo = fimg_create(&fimg, width, height, 3);
if (foo) { if (foo) {
fprintf(stderr, "create floatimg -> %d\n", foo); fprintf(stderr, "create floatimg -> %d\n", foo);