#include <stdio.h>
#include <graphinc.h>

main(argc, argv)
int argc;
char *argv[];
{
	int func;
	char c;

	dofunc(5);
	for(;;) {
		printf("\n1\tline\n2\ttrapeze\n3\ttriangle\n");
		printf("4\tfill\n5\tclear\n6\tplot\n");
		printf("7\tmouse\n");
		printf("9\tstop\n\nselect function: ");
                fflush(stdout);
		scanf("%d", &func);
		if ((c = getchar()) != '\n') ungetc(c);
		if (func == 9) break;
		dofunc(func);
	}
}

dofunc(f)
int f;
{
	int x1, x2, x3, x4, y1, y2, y3, y4;

	switch(f) {
		case 1:	printf("line from x1, y1 to x2, y2:  ");
			scanf("%d, %d, %d, %d", &x1, &y1, &x2, &y2);
			Line(x1, y1, x2, y2);
			break;

		case 2:	printf("trapezium between x1, x2, y1 and x3, x4 y2:  ");
			scanf("%d, %d, %d, %d, %d, %d", &x1, &x2, &y1,
				&x3, &x4, &y2);
			Trapeze(x1, x2, y1, x3, x4, y2);
			break;

		case 3:	printf("triangle between x1, y1, x2, y2 and x3, y3:  ");;
			scanf("%d, %d, %d, %d, %d, %d", &x1, &y1, &x2, &y2,
				&x3, &y3);
			Triangle(x1, y1, x2, y2, x3, y3);
			break;

		case 4:	printf("fill box x1, y1, x2, y2:  ");
			scanf("%d, %d, %d, %d", &x1, &y1, &x2, &y2);
			Fill(x1, y1, x2, y2);
			break;

		case 5: Clear();
			Colour(White);
			Enable(White);
			Offset(0, 0);
			break;

		case 6: printf("plot point x, y:  ");
			scanf("%d, %d", &x1, &y1);
			Plot(x1, y1);
			break;

		case 7: printf("mouse x, y, buttons = %d, %d, %d\n",
				MouseX, MouseY, MouseButtons);
			break;

		default:
			printf("invalid option\n");
			while(getchar() != '\n' && !feof(stdin)) ;
	}
}
