Points of Graphic Oval

hh hh at hyperhh.de
Mon Jul 31 05:02:00 EDT 2017


[Once again, without typos (although it works correctly with the typos)]

The following runs in LC 6/7/8/9.

### yields points of an 'elliptical' n0-sided polygon,
### for a 'circular' shape set rx=ry.
-- n0 is the number of vertices (= n0+1 points for a closed polygon)
-- rx is the horizontal radius
-- ry is the vertical radius
-- x0 is the horizontal coord of the shape's center
-- y0 is the vertical coord of the shape's 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 (start=end)
  -- 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 pts
end ellipticalPoints





More information about the use-livecode mailing list