PEBezier.mesa
Written by Darlene Plebon on August 3, 1983 11:31 am
Bezier routines for the Path Editor.
DIRECTORY
CGCubic USING [Bezier],
PETypes;
PEBezier: CEDAR DEFINITIONS =
BEGIN OPEN PETypes;
Bezier: TYPE = CGCubic.Bezier;
BezierLineProc: TYPE = PROCEDURE[t0, t3: REAL, bezier: Bezier];
BezierSubdivideUntilLines: PROCEDURE [bezier: Bezier, proc: BezierLineProc, depth: NAT ← 0, t0: REAL ← 0.0, t3: REAL ← 1.0];
This routine runs the bezier subdivision algorithm on a bezier cubic segment applying the specified client procedure to each straight line segment generated. The client procedure is passed the endpoints of the line segment and the value of the parameter t at the endpoints.
This routine uses flatness and maximum depth tests to control the recursion.
BezierPointProc: TYPE = PROCEDURE[t: REAL, p: Point];
BezierSubdivideUntilPoints: PROCEDURE [bezier: Bezier, proc: BezierPointProc, t0: REAL ← 0.0, t3: REAL ← 1.0];
This routine runs the bezier subdivision algorithm on a bezier cubic segment applying the specified client procedure to each point generated. The client procedure is passed the point and the value of the parameter t at that point. The subdivision is halted when we get down to pixel resolution.
SegmentToBezier: PROCEDURE [segment: Segment] RETURNS [bezier: Bezier];
SegmentToBezier converts a bezier spline segment from our segment representation to the bezier representation used by the CGCubic routines.
BezierToSegment: PROCEDURE [bezier: Bezier] RETURNS [segment: Segment];
This routine converts a bezier spline segment from the bezier representation used by the CGCubic routines to our segment representation. Two vertices within epsilon of each other are considered identical, and only one of the two is inserted in the segment, thus permitting lines and quadratics. This routine always generates a segment with at least one vertex in it. Note that the fp field of the segment is not initialized properly since this is a pointer back into another segment.
SplitBezier: PROCEDURE [originalBezier: Bezier, t: REAL] RETURNS [bezier1, bezier2: Bezier];
SplitBezier splits a bezier spline segment into two segments at the specified point on the curve, recomputing the control points so that the two new segments form the original curve.
END.