As3 中的贝塞尔曲线

发布于 2024-11-01 20:26:47 字数 137 浏览 4 评论 0原文

我是否正确地认为,从 Flash GUI 中只能绘制三次贝塞尔曲线,而从 Actionscript 中只能绘制二次贝塞尔曲线?真的吗?

这似乎是,嗯……我确信它不可能……如果我必须编写一个二次贝塞尔绘图应用程序来计算出一些点坐标,那就太疯狂了。

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 ? 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

听闻余生 2024-11-08 20:26:47

如果您使用绘图 API,则只能使用 curveTo() 函数绘制二次贝塞尔曲线。
http://help.adobe.com /en_US/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

If you're using the drawing API, then you can only draw Quadratic Bezier Curves using the curveTo() function.
http://help.adobe.com/en_US/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.farmcode.org/post/2009/07/06/Fast-2D-Bezier-Library-for-ActionScript-3.aspx

念三年u 2024-11-08 20:26:47

实际上,从昨天发布的 Flash Player 11 开始,绘图 API 支持三次贝塞尔曲线:(

以及此主要版本的其他改进和添加...)

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

Actually from Flash Player 11, released yesterday, the Drawing API supports Cubic Bezier curves:

(amongst other improvements and additions on this major release...)

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

尤怨 2024-11-08 20:26:47

这是一篇使用 fl.motion.BezierSegment 类在 ActionScript 中绘制三次贝塞尔曲线的精彩文章:

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);    
}

这真是一篇很棒的文章!

This is a great post to draw Cubic Bezier curves in ActionScript using the fl.motion.BezierSegment class:

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文