PDA

View Full Version : well, now I know how to draw dynamically, BUT...



supergokito
August 7th, 2003, 03:47 AM
How to recognise a shape???

I mean:

Ok most of the drawing apps made with Flash track the mouse and use the lineTo method. We can even track these points/vertex within an array and re-produce the polygon made by the user.

But what if I'd like to draw curves??? 'cause they're smoother than a couple of lines, right?

The challenge could also be recognising a shape imported from Freehand, Illustrator, or any other drawing application in order to be reproduced by a script.

Any ideas?

Thanks!!!

fluid_0ne
August 7th, 2003, 05:33 AM
welcome to the forum






um... use
curveTo(x,y,anchorX,anchorY);

pom
August 7th, 2003, 06:44 AM
curveTo is a bit harder to use than lineTo. Robert penner and Lifaros wrote nice functions to draw accurately, see if you can find them on their sites. Otherwise, I'll try to dig them up :)

λ
August 7th, 2003, 07:24 AM
This is a different way of using curveTo (made by Robert Penner);


MovieClip.prototype.curveThrough3Pts =
function (startX,startY,throughX,throughY,endX,endY){
var controlX = (2*throughX) - .5 * (startX+endX);
var controlY = (2*throughY) - .5 *(startY+endY);
this.moveTo(startX,startY);
this.curveTo(controlX, controlY, endX, endY);
}

There, if I didn't make a typo, that should work.

supergokito
August 7th, 2003, 07:30 AM
Thanks guys! But my question is not about drawing curves but about recognising curves.

Two examples:
1) the user holds the button and tries to draw a curve. Is it possible not to append straight lines to simulate that curve?
2) importing a shape into Flash, could I just find out which points and anchors form it??

See you!

senocular
August 7th, 2003, 07:57 AM
1) yes
2) you can import a shape from whereever, export to swf then use this

http://www.quasimondo.com/shapedecoder/qm_shape_decoder.php