Points of Graphic Oval

hh hh at hyperhh.de
Mon Jul 31 04:38:24 EDT 2017


> BR wrote:
> 1) draw graphic  oval  name:  "moveClue1"
> 2) create small image "word_1"
> move image "word_1" to the points of grc "moveClue1" in 2 seconds
> OK, so how can we generate the points of a perfect oval?

> > Scott wrote:
> > You can use the effectivePoints to get the points of any graphic shape,
> > but depending on the size, your oval may produce too many points.
> > In any event, your source oval doesn't need to be perfect. If you
> > a "decent" number of points along the shape of the oval, your image
> > will have the appearance of moving along an elliptical path.

You don't need to create a graphic for that, a ("decent") list of points
is enough:

on mouseUp
  put 200 into x0
  put 200 into y0
  put 100 into rx
  put 100 into ry
  put 36 into n0 #<-- usually enough vertices for 1.5 seconds
  move image 1 to ellipticalPoints(n0,rx,ry,x0,y0) in 1500 millisecs
end mouseUp

### yields points of a elliptical n-sided polygon
### circular: set rx=ry
-- n0 is the number of vertices (= n+1 points as closed polygon)
-- rx is the horizontal radius
-- ry is the vertical radius
-- x0 is the x-coord of the center
-- y0 is the x-coord of the center
function ellipticalPoints n0,rx,ry,x0,y0
  put 2*pi/n0 into cn
  -- n0 vertices --> n0+1 points as we want a 'closed' polygon
  -- This is here true as sin(0)=sin(2*pi) and cos(0)=cos(2*pi)
  put empty into pts
  repeat with j= 0 to n0
    put CR & (round(rx*sin(j*cn)+x0),round(-ry*cos(j*cn)+y0)) after pts
  end repeat
  return char 2 to -1 of of pts
end ellipticalPoints





More information about the use-livecode mailing list