#include <sys/types.h>
#include <malloc.h>
#include <string.h>
#include <sys/time.h>
#include <sys/fcntl.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>

#include "xstuff.h"

int main(int argc, char *argv[])
{
    int i, n = (argc >= 2 ? atoi(argv[1]):2000);

    puts("Press 'q' in the X-window to quit, or press ^C in this window.");

    /* This function must be called to initialize the X stuff.
    ** It will exit if there is an error.
    */
    start_x(argc, argv, "random lines");

    for(i=0; i<n ;i++)
    {
	unsigned x1,x2,y1,y2;

	/* This function must be called frequently to handle the X
	** events for you.
	*/
	update_x();

	x1 = lrand48() % width;
	y1 = lrand48() % height;
	x2 = lrand48() % width;
	y2 = lrand48() % height;

	/*printf("%d (%d,%d)->(%d,%d)\n", i, x1,y1, x2,y2);*/
	drawline(x1,y1, x2,y2);
    }
}
