ImagerStroke.mesa
Copyright Ó 1984, 1985, 1986, 1987, 1989, 1991 by Xerox Corporation. All rights reserved.
Michael Plass, August 17, 1991 0:27 am PDT
Doug Wyatt, February 24, 1986 4:13:34 pm PST
DIRECTORY
Imager USING [StrokeEnd, StrokeJoint],
ImagerBox USING [Box],
ImagerPath USING [ConicToProc, CurveToProc, LineToProc, MoveToProc, PathProc],
ImagerPen USING [Pen],
ImagerTransformation USING [Transformation],
Real USING [LargestNumber],
Vector2 USING [VEC];
VertexIndex: TYPE ~ NAT;
maxReal: REAL ~ Real.LargestNumber;
bigBox: ImagerBox.Box ~ [xmin: -maxReal, ymin: -maxReal, xmax: maxReal, ymax: maxReal];
EndCode:
TYPE ~
INT;
warningSquareEnd: EndCode ~ -1;
A special encoding to indicate that a signal ought to be raised when a square end is requested for a zero-length trajectory.
squareEnd: EndCode ~ ORD[Imager.StrokeEnd.square];
buttEnd: EndCode ~ ORD[Imager.StrokeEnd.butt];
roundEnd: EndCode ~ ORD[Imager.StrokeEnd.round];
JointCode:
TYPE ~
INT;
miterJoint: JointCode ~ ORD[Imager.StrokeJoint.miter];
bevelJoint: JointCode ~ ORD[Imager.StrokeJoint.bevel];
roundJoint: JointCode ~ ORD[Imager.StrokeJoint.round];
SignalSquareEndWithNoDirection:
PROC;
Raises the appropriate signal (currently Imager.Warning); provided so the error description is in only one place.
PathFromStroke:
PROC [path: ImagerPath.PathProc, closed:
BOOL,
pen: ImagerPen.Pen, end: EndCode, joint: JointCode,
m: ImagerTransformation.Transformation,
moveTo: ImagerPath.MoveToProc,
lineTo: ImagerPath.LineToProc,
conicTo: ImagerPath.ConicToProc,
box: ImagerBox.Box ¬ bigBox,
pathT: ImagerTransformation.Transformation ¬
NIL,
miterLimit:
REAL ¬ 0];
Produces the outline of a stroke in device, view or surface coordinates, given a path for the centerline in client coordinates. The box (in the coordinate system of the result) is used to avoid extra work on portions of the trajectory that fall outside of it, but the result is not clipped to the box. The conicTo is in fact only called with parabolic segments, i.e., r=0.5.
If pathT # NIL, then the path coordinates will be transformed by pathT, otherwise they will be transformed by m.
miterLimit controls when to bevel joints if joint is miter. If miterLimit is less than 1, then miterJoints always go through.
thickening compensates for marking process, and can have negative values (for thinning).
PathFromVector:
PROC [p0, p1:
VEC, pen: ImagerPen.Pen, end: EndCode,
m: ImagerTransformation.Transformation, moveTo: ImagerPath.MoveToProc, lineTo: ImagerPath.LineToProc];
Similar to PathFromStroke with path ~ { moveTo[p0]; lineTo[p1] };
PenStroke:
PROC [path: ImagerPath.PathProc, pen: ImagerPen.Pen, closed:
BOOL,
moveTo: ImagerPath.MoveToProc, lineTo: ImagerPath.LineToProc, conicTo: ImagerPath.ConicToProc,
end:
PROC [p:
VEC, v:
VEC, i0, i1: VertexIndex],
joint:
PROC [p:
VEC, v0, v1:
VEC, i0, i1: VertexIndex],
box: ImagerBox.Box,
cull:
BOOL ¬
FALSE
];
This is a more basic routine. Produces the polygonal outline of a stroke, given a path for the centerline. The input path is in a coordinate system with one unit per pixel. The output outlines winds counterclockwise in this coordinate system. The pen must be convex. If cull, segments are culled completely if their bounding box extended by the pen bounding box is ouside of box; otherwise the are kept; cull should be false if mitered joints or square ends are used.
MeasurePath:
PROC [path: ImagerPath.PathProc, closed:
BOOL ¬
FALSE]
RETURNS [
REAL];
Computes an approximation to the arc length of the path.
Dashes:
PROC [path: ImagerPath.PathProc,
patternLen:
NAT, pattern:
PROC [i:
NAT]
RETURNS [
REAL], offset, length:
REAL,
moveTo: ImagerPath.MoveToProc, lineTo: ImagerPath.LineToProc,
conicTo: ImagerPath.ConicToProc, curveTo: ImagerPath.CurveToProc,
closed:
BOOL ¬
FALSE
];
Produces dash segments, given a path and dash specification. If closed is TRUE, then Dashes will perform a lineto[firstPoint] at the end of each trajectory of the provided path.
FindVertex:
PROC [pen: ImagerPen.Pen, direction:
VEC, i:
NAT ¬ 0]
RETURNS [
NAT];
Finds the vertex of the pen that is farthest in the given direction; i provides the initial guess.
ConvolvePenWithPath:
PROC [path: ImagerPath.PathProc, pen: ImagerPen.Pen, moveTo: ImagerPath.MoveToProc, lineTo: ImagerPath.LineToProc];
Useful for enlarging an outline, provided it meets some fairly restrictive conditions. The path must be wrapped in a counterclockwise direction, and must consist only of line segments.
MapBitPath:
PROC [byte:
BYTE, p0, v1, v2:
VEC, moveTo: ImagerPath.MoveToProc, lineTo: ImagerPath.LineToProc];
Turns eight bits into a counterclockwise path; this is a utility for the code that renders bitmaps by using the show machinery.