Testing+Drawing+Rules,+join+the+fun


 * TEST.BAS EDITED BY : .............................................................**

Experimenting is always more fun than reading long complicated explanations.

This is how this program : test.bas started. I was trying to understand how drawing rules work //(print #handle, "rule rulename")//. What would happen if did this ? ... and this ? and then this ? Would that work ? hmmm, let's see... This is how more and more buttons started growing on my window.

So, if you run the program, you can see that on the right, there are **setting buttons** to set the XOR rule, to clear the screen etc. At the bottom, there are **drawing objects** **buttons**. Try the box button with normal rule: you'll get a box. Try the box button with XOR rule : you'll get a ...box ! Press the box button again : the box disappears. Press it again : the box comes back !

I'm starting to understand the XOR rule a little bit more ...

This is where you can join in ! Why not experiment too ? an other rule you want to try ? a crazy idea about drawing ? Feel free to add your bit of code to the program and add your button to the window. Want to add an other drawing rule ? a different color ? add your button to the **setting buttons**. Want to draw something ? add your button to the **drawing objects buttons** group.

You have a totally new idea ? does not fit in either group ? you could always add a menu ....

Want ot improve the code already there ? want to put comments ? add a help ? not a problem.


 * All I'm asking is that :**


 * 1) If you are busy modifying TEST.BAS, put your name up there (1st line of this page), to let people you are busy modifying it.
 * 2) Once you have added your code, make sure that TEST.BAS still runs smoothly and without bugs.
 * 3) Remove your name up there so some other programmer can have a turn !
 * 4) Copy and paste your new version here with version number and date

code format="vbnet"

' ' TEST. BAS VERSION 2 - 13/03/06 '   nomainwin

WindowWidth=600: WindowHeight=450 UpperLeftX=Int((DisplayWidth-WindowWidth)/1) UpperLeftX=Int((DisplayHeight-WindowHeight)/1) BackgroundColor$="grey" ForegroundColor$ = "lightgray" menu #w, "Exit", "Exit", [exit] graphicbox #w.g, 10,  10,  400,  230 button #w.line," line ", [line], UL, 10, 250 button #w.dots,"circlefilled", [dots], UL, 70, 250 button #w.dots," draw ", [set], UL, 170, 250 button #w.dots,"box", [box], UL, 230, 250 button #w.dots,"draw rectangle", [drawrectangle], UL, 10, 290 button #w.dots,"draw line",[drawline],UL,130,290

button #w.normal," normal ",[normal], UL, 420, 20 button #w.xor," XOR ",[XOR], UL, 420, 60 button #w.not," NOT ",[NOT], UL, 420, 100 button #w.clear," clear ",[clear], UL, 500, 20 button #w.fill," fill ",[fill], UL, 500, 60 open " Test XOR " for graphics_nsb_nf as #w print #w,"trapclose [exit]"

drawrule=1 'normal by default wait

 ' SETTING BUTTONS  ' Add draw rules here and add rule to checkrule Sub [normal] drawrule=1 wait [XOR] drawrule=2 wait [NOT] drawrule=3 wait

' ' CLEAR AND FILL BACKGROUND WITH COLOR ' [clear] print #w.g,"cls" wait [fill] if color$="" then color$="lightgray" print #w.g,"fill ";color$ print #w.g,"flush" wait

 ' OBJECTS DRAWN BUTTONS 

''' ' ROW 1 ''' [line] print #w.g,"down" call checkrule drawrule for i=10 to 200 step 10 call drawline i, normalflag call pause 100 next i   wait

[dots] print #w.g,"down" call checkrule drawrule for i=10 to 200 step 20 call drawdots i       call pause 500 next i   wait

[set] #w.g "when leftButtonMove [draw]" [draw] print #w.g,"down" call checkrule drawrule print #w.g, "set "; MouseX; " "; MouseY wait

[box] print #w.g,"down" call checkrule drawrule print #w.g,"place 50 50" print #w.g,"box 100 100" wait ''' ' ROW 2 ''' [drawrectangle] call checkrule drawrule print #w.g,"when leftButtonDown [plotstart]" print #w.g,"when leftButtonMove [drawframe]" print #w.g,"when leftButtonUp [plot]" wait

[drawframe] CX = int(MouseX/1)*1+1 CY = int(MouseY/1)*1+1 print #w.g,"place ";CX;" ";CY call drawrectangle AX,AY,OMX,OMY call drawrectangle AX,AY,CX,CY OMX=CX OMY=CY wait

[plot] #w.g, "Segment segID2" #w.g, "Flush segID2" wait

[drawline] call checkrule drawrule print #w.g,"when leftButtonDown [plotstart]" print #w.g,"when leftButtonMove [bungie]" print #w.g,"when leftButtonUp [plot3]" wait

[plotstart] call checkrule drawrule print #w.g,"down" AX=MouseX AY=MouseY 'Old mouseX and old mouseY OMX=MouseX OMY=MouseY print #w,"place ";AX;" ";AY wait

[bungie] CX = int(MouseX/1)*1+1 CY = int(MouseY/1)*1+1 print #w.g,"place ";CX;" ";CY call drawbungie AX,AY,OMX,OMY call drawbungie AX,AY,CX,CY OMX=CX OMY=CY wait

[plot3] #w.g, "Segment segID3" #w.g, "Flush segID3" wait

[exit] print #w.g,"cls" close #w end

'' '                     SUBS AND FUNCTION ''

Sub checkrule drawrule SELECT CASE drawrule CASE 1 #w.g, "rule ";_R2_COPYPEN CASE 2 #w.g, "rule XOR" CASE 3 #w.g, "rule ";_R2_NOT CASE else #w.g, "rule ";_R2_COPYPEN

END SELECT end sub

Sub drawline i, normalflag AX=50 if normalflag = 1 then AY=50 else AY=80 end if   BX=AX BY=AY BX=BX+i print #w.g,"line ";AX;" ";AY;" ";BX;" ";BY end sub

Sub drawdots i   AX=50 AY=100 BY=AY BX=AX print #w.g,"place ";BX+i;" ";BY print #w.g,"circlefilled 5" end sub

Sub drawset i   AX=50 AY=150 BY=AY BX=AX print #w.g,"set ";BX+i;" ";BY end sub

Sub drawrectangle AX,AY,CX,CY print #w.g,"line ";AX;" ";AY;" ";CX;" ";AY print #w.g,"line ";AX;" ";AY;" ";AX;" ";CY print #w.g,"line ";CX;" ";AY;" ";CX;" ";CY print #w.g,"line ";CX;" ";CY;" ";AX;" ";CY End Sub

Sub drawbungie AX,AY,CX,CY print #w.g,"line ";AX;" ";AY;" ";CX;" ";CY End Sub

SUB pause mil TIMER mil, [cont] WAIT [cont] TIMER 0 END SUB

code