Hi, pretty cool :)
If I had to guess I'd say the twist is caused by moving to a controlpoint instead of the average of one. Could you try moving to (firstPoint+lastPoint)/2 ? greetz JC On 7/18/07, Ash Warren <[EMAIL PROTECTED]> wrote:
Oh I feel like I'm sooo close. Here is what I have after your last suggestion: http://www.ashbrand.com/curveTo_circle_3.swf It looks pretty good at first glance but if you zoom in on the file you will see that the vector looks "twisted" at the top. Here is the code that is driving that file: /*--------------------------------------------------------------------*/ this.displayClip.beginFill (0xF0A0B9, 45); var lastPoint:MovieClip = this.controlPoints [this.controlPoints.length - 1]; var endX:Number, endY:Number; var thisPoint:MovieClip; var nextPoint:MovieClip; this.displayClip.moveTo (lastPoint._x, lastPoint._y); for (var i:Number = 0; i < this.controlPoints.length; i++) { thisPoint = this.controlPoints[i]; nextPoint = this.controlPoints[(i + 1) % this.controlPoints.length]; endX = (thisPoint._x + nextPoint._x) / 2; endY = (thisPoint._y + nextPoint._y) / 2; this.displayClip.curveTo (thisPoint._x, thisPoint._y, endX, endY); } this.displayClip.endFill (); /*--------------------------------------------------------------------*/ Thank you very much for your help. Ash -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hans Wichman Sent: Tuesday, July 17, 2007 4:24 PM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Drawing API :: curveTo assistance, code and example inside Hi, shouldnt the this.pLine.moveTo (0,100); be control point based as well? greetz JC On 7/17/07, Ash Warren <[EMAIL PROTECTED]> wrote: > > Well that seemed to kind of get me closer, here is the latest example > using > your code tip (pasted below) > > http://www.ashbrand.com/curveto_circle_2.swf > > Thank you. > > /*--------------------------------------------------------------------*/ > this.pLine.beginFill (0xF0A0B9); > var endX:Number, endY:Number; > var thisPoint:MovieClip; > var nextPoint:MovieClip; > this.pLine.moveTo (0,100); > > for (var i:Number = 0; i < this.controlPoints.length; i++) > { > thisPoint = this.controlPoints[i]; > nextPoint = this.controlPoints[(i + 1) % > controlPoints.length]; > endX = (thisPoint._x + nextPoint._x) / 2; > endY = (thisPoint._y + nextPoint._y) / 2; > this.pLine.curveTo (thisPoint._x, thisPoint._y, endX, > endY); > } > > this.pLine.endFill (); > /*--------------------------------------------------------------------*/ > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Hans > Wichman > Sent: Tuesday, July 17, 2007 2:55 PM > To: flashcoders@chattyfig.figleaf.com > Subject: Re: [Flashcoders] Drawing API :: curveTo assistance, code and > example inside > > Hi, > my quick guess is, let the loop run from 0 to i < controlPoints.lengthand > do the lookup like > this.controlPoints[ (i+1)%controlPoints.length ] > > Just a guess though, but I think that might be it. > And then skip the last curveTo outside of the loop. > > greetz > JC > > > On 7/17/07, Ash Warren <[EMAIL PROTECTED]> wrote: > > > > This might be a better example: > > > > http://www.ashbrand.com/curveto_circle.swf > > > > I am using basically the same code however, please see below: > > > > /*--------------------------------------------------------------------*/ > > this.pLine.beginFill (0xF0A0B9); > > var endX:Number, endY:Number; > > var thisPoint:MovieClip; > > var nextPoint:MovieClip; > > this.pLine.moveTo (0,100); > > > > for (var i:Number = 0; i < this.controlPoints.length - 1; i++) > > { > > thisPoint = this.controlPoints[i]; > > nextPoint = this.controlPoints[i + 1]; > > endX = (thisPoint._x + nextPoint._x) / 2; > > endY = (thisPoint._y + nextPoint._y) / 2; > > this.pLine.curveTo (thisPoint._x, thisPoint._y, endX, > > endY); > > } > > > > var lastPoint:MovieClip = > > this.controlPoints[this.controlPoints.length - 1]; > > this.pLine.curveTo (lastPoint._x,lastPoint._y, 0, 100); > > > > this.pLine.endFill (); > > /*--------------------------------------------------------------------*/ > > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Ash > Warren > > Sent: Tuesday, July 17, 2007 1:44 PM > > To: flashcoders@chattyfig.figleaf.com > > Subject: [Flashcoders] Drawing API :: curveTo assistance, code and > example > > inside > > > > I am trying to create a very simple way for a user to manipulate a mask > > shape in Flash using curveTo. > > > > After finding a few great online examples I feel that I'm getting pretty > > close, however I cannot get rid of my "corner" control point that > > begins/ends the shape. > > > > Please view the example here and click on the top center point to see > what > > I > > mean, it manipulates the shape at more of a "right" angle instead of a > > nice > > subtle curve like the others. > > > > http://www.ashbrand.com/curveto.swf > > > > The code that I am using is posted below (where "controlPoints" is > simply > > an > > array holding the x and y values for those points and "p1" is the actual > > mc > > on the stage that acts as the start/end of the shape). > > > > I feel like such a newb when it comes to beziers and the drawing API in > > Flash. Thank you in advance for any assistance. > > > > /*--------------------------------------------------------------------*/ > > this.pLine.beginFill (0xF0A0B9); > > > > var startX:Number = this.p1._x; > > var startY:Number = this.p1._y; > > var endX:Number, endY:Number; > > var thisPoint:MovieClip; > > var nextPoint:MovieClip; > > this.pLine.moveTo (startX,startY); > > > > for (var i:Number = 0; i < this.controlPoints.length - 1; i++) > > { > > thisPoint = this.controlPoints[i]; > > nextPoint = this.controlPoints[i + 1]; > > endX = (thisPoint._x + nextPoint._x) / 2; > > endY = (thisPoint._y + nextPoint._y) / 2; > > this.pLine.curveTo (thisPoint._x, thisPoint._y, endX, > > endY); > > > > startX = endX; > > startY = endY; > > } > > > > var lastPoint:MovieClip = > > this.controlPoints[this.controlPoints.length - 1]; > > this.pLine.curveTo (lastPoint._x,lastPoint._y, this.p1._x, > > this.p1._y); > > > > this.pLine.endFill (); > > /*--------------------------------------------------------------------*/ > > > > _______________________________________________ > > Flashcoders@chattyfig.figleaf.com > > To change your subscription options or search the archive: > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > Brought to you by Fig Leaf Software > > Premier Authorized Adobe Consulting and Training > > http://www.figleaf.com > > http://training.figleaf.com > > > > _______________________________________________ > > Flashcoders@chattyfig.figleaf.com > > To change your subscription options or search the archive: > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > Brought to you by Fig Leaf Software > > Premier Authorized Adobe Consulting and Training > > http://www.figleaf.com > > http://training.figleaf.com > > > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com