Files
retrobsd/share/examples/gpanel/rect.c
Serge Vakulenko 08edaaba8c Fix bug in hxtft driver: drawing rectangles.
Add a few gpanel examples.
2015-10-08 22:15:01 -07:00

35 lines
700 B
C

/*
* Draw random rectangles.
*/
#include <stdio.h>
#include <sys/gpanel.h>
int xsize, ysize;
int main()
{
char *devname = "/dev/tft0";
int x0, y0, x1, y1, color;
if (gpanel_open(devname) < 0) {
printf("Cannot open %s\n", devname);
exit(-1);
}
gpanel_clear(0, &xsize, &ysize);
printf("Screen size %u x %u.\n", xsize, ysize);
srandom(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();
gpanel_rect(color, x0, y0, x1, y1);
}
return 0;
}