Use rand() in gpanel examples.

This commit is contained in:
Serge Vakulenko
2015-10-09 13:47:07 -07:00
parent d2fb9b98a6
commit 1d32cd012a
5 changed files with 27 additions and 27 deletions

View File

@@ -18,15 +18,15 @@ int main()
gpanel_clear(0, &xsize, &ysize);
printf("Screen size %u x %u.\n", xsize, ysize);
srandom(time(0));
srand(time(0));
printf("Draw random circles.\n");
printf("Press ^C to stop.\n");
for (;;) {
x = random() % xsize;
y = random() % ysize;
r = random() % ysize;
color = random();
x = rand() % xsize;
y = rand() % ysize;
r = rand() % ysize;
color = rand() << 1;
gpanel_circle(color, x, y, r);
}
return 0;

View File

@@ -18,16 +18,16 @@ int main()
gpanel_clear(0, &xsize, &ysize);
printf("Screen size %u x %u.\n", xsize, ysize);
srandom(time(0));
srand(time(0));
printf("Draw random filled rectangles.\n");
printf("Press ^C to stop.\n");
for (;;) {
x0 = random() % xsize;
y0 = random() % ysize;
x1 = random() % xsize;
y1 = random() % ysize;
color = random();
x0 = rand() % xsize;
y0 = rand() % ysize;
x1 = rand() % xsize;
y1 = rand() % ysize;
color = rand() << 1;
gpanel_fill(color, x0, y0, x1, y1);
}
return 0;

View File

@@ -18,16 +18,16 @@ int main()
gpanel_clear(0, &xsize, &ysize);
printf("Screen size %u x %u.\n", xsize, ysize);
srandom(time(0));
srand(time(0));
printf("Draw random lines.\n");
printf("Press ^C to stop.\n");
for (;;) {
x0 = random() % xsize;
y0 = random() % ysize;
x1 = random() % xsize;
y1 = random() % ysize;
color = random();
x0 = rand() % xsize;
y0 = rand() % ysize;
x1 = rand() % xsize;
y1 = rand() % ysize;
color = rand() << 1;
gpanel_line(color, x0, y0, x1, y1);
}
return 0;

View File

@@ -18,14 +18,14 @@ int main()
gpanel_clear(0, &xsize, &ysize);
printf("Screen size %u x %u.\n", xsize, ysize);
srandom(time(0));
srand(time(0));
printf("Draw random pixels.\n");
printf("Press ^C to stop.\n");
for (;;) {
x = random() % xsize;
y = random() % ysize;
color = random();
x = rand() % xsize;
y = rand() % ysize;
color = rand() << 1;
gpanel_pixel(color, x, y);
}
return 0;

View File

@@ -18,16 +18,16 @@ int main()
gpanel_clear(0, &xsize, &ysize);
printf("Screen size %u x %u.\n", xsize, ysize);
srandom(time(0));
srand(time(0));
printf("Draw random rectangles.\n");
printf("Press ^C to stop.\n");
for (;;) {
x0 = random() % xsize;
y0 = random() % ysize;
x1 = random() % xsize;
y1 = random() % ysize;
color = random();
x0 = rand() % xsize;
y0 = rand() % ysize;
x1 = rand() % xsize;
y1 = rand() % ysize;
color = rand() << 1;
gpanel_rect(color, x0, y0, x1, y1);
}
return 0;