' iBPlot.ibas
{CREATORID "LDIP"}
{VERSION "2.3"}
{PARSER ON}
{RESOURCEFILE "iBPlot.rsrc"}

CONST A$="iBPlot v2.3¶	July 28, 2009¶	by Laurent Duveau¶"
CONST B$="	www.aldweb.com¶¶Life is colorful !"
CONST C$="Which Screen Res ?¶1. Low Res¶	160x160 pixels¶"
CONST D$="2. High Res¶	320x320 pixels¶3. Cancel"
CONST E$="2. High Res¶	320x320 pixels¶3. Low Res+¶	160x224"
CONST F$=" pixels¶4. High Res+¶	320x448 pixels¶5. Cancel"

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(2)
IF T=0 THEN
   T=HIGHRES(1) 'LowRes or HighRes
   D=HIGHRES(0)
ELSE
   H=T '320x320, 320x480 or 480x320 
   T=2 'LowRes+ or HighRes+
ENDIF
REPEAT
   D=DOEVENTS
   IF D=1003 LET H=HIGHRES(2) '320x320, 320x480 or 480x320
   IF D=5 GOSUB _DelScreen
   IF D>0 IF D<5 GOSUB _PlotGraph
UNTIL D=-1
D=MESSAGEBOX(A$+B$,0)
END

_DelScreen:
   SELECT CASE T
   CASE 1
      W=MESSAGEBOX(C$+D$,5)
      IF W<3 THEN
         COLOR E
         BOXFILLED 0,16 TO 160,160
         V=W-1
      ENDIF
   CASE 2
      U=V
      W=MESSAGEBOX(C$+E$+F$,7)
      IF W<5 THEN
         COLOR E
         BOXFILLED 0,16 TO 160,160
         V=W-1
         IF V>1 THEN
            SETRES V
         ELSE
            IF U>1 SETRES 0
         ENDIF
      ENDIF
   END SELECT
RETURN

_PlotGraph:
   IF V=1 SETRES V
   G=1+((V=1) OR (V=3))
   K=G*(160+(H=3)*64)
   L=G*(142+(H=2)*64)   
   M=G*18
   IF D<>4 THEN N=20
   ELSE N=G*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 G=1 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 SETRES 0
RETURN