Drawing a "Centered" Circle
Jim Lyons
jimlyons at earthlink.net
Mon May 17 17:17:02 EDT 2004
Rob asked:
> Has anyone given any thought or scripting time to exploring what it
> would take to draw a circle that is centered over the loc of the
> original mouseDown?
Make an oval graphic and call it "circ", then put this into the card
script:
local centerPoint
on mouseDown
put the mouseLoc into centerPoint
hide grc "circ"
end mouseDown
on mouseMove x,y
if centerPoint is empty then exit mouseMove
put sqrt((x-item 1 of centerPoint)^2 + (y-item 2 of centerPoint)^2)
into radius
set the width of grc "circ" to 2*radius
set the height of grc "circ" to 2*radius
show grc "circ" at centerPoint
end mouseMove
on mouseUp
put empty into centerPoint
end mouseUp
You can modify as needed to show or hide the graphic when you want. HTH.
Jim Lyons
More information about the use-livecode
mailing list