// This program draws shapes which can be clicked on with the mouse. // Click on each shape and it's description is shown at the top. // Note that the blue square is not clickable (intentionally). // Note that if items overlap, the last one specified gets selected. // Try zooming and scrolling and then clicking on shapes. // Click on the "Exit" rectangle to close and end the program. include standard_colors.txt degrees dim pa(4,2) dim star (10,2) dim zigzag (6,2) dim names$ (21) //debug mousecheckforward graph equalscales,landscape shape mouseclick,radius=10,center=(0,25),fillcolor=red shape ellipse names$ (lastshapeid) = "red ellipse" shape mouseclick,center=(10,11) shape fillcolor=green,rectangle names$ (lastshapeid) = "green rectangle" shape radius=5,center=(-10,10) shape filltype=solid,fillcolor=blue,rectangle shape bottom=10,top=40,left=40,right=40,characters="AB" shape bold=1000, ITALIC=1, font="Times New Roman" shape fillcolor=magenta shape mouseclick,text names$ (lastshapeid) = "magenta text" pa(0,0) = 25: pa(0,1) = 5 pa(1,0) = 35: pa(1,1) = 15 pa(2,0) = 30: pa(2,1) = 20 shape fillcolor=gray_50 shape polycount=3, polypoints=pa shape mouseclick, polygon names$ (lastshapeid) = "gray triangle" r = 10 x = 18: y = 25 for i = 0 to 9 star (i,0) = x + r * sin (36 * i) star (i,1) = y + r * cos (36 * i) i = i + 1 star (i,0) = x + r/2 * sin (36 * i) star (i,1) = y + r/2 * cos (36 * i) next shape polypoints = star, polycount = 10, smooth=6,filltype=hatch shape mouseclick, polygon names$ (lastshapeid) = "star" shape smooth = 0 shape mouseclick, beginpath names$ (lastshapeid) = "gold box with hole" shape fillcolor= (216, 180, 0), filltype=solid shape center=(50, 40), radius=10, rectangle shape closefigure shape radius=5, direction=reverse, ellipse shape endpath shape strokefill shape direction=normal shape center=(25,40),radius=10,filltype=solid shape startangle=0,endangle=40,fillcolor=red,mouseclick,pie names$(lastshapeid) = "red pie" shape startangle=40,endangle=150,fillcolor=yellow,mouseclick,pie names$(lastshapeid) = "yellow pie" shape startangle=150,endangle=210,fillcolor=green,mouseclick,pie names$(lastshapeid) = "green pie" shape startangle=210,endangle=360,fillcolor=blue,mouseclick,pie names$(lastshapeid) = "blue pie" shape linestart=(-10,40),lineend=(0,30),linecolor=purple,lineweight=6 shape mouseclick,line names$(lastshapeid) = "purple line" shape linecolor=black,lineweight=1 shape startangle=0,endangle=90,radius=10,center=(35,20) shape mouseclick,arc names$(lastshapeid) = "arc" shape linestart = (50,55), lineend = (70,70) shape ctlpt1 = (65,60),ctlpt2 = (60,75), mouseclick,bezier names$(lastshapeid) = "Bezier Curve" nnn$ = "Click on a shape." text h=70,v=95,size=30,string=nnn$ zigzag (0,0) = 0: zigzag (0,1) = 65 zigzag (1,0) = 5: zigzag (1,1) = 70 zigzag (2,0) = 10: zigzag (2,1) = 60 zigzag (3,0) = 15: zigzag (3,1) = 70 zigzag (4,0) = 20: zigzag (4,1) = 60 zigzag (5,0) = 25: zigzag (5,1) = 70 shape polypoints = zigzag, polycount=6, mouseclick, polyline names$(lastshapeid) = "Poly Line" shape mouseclick,left=0,right=15,bottom=50,top=55 shape fillcolor=gray_12,filltype=solid,rectangle names$ (lastshapeid) = "EXIT" exit_id = lastshapeid text x=7.5, y=51,datasize=5,string="EXIT" //========================================================= 100 // loop to check for mouseclicks delay 10 id = CHECKMOUSECLICK if id = -1 then goto 100 // replace the string in the TEXT at the top of the screen. if id = -2 then nnn$ = "(No Selection)" if id >= 0 then nnn$ = names$(id) if id < -2 then ch$ = chr$ (abs (id)): nnn$ = "Character " + ch$ if id <> -9 then graph grid // force graph to update (to show the new text) if id < -2 then print -id, "Character "; ch$ : goto 100 // character (keystroke) if id >= 0 then goto 177 print id, mousexcoord, mouseycoord, "(no selection)" goto 100 177 if id >= 0 then print id, mousexcoord, mouseycoord, names$(id) if id = exit_id then goto 200 // -- DEBUG -- DELETESHAPE id // -- END DEBUG -- goto 100 200 graph end end