绘制三次Bezier曲线的Actionscript?曲线、Bezier、Actionscript

2023-09-08 13:43:38 作者:扯起微笑装坚强

什么是绘制三次Bezier曲线编程在AS3的最佳方法是什么?该图形类似乎只支持二次曲线。 :(我希望能够做一些事情,如:

  VAR的startPoint:点=新的点(0,0);
VAR端点:点=新的点(5,5);
VAR控制1:点=新的点(5,0);
VAR控制2:点=新的点(0,5);

VAR myBezier:雪碧= getBezier(的startPoint,控制1,控制2,终点);
 

有关为服务目标,我打算让〜50这些在舞台上的一次。

解决方案   

注意:的Flash Player 11日起,包括一个本地方法来绘制三次曲线, cubicCurveTo()这应该是最快的方法,如果你的目标FP11。

就在上周,我写了一个类来绘制任意阶Bezier曲线。

在code未优化,但在我的测试工作正常。业绩是做动画(虽然我不认为这是一个好主意,滥用它,因为正如我说这不是优化的接受事件,它没有任何意义的使用,当然这些对于二次曲线,因为玩家可以这样做本身)。

在code是在这里,如果你想使用它,或者看看:

bezier曲线 bezier曲线绘制 CSDN

的BezierCurve类

样品code

我想这与样品code,你将能够找出如何使用它没有麻烦(这是相当简单的,有点评论);但是,如果你遇到问题,请走开!

随意使用它,你认为合适的。

What's the best way to draw cubic bezier curves programmatically in AS3? The Graphics class only seems to support quadratic curves. :( I want to be able to do something like:

var startPoint:Point = new Point(0, 0);
var endPoint:Point = new Point(5, 5);
var control1:Point = new Point(5, 0);
var control2:Point = new Point(0, 5);

var myBezier:Sprite = getBezier(startPoint, control1, control2, endPoint);

For a performance target, I'm planning on having ~50 of these on the stage at once.

解决方案

Note: Flash Player 11 onwards includes a native method to draw cubic curves, cubicCurveTo() which should be the fastest method if you are targeting FP11.

Just last week I wrote a class to draw Bezier curves of arbitrary order.

The code is not optimized but works fine in my tests. Performance is acceptable event for doing animations (although I don't think it's a good idea to abuse it, since as I said it's not optimized; it doesn't make sense to use these for quadratic curves, of course, since the player can do that natively).

The code is here if you want to use it or take a look:

The BezierCurve class

Sample code

I think that with the sample code you will be able to figure out how to use it without trouble (it's quite straight forward and somewhat commented); but if you run into problems, ask away!

Feel free to use it as you see fit.