'** Run from Just BASIC root directory, so program can find bmps '** modification of drawx.bas '** Alyce Watson, 2004 nomainwin lineThickness$ = "1" lineColor$ = "black" menu #1, "&File", "&New",[cls],"&Save",[save], _ "&Print",[printIt],|,"E&xit",[quit] menu #1, "&Object", "&Line", [setForLine], "&Ellipse", [setForEllipse],_ "&Box", [setForBox],"Bitmap",[setForPan] menu #1, "&Color", "&Red", [colorRed], "&Yellow", [colorYellow],_ "&Green", [colorGreen], "&Blue", [colorBlue] menu #1, "&Drawing", "&Line Thickness", [lineThickness],_ "Line &Color", [lineColor] bmpbutton #1, "bmp\redbttn.bmp", [colorRed], UL, 0, 0 bmpbutton #1, "bmp\yllwbttn.bmp", [colorYellow], UL, 28, 0 bmpbutton #1, "bmp\grnbttn.bmp", [colorGreen], UL, 56, 0 bmpbutton #1, "bmp\bluebttn.bmp", [colorBlue], UL, 84, 0 bmpbutton #1, "bmp\check.bmp", [lineThickness], UL, 130, 0 bmpbutton #1, "bmp\grphbttn.bmp", [lineColor], UL, 158, 0 bmpbutton #1, "bmp\panbttn.bmp", [setForPan], UL, 204, 0 bmpbutton #1, "bmp\circbttn.bmp", [setForEllipse], UL, 232, 0 bmpbutton #1, "bmp\sqrbttn.bmp", [setForBox], UL, 260, 0 bmpbutton #1, "bmp\linebttn.bmp", [setForLine], UL, 288, 0 graphicbox #1.graph, 0, 29, 640, 440 WindowWidth = 640 : WindowHeight = 480 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) open "Drawing Demo" for graphics_nsb_nf as #1 #1 "trapclose [quit]" #1 "fill buttonface ; flush" #1.graph "when rightButtonUp [cls]" #1.graph "setfocus; down" #1.graph "color black" goto [setForLine] [inputLoop] wait [startDraw] startX = MouseX startY = MouseY #1.graph "place "; startX; " "; startY wait [firstLine] #1.graph "when leftButtonMove [trackLine]" #1.graph "line "; startX; " "; startY; " "; MouseX; " "; MouseY oMouseY = MouseY oMouseX = MouseX wait [firstFrame] #1.graph "when leftButtonMove [trackBox]" #1.graph "box "; MouseX; " "; MouseY oMouseY = MouseY oMouseX = MouseX wait [trackBox] #1.graph "rule XOR" #1.graph "box "; oMouseX; " "; oMouseY #1.graph "place "; startX; " "; startY #1.graph "box "; MouseX; " "; MouseY oMouseY = MouseY oMouseX = MouseX wait [trackLine] #1.graph "rule XOR" #1.graph "line "; startX; " "; startY; " "; oMouseX; " "; oMouseY #1.graph "place "; startX; " "; startY #1.graph "line "; startX; " "; startY; " "; MouseX; " "; MouseY oMouseY = MouseY oMouseX = MouseX wait [finishLine] #1.graph "when leftButtonMove [firstLine]" #1.graph "discard;rule OVER" #1.graph "line "; startX; " "; startY; " "; MouseX; " "; MouseY #1.graph "flush ; redraw" wait [finishBox] #1.graph "when leftButtonMove [firstFrame]" #1.graph "discard;rule OVER" #1.graph "boxfilled "; MouseX; " "; MouseY #1.graph "flush ; redraw" wait [finishEllipse] #1.graph "when leftButtonMove [firstFrame]" #1.graph "discard;rule OVER" #1.graph "place "; int((startX+MouseX)/2); " "; int((startY+MouseY)/2) #1.graph "ellipsefilled "; abs(MouseX-startX); " "; abs(MouseY-startY) #1.graph "flush ; redraw" wait [cls] #1.graph "cls" wait [setForLine] #1.graph "when leftButtonDown [startDraw]" #1.graph "when leftButtonMove [firstLine]" #1.graph "when leftButtonUp [finishLine]" wait [setForBox] #1.graph "when leftButtonDown [startDraw]" #1.graph "when leftButtonMove [firstFrame]" #1.graph "when leftButtonUp [finishBox]" wait [setForEllipse] #1.graph "when leftButtonDown [startDraw]" #1.graph "when leftButtonMove [firstFrame]" #1.graph "when leftButtonUp [finishEllipse]" wait [setForPan] filedialog "Get *.bmp file", "bmp\*.bmp", panFile$ if panFile$ = "" then [inputLoop] loadbmp "panWithMe", panFile$ #1.graph "when leftButtonDown [drawBmp]" #1.graph "when leftButtonMove [drawBmp]" #1.graph "when leftButtonUp [flushBmp]" wait [drawBmp] #1.graph "drawbmp panWithMe "; MouseX; " "; MouseY wait [flushBmp] #1.graph "flush" wait [colorRed] #1.graph "backcolor red" wait [colorYellow] #1.graph "backcolor yellow" wait [colorGreen] #1.graph "backcolor green" wait [colorBlue] #1.graph "backcolor blue" wait [lineThickness] dim thick$(10) for i = 1 to 10 thick$(i)=str$(i) next WindowWidth=210:WindowHeight=100 combobox #thick.sel, thick$(),[thickSelect],10,10,120,300 button #thick.default, "Okay",[newLineThick],UL,140,10,60,24 button #thick.cancel, "Cancel",[closeThick],UL,140,40,60,24 Open "Select Line Thickness" for dialog_modal as #thick #thick "trapclose [closeCol]" #thick.sel "select ";lineThickness$ #thick.sel "setfocus" wait [thickSelect] wait 'wait until user clicks OKAY to get color and close window [newLineThick] #thick.sel "selection? selectedThick$" lineThickness$=selectedThick$ #1.graph "size "; lineThickness$ [closeThick] close #thick: wait [lineColor] dim color$(12) color$(1)="black" color$(2)="darkpink" color$(3)="darkblue" color$(4)="darkgreen" color$(5)="darkred" color$(6)="darkgray" color$(7)="brown" color$(8)="darkcyan" color$(9)="lightgray" color$(10)="pink" color$(11)="cyan" color$(12)="white" WindowWidth=210:WindowHeight=100 combobox #col.sel, color$(),[colSelect],10,10,120,300 button #col.default, "Okay",[newLineColor],UL,140,10,60,24 button #col.cancel, "Cancel",[closeCol],UL,140,40,60,24 Open "Select Line Color" for dialog_modal as #col #col "trapclose [closeCol]" #col.sel "select ";lineColor$ #col.sel "setfocus" wait [colSelect] wait 'wait until user clicks OKAY to get color and close window [newLineColor] #col.sel "selection? selectedCol$" lineColor$=selectedCol$ #1.graph "color ";lineColor$ [closeCol] close #col: wait [save] filedialog "Save Drawing As","*.bmp",saveFile$ if saveFile$="" then wait #1.graph "getbmp saver 0 0 640 440" bmpsave "saver",saveFile$ unloadbmp "saver" wait [printIt] #1.graph "print vga" wait [quit] close #1: end