Bezier approximation methods used in SVG import.
Bezier | Bezier approximation methods used in SVG import. |
Variables | |
tolerance | Approximation deviation tolerance. |
Functions | |
Bezier | Bezier object Constructor |
getQuadBezier | Calls either GetQuadBez_TG or GetQuadBez_RP depending on tolerance. |
GetQuadBez_TG | Midpoint approximation of a cubic bezier with four quad segments. |
GetQuadBez_RP | Recursive midpoint approximation of a cubic bezier with as many quadratic bezier segments (n) as required to achieve specified tolerance. |
public static var tolerance: int
Approximation deviation tolerance.
Set tolerance to zero to use Timothee Groleau’s midpoint method. Or larger than zero to use Robert Penner’s recursive approximation method. In Robert Penner’s version of getQuadBezier, the last argument is tolerance (1 = very accurate, 25 (eg) = faster, not so accurate)
public function Bezier( p1Anchor: Point, p2Anchor: Point, c1Control: Point, c2Control: Point ):void
Bezier object Constructor
Defines a cubic bezier curve with anchor points p1 and p2, and control points c1 and c2. Also calls getQuadBezier to create an array of quadratic bezier points, QPts, which approximate the cubic
p1 | first anchor |
p2 | second anchor |
c1 | first control |
c2 | second control |
private function getQuadBezier( p1Anchor: Point, p2Anchor: Point, c1Control: Point, c2Control: Point ):void
Calls either GetQuadBez_TG or GetQuadBez_RP depending on tolerance.
p1Anchor | first anchor |
p2Anchor | second anchor |
c1Control | first control |
c2Control | second control |
private function GetQuadBez_RP( a: Point, b: Point, c: Point, d: Point, k: int ):void
Recursive midpoint approximation of a cubic bezier with as many quadratic bezier segments (n) as required to achieve specified tolerance. Set tolerance larger than zero to use. Adds n elements to QPts array.
a | first anchor point |
b | first control point |
c | second control point |
d | second anchor point |
k | tolerance (low number = most accurate result) |
Approximation deviation tolerance.
public static var tolerance: int
Bezier object Constructor
public function Bezier( p1Anchor: Point, p2Anchor: Point, c1Control: Point, c2Control: Point ):void
Calls either GetQuadBez_TG or GetQuadBez_RP depending on tolerance.
private function getQuadBezier( p1Anchor: Point, p2Anchor: Point, c1Control: Point, c2Control: Point ):void
Midpoint approximation of a cubic bezier with four quad segments.
private function GetQuadBez_TG( P0: Point, P1: Point, P2: Point, P3: Point ):void
Recursive midpoint approximation of a cubic bezier with as many quadratic bezier segments (n) as required to achieve specified tolerance.
private function GetQuadBez_RP( a: Point, b: Point, c: Point, d: Point, k: int ):void