|
|
|
Vector Shape - Create Ellipse (Improved)
Added on 9/30/2006
|
This is a more accurate algorithm which will draw an ellipse or circle more accurately. In fact, it's impossible to draw a perfect circle using bezier curves, but we can approximate it very closely using kappa (k). For those interested, info can be found here: http://www.whizkidtech.redprince.net/bezier/circle/
on createEllipse (aWidth, aHeight)
rX = aWidth / 2.0
if voidP(aHeight) then aHeight = aWidth
rY = aHeight / 2.0
pt1 = point(rX*cos(3.92699081698724), rY*sin(3.92699081698724))
pt2 = point(rX*cos(5.49778714378214), rY*sin(5.49778714378214))
pt3 = point(rX*cos(0.78539816339745), rY*sin(0.78539816339745))
pt4 = point(rX*cos(2.35619449019234), rY*sin(2.35619449019234))
k = 0.552284749830794
vertList = [[#vertex: pt1, #handle1: pt1 * point(-k, k), #handle2: pt1 * point(k, -k)], [#vertex: pt2, #handle1: pt2 * point(k, -k), #handle2: pt2 * point(-k, k)], [#vertex: pt3, #handle1: pt3 * point(-k, k), #handle2: pt3 * point(k, -k)], [#vertex: pt4, #handle1: pt4 * point(k, -k), #handle2: pt4 * point(-k, k)]]
return vertList
end
|
|