4 Replies Latest reply on Jun 14, 2006 2:53 PM by Newsgroup_User

    Changing a circular vector shape's size

    Level 7
      I need to be able to change (via lingo) the vertex list of a circle so that
      it becomes bigger/smaller based on the user dragging the mouse. I can't just
      change the rect of the sprite, as I want to extract the alpha from the
      vector member when the user has stopped dragging the mouse.

      I can change the size of the vector shape easily by
      incrementing/decrementing each vertex (4 in a circle) but of course it loses
      it's shape because I am not adjusting the points that make up the handles. I
      would imagine that for circles, there is a simple formula for calculating
      the points of the handle based on the vertices. Does anyone know? Is there
      a simpler solution I am overlooking altogether?


        • 1. Re: Changing a circular vector shape's size
          Level 7
          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
          hassle.

          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.


          • 2. Re: Changing a circular vector shape's size
            Level 7
            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.


            • 3. Re: Changing a circular vector shape's size
              Level 7
              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.

              Thanks


              • 4. Re: Changing a circular vector shape's size
                Level 7
                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[1] = [#vertex: point(0.0, h/2), \
                #handle1: point(0.0, -vOffset), #handle2: point(0.0, vOffset)]
                tVertexList[2] = [#vertex: point(w/2, 0.0), \
                #handle1: point(hOffset, 0.0), #handle2: point(-hOffset, 0.0)]
                tVertexList[3] = [#vertex: point(w , h/2), \
                #handle1: point(0.0, vOffset), #handle2: point(0.0, -vOffset)]
                tVertexList[4] = [#vertex: point(w/2, h), \
                #handle1: point(-hOffset, 0.0), #handle2: point(hOffset, 0.0)]