This content has been marked as final. Show 4 replies
If it's just a circle, why not use the ellipse-shape tool already in the
program? I've found that the vector shape tool in this program is almost
too buggy to even consider using. I go into the vector-editor, try moving a
few points around, and it only takes a few minutes for the interface to go
all wacky and then you can't do anything, and the vector member is forever
corrupt, even a save-reload won't make it work anymore. Not worth the
Another option would be to make a shape in Flash and import that. Either
way it's less complicated than figuring out the math for those vector
handles, and less likely to totally screw up.
Oh, that's rich. I was going to try a little experiment just to see if I
could come up with something. All I did was try to open the Vector window.
Froze the system for a full minute, and then finally "Fatal Error. Director
will quit now." Yeah, I'm gonna go ahead and just reiterate my previous
statement. Don't use vector shapes. Feature is broken.
I also have seen some issues working in the vector editor. Fortunately that
is not what I am doing. Users of the program I am building can create shapes
by clicking and dragging their mouse. Behind the scenes the code is
adding/modifying the vertexList of a single vector shape. This is all
working rock-solid. Previously users could create rectangles, polygons
(including complex polygons) and freehand shapes using vectors, but I want
to add circles.
This is all part of a multi-user game, where one user is creating these
shapes and sending them to other users (movies) over the internet. Sending a
small list of coodinates is much more efficient than sending an image.
Movies on the other end can reconstruct the shapes based on the vertexList
received. Also I have already implemented the code to handle vectors, and
would like to avoid having to write extra code just to handle circles drawn
in a bitmap member.
Any way I have noticed that the ratio of a vertex point to a handle point is
consistent for circle shapes, approximately 1.786. So I wrote a fairly
simple function that takes the desired radius as a parameter and updates
vertex and handles appropriately. I haven't fully tested this yet, but
initial results seem to be acceptable for my needs.
I don't know whether this will help, but here's a snippet from a project
that allows users to draw ellipses (w and h are width and height - keep
them the same to create a circle, in which case there's no need to
separately calculate hOffset and vOffset):
-- calculate vertices and control points for an ellipse:
const = (2.0/3) * (sqrt(2.0) - 1)
hOffset = w * const
vOffset = h * const
tVertexList = [#vertex: point(0.0, h/2), \
#handle1: point(0.0, -vOffset), #handle2: point(0.0, vOffset)]
tVertexList = [#vertex: point(w/2, 0.0), \
#handle1: point(hOffset, 0.0), #handle2: point(-hOffset, 0.0)]
tVertexList = [#vertex: point(w , h/2), \
#handle1: point(0.0, vOffset), #handle2: point(0.0, -vOffset)]
tVertexList = [#vertex: point(w/2, h), \
#handle1: point(-hOffset, 0.0), #handle2: point(hOffset, 0.0)]