' iBPlot.ibas
{CREATORID "LDIP"}
{VERSION "2.1"}
{RESOURCEFILE "iBPlot.rsrc"}

CONST A$="iBPlot v2.1¶	December 2, 2004¶	by Laurent Duveau¶"
CONST B$="	www.aldweb.com¶¶Life is colorful !"
CONST C$="Which Screen Res ?¶¶1. High Res¶	320x320 "
CONST D$="pixels¶¶2. Low Res¶	160x160 pixels"

BEGIN
S=SCREENMODES
SCREEN S
IF S=0 LET C=1
E=COLOR(0)
BUTTON #1,"Box",43,1,21,10
BUTTON #2,"FBox",67,1,25,10
BUTTON #3,"Line",95,1,22,10
BUTTON #4,"Dot",120,1,20,10
BUTTON #5,"Cls",143,1,16,10
T=HIGHRES(1)
D=HIGHRES(0)
REPEAT
   D=DOEVENTS
   IF D=5 GOSUB _DelScreen : D=0
   IF D>0 GOSUB _PlotGraph
UNTIL D=-1
D=MESSAGEBOX(A$+B$,0)
END

_DelScreen:
   COLOR E
   BOXFILLED 0,16 TO 160,160
   IF T=1 LET V=MESSAGEBOX(C$+D$,4)
RETURN

_PlotGraph:
   IF V=1 THEN H=HIGHRES(1)
   ELSE H=0
   ENDIF
   K=H+1*160
   L=H+1*142
   M=H+1*18
   IF D<>4 THEN N=20
   ELSE N=H+1*200
   ENDIF
   FOR A=1 TO N
      X=RND(K)
      Y=RND(L)+M
      I=RND(K)
      J=RND(L)+M
      IF S>0 THEN
         R=RND(256)
         G=RND(256)
         B=RND(256)
         C=COLORRGB(R,G,B)
      ENDIF
      COLOR C
      IF D=1 THEN
         IF H=0 THEN
            BOX X,Y TO I,J
         ELSE
            LINE X,Y TO I,Y
            LINE TO I,J
            LINE TO X,J
            LINE TO X,Y
         ENDIF
      ENDIF
      IF D=2 BOXFILLED X,Y TO I,J
      IF D=3 LINE X,Y TO I,J
      IF D=4 PSET X,Y
   NEXT
   IF V=1 LET H=HIGHRES(0)
RETURN