/* ---------------------------------------------------------------------------
| Filename:     graph.c
|
| Authors:      Thomas Braunl   
|
| Description:  line and rectangle demo using libgraph
| ------------------------------------------------------------------------- */

#include "eyebot.h"

/* ----------------------------------------------------------------------- */
/** main of demo program */
int main()
{ char k;
  int x1=0, y1=0;
  int x=0, y=0, xd=1, yd=1;

  /* line demo */
  do {
    do {
      LCDMenu("Y","X","+/-","LINE");
      LCDSetPixel(y,x, 1);
      KEYGetBuf(&k);
      switch (k) {
	case KEY1: y = (y + yd +  64) %  64; break;
	case KEY2: x = (x + xd + 128) % 128; break;
	case KEY3: xd = -xd; yd = -yd; break;
      }
      LCDSetPos(1,2); LCDPrintf("fr y%2d:x%3d", y1,x1);
      LCDSetPos(2,2); LCDPrintf("to y%2d:x%3d", y ,x );
    } while(KEY4 != k);
    LCDLine(x1,y1, x,y, 1);
    x1=x; y1=y;  /* next lines starts from last point */
    LCDMenu("LINE"," "," ","AREA");
    KEYGetBuf(&k);
  } while (KEY4 != k);

/* area demo */
  x=0;  y=0;  x1=0;  y1=0;  /* start over */
  xd=1; yd=1;
  LCDClear();
  do {
    do {
      LCDMenu("Y","X"," ","AREA");
      LCDSetPixel(y,x, 1);
      KEYGetBuf(&k);
      switch (k) {
	case KEY1: y = (y + yd +  64) %  64; break;
	case KEY2: x = (x + xd + 128) % 128; break;
	case KEY3: xd = -xd; yd = -yd; break;
      }
      LCDSetPos(1,2); LCDPrintf("fr y%2d:x%3d", y1,x1);
      LCDSetPos(2,2); LCDPrintf("to y%2d:x%3d", y ,x );
    } while(KEY4 != k);
    LCDArea(x1,y1, x,y, 1);
    x1=x; y1=y;  /* next lines starts from last point */
    LCDMenu("AREA"," "," ","END");
    KEYGetBuf(&k);
  } while (KEY4 != k);
  return 0;
}
