Microsoft Small Basic

Program Listing: BRG626
GraphicsWindow.Width=500
GraphicsWindow.Height=400

GraphicsWindow.DrawBoundText(10,10,1000,"Teken met de muis ongeveer een cirkel.")
GraphicsWindow.DrawBoundText(10,20,1000,"Dit programma maakt er een prefecte ellips van!")

GraphicsWindow.MouseDown=OnMouseDown
GraphicsWindow.MouseMove=OnMouseMove
GraphicsWindow.MouseUp=OnMouseUp



Sub OnMouseUp
down=0

'wis alle getekende punten
For teller=1 to count
GraphicsWindow.SetPixel(punt[teller]["x"],punt[teller]["y"],"white")
endfor


'teken een passende cirkel aan de hand van xmin, xmax, ymin, ymax
GraphicsWindow.DrawEllipse(xmin,ymin,xmax-xmin,ymax-ymin)
endsub

Sub OnMouseMove
If down=1 then
'bewaar de huidige positie van de muis
count=count+1
punt[count]["x"]=GraphicsWindow.MouseX
punt[count]["y"]=GraphicsWindow.MouseY

'teken de muis positie
GraphicsWindow.SetPixel(GraphicsWindow.MouseX, GraphicsWindow.MouseY,"blue")

If GraphicsWindow.mousex xmin=GraphicsWindow.mousex
endif

If GraphicsWindow.mousex>xmax then
xmax=GraphicsWindow.mousex
endif

If GraphicsWindow.mousey ymin=GraphicsWindow.mousey
endif

If GraphicsWindow.mousey>ymax then
ymax=GraphicsWindow.mousey
endif


endif
endsub

Sub OnMouseDown
down=1
count=0

'dit zijn de kleinste en grootste x en y-coordinaten tot nu toe
xmin=GraphicsWindow.MouseX
xmax=xmin

ymin=GraphicsWindow.MouseY
ymax=ymin


endsub