As3中的贝塞尔曲线

| 我是否认为从Flash GUI中只能绘制三次贝塞尔曲线,而从Actionscript中只能绘制二次贝塞尔曲线?真? 这似乎很好..我不确定它不可能..如果我不得不编写一个Quadratic Bezier绘图应用程序来计算一些点坐标,那将是疯狂的。     
已邀请:
如果您使用的是绘图API,则只能使用curveTo()函数绘制二次贝塞尔曲线。 http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#curveTo() 对于适当的贝塞尔曲线,并不难,但是您必须自己做。我发现的一些与源代码的快速链接: 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     
实际上是从昨天发布的Flash Player 11开始,Drawing API支持Cubic Bezier曲线: (除了此主要版本的其他改进和增补...) http://www.adobe.com/devnet/flashplayer/articles/whats-new-flash-player11.html     
这是使用fl.motion.BezierSegment类在ActionScript中绘制Cubic Bezier曲线的好文章: http://www.eleqtriq.com/2010/04/cubic-bezier-in-flash/ 太棒了-我创建了一条完整的曲线,其中包含多个段,以及此页面上大多数其他链接所需的部分代码和类:
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);    
}
这是一个很棒的帖子!     

要回复问题请先登录注册