Drawing a "Centered" Circle

Jim Hurley jhurley at infostations.com
Mon May 17 15:32:11 EDT 2004


>
>Message: 9
>Date: Mon, 17 May 2004 08:05:35 -0700
>From: Rob Cozens <rcozens at pon.net>
>Subject: Drawing a "Centered" Circle
>To: How to use Revolution <use-revolution at lists.runrev.com>
>Message-ID: <a05100300bcce7fcba699@[66.52.165.134]>
>Content-Type: text/plain; charset="us-ascii" ; format="flowed"
>
>Hi All,
>
>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?
>
>In the course of public presentation I would like to project a map
>and allow people in the audience to identify an area on the map by
>drawing a circle around it with a mouse.
>
>Using Transcript's oval tool the loc & shape of a circle change as
>the mouseLoc changes.  I want the effect of a perfect circle growing
>or shrinking around a fixed point as the mouse recedes from or
>approaches that point.
>
>At the moment, the approach I'm contemplating involves:
>
>1.  Drawing a minimal circle on mouseDown
>2.  Changing the oval tool's ink (or visible property?) to make a new
>invisible oval.
>3.  On mouseMove change the width & height of the original circle to
>the distance between the mouseDown loc and the current mouse loc
>4.  On mouseUp delete the invisible oval.
>
>Anyone have any comments or a better solution to offer?
>
>TIA.
>--
>
>Rob Cozens
>CCW, Serendipity Software Company


Rob,

This works for me. It's probably what you had in mind.

Jim

Card Script

local myName,x1,y1 -- Or use custom properties.

on mouseDown
   if there is not graphic "circle" then
     set the style of the templateGraphic to Oval
     create graphic "circle"
   end if
   put the name of me into myname
   put the mouseH into x1
   put the mouseV into y1
end mouseDown

on mouseUP
   put "" into myName
end mouseUP

on mouseMove x,y
   if myName is "" then exit mouseMove
   put distance(x,y) into r
   set the rect of grc "circle" to x1-r,y1-r,x1+r,y1+r
end mouseMove

function distance x,y
   return trunc(sqrt((x1-x)^2 + (y1-y)^2))
end distance


More information about the use-livecode mailing list