How can I convert curveTo() to a list of Points?

前端 未结 3 1876
悲哀的现实
悲哀的现实 2021-01-02 06:46

Take the following AS3 that will draw a curved line using curveTo():

var line:Shape = new Shape();

line.x = line.y = 20;
line.graphics.lineStyl         


        
3条回答
  •  暖寄归人
    2021-01-02 07:18

    A Bezier curve is a parametric function. A quadratic Bezier curve (i.e. three control points) can be expressed as: F(t) = A(1 - t)^2 + B(1 - t)t + Ct^2 where A, B and C are points and t goes from zero to one.

    This will give you two equations:

    x = a(1 - t)^2 + b(1 - t)t + ct^2
    
    y = d(1 - t)^2 + e(1 - t)t + ft^2
    

    If you add for instance the line equation (y = kx + m) to that, you'll end up with three equations and three unknowns (x, y and t).

    from: How to find the mathematical function defining a bezier curve

    using this equation, you can create an array of x and y coordinates

提交回复
热议问题