Bezier

Bezier approximation methods used in SVG import.

Summary
BezierBezier approximation methods used in SVG import.
Variables
toleranceApproximation deviation tolerance.
Functions
BezierBezier object Constructor
getQuadBezierCalls either GetQuadBez_TG or GetQuadBez_RP depending on tolerance.
GetQuadBez_TGMidpoint approximation of a cubic bezier with four quad segments.
GetQuadBez_RPRecursive midpoint approximation of a cubic bezier with as many quadratic bezier segments (n) as required to achieve specified tolerance.

Variables

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)

Functions

Bezier

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

Parameters

p1first anchor
p2second anchor
c1first control
c2second control

getQuadBezier

private function getQuadBezier(p1Anchor: Point,
p2Anchor: Point,
c1Control: Point,
c2Control: Point):void

Calls either GetQuadBez_TG or GetQuadBez_RP depending on tolerance.

Parameters

p1Anchorfirst anchor
p2Anchorsecond anchor
c1Controlfirst control
c2Controlsecond control

GetQuadBez_TG

private function GetQuadBez_TG(P0: Point,
P1: Point,
P2: Point,
P3: Point):void

Midpoint approximation of a cubic bezier with four quad segments.  Set tolerance to zero to use it.  Adds 4 elements to QPts array.

Parameters

P0first anchor
P1first control
P2second control
P3second anchor

GetQuadBez_RP

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.

Parameters

afirst anchor point
bfirst control point
csecond control point
dsecond anchor point
ktolerance (low number = most accurate result)
public static var tolerance: int
Approximation deviation tolerance.
public function Bezier(p1Anchor: Point,
p2Anchor: Point,
c1Control: Point,
c2Control: Point):void
Bezier object Constructor
private function getQuadBezier(p1Anchor: Point,
p2Anchor: Point,
c1Control: Point,
c2Control: Point):void
Calls either GetQuadBez_TG or GetQuadBez_RP depending on tolerance.
private function GetQuadBez_TG(P0: Point,
P1: Point,
P2: Point,
P3: Point):void
Midpoint approximation of a cubic bezier with four quad segments.
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.
Close