简体   繁体   English

As3中的贝塞尔曲线

[英]Bezier curves in As3

Am i right in thinking that from the Flash GUI you can only draw Cubic Bezier Curves, and from Actionscript you can only draw Quadratic Bezier Curves ? 我是否认为从Flash GUI中只能绘制三次贝塞尔曲线,而从Actionscript中只能绘制二次贝塞尔曲线? Really? 真?

This seems, well.. im sure it cant be.. It would be crazy if i had to write a Quadratic Bezier drawing app to work out some point co-ordinates. 这似乎很好..我肯定不能。.如果我不得不编写一个Quadratic Bezier绘图应用程序来计算一些点坐标,那将是疯狂的。

If you're using the drawing API, then you can only draw Quadratic Bezier Curves using the curveTo() function. 如果您使用的是绘图API,则只能使用curveTo()函数绘制二次贝塞尔曲线。 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#curveTo () http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#curveTo ()

For proper bezier curves, it's not that hard, but you'll have to do it yourself. 对于适当的贝塞尔曲线,并不难,但是您必须自己做。 Some quick links with source code that I found: http://www.paultondeur.com/2008/03/09/drawing-a-cubic-bezier-curve-using-actionscript-3/ 我发现的一些与源代码的快速链接: http : //www.paultondeur.com/2008/03/09/drawing-a-cubic-bezier-curve-using-actionscript-3/

http://www.farmcode.org/post/2009/07/06/Fast-2D-Bezier-Library-for-ActionScript-3.aspx http://www.farmcode.org/post/2009/07/06/Fast-2D-Bezier-Library-for-ActionScript-3.aspx

Actually from Flash Player 11, released yesterday, the Drawing API supports Cubic Bezier curves: 实际上是从昨天发布的Flash Player 11开始,Drawing API支持Cubic Bezier曲线:

(amongst other improvements and additions on this major release...) (除了此主要版本的其他改进和增补...)

http://www.adobe.com/devnet/flashplayer/articles/whats-new-flash-player11.html http://www.adobe.com/devnet/flashplayer/articles/whats-new-flash-player11.html

This is a great post to draw Cubic Bezier curves in ActionScript using the fl.motion.BezierSegment class: 这是一篇很棒的文章,使用fl.motion.BezierSegment类在ActionScript中绘制了三次Bezier曲线:

http://www.eleqtriq.com/2010/04/cubic-bezier-in-flash/ http://www.eleqtriq.com/2010/04/cubic-bezier-in-flash/

It's awesome - I created a complete curve with multiple segments with a fraction of the code and classes you need for most of the other links on this page: 太棒了-我创建了一条完整的曲线,其中包含多个段,以及此页面上大多数其他链接所需的部分代码和类:

var resolution  :uint       = 50;
var step        :Number     = 1/resolution;

function drawCurve(p0:Point, c0:Point, c1:Point, p1:Point)
{
    var bezier  :BezierSegment  = new BezierSegment(p0, c0, c1, p1);
    var t       :Number         = 0;
    while (t <= 1)
    {
        var pt:Point = bezier.getValue(t);
        with (graphics)
        {
            lineStyle(0.1, 0x00FFFF);
            t == 0
                ? moveTo(pt.x, pt.y)
                : lineTo(pt.x, pt.y);
        }
        t+=step;
    }   
    pt = bezier.getValue(1);
    graphics.lineTo(pt.x, pt.y);    
}

It's a really great post! 这是一个很棒的帖子!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM