ImagerPen.mesa
Copyright Ó 1985, 1987, 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Michael Plass, January 21, 1992 10:33 am PST
Doug Wyatt, May 19, 1985 4:12:33 pm PDT
DIRECTORY
Vector2 USING [VEC],
ImagerTransformation USING [Transformation];
ImagerPen: CEDAR DEFINITIONS
~ BEGIN
VEC: TYPE ~ Vector2.VEC;
Transformation: TYPE ~ ImagerTransformation.Transformation;
Pen: TYPE ~ REF PenRep;
Treat PenRep as immutable. For i IN [0..size),
-bounds.x <= s[i].x <= bounds.x
-bounds.y <= s[i].y <= bounds.y
PenRep: TYPE ~ RECORD [
bounds: VEC,
majorAxis, minorAxis: REAL, theta: Degrees,
s: SEQUENCE size: NAT OF VEC
];
Degrees: TYPE ~ REAL;
MakeTransformedCircle: PROC [strokeWidth: REAL, m: Transformation, thickening: VEC ¬ [0.0, 0.0]] RETURNS [Pen];
A convenience; the translation part of m is ignored. Thickening is in device space and can be negative (i.e. thinning is OK).
MakeEllipse: PROC [majorAxis, minorAxis: REAL, theta: Degrees] RETURNS [Pen];
The resulting Pen has each vertex on a half-integer, and is convex and symmetric around the origin. There are no duplicate or redundant vertices. The vertices are chosen to yield a consistent stoke width, using a method developed by John Hobby and Donald Knuth for Metafont 84.
Parameters majorAxis and minorAxis define the axes of the ellipse; and parameter theta is an angle by which the ellipse is rotated counterclockwise. If theta=0, the ellipse has the equation
$(x/a)^2+(y/b)^2=1$, where |a=major𡤊xis/2| and |b=minor𡤊xis/2|.
In general, the points of the ellipse are generated in the complex plane
by the formula $e^{i\theta}(a\cos t+ib\sin t)$, as $t$~ranges over all
angles. Notice that if |major𡤊xis=minor𡤊xis=d|, we obtain a circle
of diameter~|d|, regardless of the value of |theta|.
END.
Michael Plass, August 10, 1989 8:34:47 am PDT
Added thickening parameter to MakeTransformedCircle, following MB MakeThickenedTransformedCircle
Michael Plass, January 21, 1992 10:16:42 am PST
Added majorAxis, minorAxis, theta fields to PenRep, to allow pdl emission based on a pen.