IPImageImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Doug Wyatt, May 30, 1986 5:23:43 pm PDT
Michael Plass, January 3, 1986 12:57:26 pm PST
DIRECTORY
Imager,
ImagerBackdoor,
ImagerExtras,
ImagerColor USING [MakeSampledBlack, MakeSampledColor],
ImagerFont,
ImagerPath,
ImagerPixelArray USING [Extract],
ImagerTransformation USING [Concat, Create, DRound, Invert, Rotate, RoundXY, RoundXYVec, Scale, Scale2, Transform, Transformation, TransformVec, Translate],
IPImage USING [],
IPImager,
IPInterpreter,
IPMaster USING [ImagerVariable],
Vector2 USING [VEC];
IPImageImpl: CEDAR PROGRAM
IMPORTS Imager, ImagerBackdoor, ImagerColor, ImagerExtras, ImagerFont, ImagerPath, ImagerPixelArray, ImagerTransformation, IPImager, IPInterpreter
EXPORTS IPImage
~ BEGIN OPEN IPInterpreter;
VEC: TYPE ~ Vector2.VEC;
TransformationFromAny:
PROC [x: Any]
RETURNS [Transformation] ~ {
WITH x SELECT FROM x: Transformation => RETURN[x]; ENDCASE;
MasterError[$wrongType, "Wrong type (expected Transformation)"];
RETURN[NIL];
};
PixelArrayFromAny:
PROC [x: Any]
RETURNS [PixelArray] ~ {
WITH x SELECT FROM x: PixelArray => RETURN[x]; ENDCASE;
MasterError[$wrongType, "Wrong type (expected PixelArray)"];
RETURN[NIL];
};
ColorFromAny:
PROC [x: Any]
RETURNS [Color] ~ {
WITH x SELECT FROM x: Color => RETURN[x]; ENDCASE;
MasterError[$wrongType, "Wrong type (expected Color)"];
RETURN[NIL];
};
TrajectoryFromAny:
PROC [x: Any]
RETURNS [Trajectory] ~ {
WITH x SELECT FROM x: Trajectory => RETURN[x]; ENDCASE;
MasterError[$wrongType, "Wrong type (expected Trajectory)"];
RETURN[NIL];
};
OutlineFromAny:
PROC [x: Any]
RETURNS [Outline] ~ {
WITH x SELECT FROM x: Outline => RETURN[x]; ENDCASE;
MasterError[$wrongType, "Wrong type (expected Outline)"];
RETURN[NIL];
};
FontFromAny:
PROC [x: Any]
RETURNS [Font] ~ {
WITH x SELECT FROM x: Font => RETURN[x]; ENDCASE;
MasterError[$wrongType, "Wrong type (expected Font)"];
RETURN[NIL];
};
ClipperFromAny:
PROC [x: Any]
RETURNS [Clipper] ~ {
WITH x SELECT FROM x: Clipper => RETURN[x]; ENDCASE;
MasterError[$wrongType, "Wrong type (expected Clipper)"];
RETURN[NIL];
};
PushVec:
PROC [self: Ref, v:
VEC] ~ {
PushReal[self, v.x]; PushReal[self, v.y];
};
PushTransformation:
PROC [self: Ref, x: Transformation] ~ {
IF x=NIL THEN MasterError[$nilFault, "Transformation value is NIL"];
PushAny[self, x];
};
PushPixelArray:
PROC [self: Ref, x: PixelArray] ~ {
IF x=NIL THEN MasterError[$nilFault, "PixelArray value is NIL"];
PushAny[self, x];
};
PushColor:
PROC [self: Ref, x: Color] ~ {
IF x=NIL THEN MasterError[$nilFault, "Color value is NIL"];
PushAny[self, x];
};
PushTrajectory:
PROC [self: Ref, x: Trajectory] ~ {
IF x=NIL THEN MasterError[$nilFault, "Trajectory value is NIL"];
PushAny[self, x];
};
PushOutline:
PROC [self: Ref, x: Outline] ~ {
IF x=NIL THEN MasterError[$nilFault, "Outline value is NIL"];
PushAny[self, x];
};
PushFont:
PROC [self: Ref, x: Font] ~ {
IF x=NIL THEN MasterError[$nilFault, "Font value is NIL"];
PushAny[self, x];
};
PushClipper:
PROC [self: Ref, x: Clipper] ~ {
IF x=NIL THEN MasterError[$nilFault, "Clipper value is NIL"];
PushAny[self, x];
};
PopVec:
PROC [self: Ref]
RETURNS [v:
VEC] ~ {
v.y ← PopReal[self]; v.x ← PopReal[self];
};
PopTransformation:
PROC [self: Ref]
RETURNS [Transformation] ~ {
x: Any ~ PopAny[self];
WITH x SELECT FROM x: Transformation => RETURN[x]; ENDCASE;
RETURN[TransformationFromAny[x]];
};
PopPixelArray:
PROC [self: Ref]
RETURNS [PixelArray] ~ {
x: Any ~ PopAny[self];
WITH x SELECT FROM x: PixelArray => RETURN[x]; ENDCASE;
RETURN[PixelArrayFromAny[x]];
};
PopColor:
PROC [self: Ref]
RETURNS [Color] ~ {
x: Any ~ PopAny[self];
WITH x SELECT FROM x: Color => RETURN[x]; ENDCASE;
RETURN[ColorFromAny[x]];
};
PopTrajectory:
PROC [self: Ref]
RETURNS [Trajectory] ~ {
x: Any ~ PopAny[self];
WITH x SELECT FROM x: Trajectory => RETURN[x]; ENDCASE;
RETURN[TrajectoryFromAny[x]];
};
PopOutline:
PROC [self: Ref]
RETURNS [Outline] ~ {
x: Any ~ PopAny[self];
WITH x SELECT FROM x: Outline => RETURN[x]; ENDCASE;
RETURN[OutlineFromAny[x]];
};
PopFont:
PROC [self: Ref]
RETURNS [Font] ~ {
x: Any ~ PopAny[self];
WITH x SELECT FROM x: Font => RETURN[x]; ENDCASE;
RETURN[FontFromAny[x]];
};
PopClipper:
PROC [self: Ref]
RETURNS [Clipper] ~ {
x: Any ~ PopAny[self];
WITH x SELECT FROM x: Clipper => RETURN[x]; ENDCASE;
RETURN[ClipperFromAny[x]];
};
SetMedium:
PROC [self: Ref,
m: Vector, pageNumber: Cardinal, duplex:
BOOL, xImageShift:
REAL] ~ {
self.mediumSize ← xxx;
self.fieldMin ← xxx;
self.fieldMax ← xxx;
IF duplex
AND Even[pageNumber]
THEN Imager.TranslateT[self.imager, [-xImageShift, 0]]
ELSE Imager.TranslateT[self.imager, [xImageShift, 0]];
};
ImagerVariable: TYPE ~ IPMaster.ImagerVariable;
ImagerVariableVal:
TYPE ~ [0..
ORD[ImagerVariable.
LAST]];
ImagerVariableFromCardinal:
PROC [i: Cardinal]
RETURNS [ImagerVariable] ~ {
IF i NOT IN ImagerVariableVal THEN MasterError[$boundsFault,
"Imager variable index out of bounds."];
RETURN[VAL[ImagerVariableVal[i]]];
};
ApplyIGET:
PUBLIC
PROC [self: Ref] ~ {
i: Cardinal ~ PopCardinal[self];
SELECT ImagerVariableFromCardinal[i]
FROM
$DCScpx => PushReal[self, ImagerBackdoor.GetReal[self.imager, $DCScpx]];
$DCScpy => PushReal[self, ImagerBackdoor.GetReal[self.imager, $DCScpy]];
$correctMX => PushReal[self, ImagerBackdoor.GetReal[self.imager, $correctMX]];
$correctMY => PushReal[self, ImagerBackdoor.GetReal[self.imager, $correctMY]];
$T => PushTransformation[self, ImagerBackdoor.GetT[self.imager]];
$priorityImportant => PushCardinal[self, ImagerBackdoor.GetInt[self.imager, $priorityImportant]];
$mediumXSize => PushReal[self, ImagerBackdoor.GetReal[self.imager, $mediumXSize]];
$mediumYSize => PushReal[self, ImagerBackdoor.GetReal[self.imager, $mediumYSize]];
$fieldXMin => PushReal[self, ImagerBackdoor.GetReal[self.imager, $fieldXMin]];
$fieldYMin => PushReal[self, ImagerBackdoor.GetReal[self.imager, $fieldYMin]];
$fieldXMax => PushReal[self, ImagerBackdoor.GetReal[self.imager, $fieldXMax]];
$fieldYMax => PushReal[self, ImagerBackdoor.GetReal[self.imager, $fieldYMax]];
$font => PushFont[self, ImagerBackdoor.GetFont[self.imager]];
$color => PushColor[self, ImagerBackdoor.GetColor[self.imager]];
$noImage => PushCardinal[self, ImagerBackdoor.GetInt[self.imager, $noImage]];
$strokeWidth => PushReal[self, ImagerBackdoor.GetReal[self.imager, $strokeWidth]];
$strokeEnd => PushCardinal[self, ImagerBackdoor.GetInt[self.imager, $strokeEnd]];
$strokeJoint => PushCardinal[self, ImagerBackdoor.GetInt[self.imager, $strokeJoint]];
$underlineStart => PushReal[self, ImagerBackdoor.GetReal[self.imager, $underlineStart]];
$amplifySpace => PushReal[self, ImagerBackdoor.GetReal[self.imager, $amplifySpace]];
$correctPass => PushCardinal[self, ImagerBackdoor.GetInt[self.imager, $correctPass]];
$correctShrink => PushReal[self, ImagerBackdoor.GetReal[self.imager, $correctShrink]];
$correctTX => PushReal[self, ImagerBackdoor.GetReal[self.imager, $correctTX]];
$correctTY => PushReal[self, ImagerBackdoor.GetReal[self.imager, $correctTY]];
$clipper => PushClipper[self, ImagerBackdoor.GetClipper[self.imager]];
ENDCASE => ERROR;
};
ApplyISET:
PUBLIC
PROC [self: Ref] ~ {
i: Cardinal ~ PopCardinal[self];
SELECT ImagerVariableFromCardinal[i]
FROM
$DCScpx => ImagerBackdoor.SetReal[self.imager, $DCScpx, PopReal[self]];
$DCScpy => ImagerBackdoor.SetReal[self.imager, $DCScpy, PopReal[self]];
$correctMX => ImagerBackdoor.SetReal[self.imager, $correctMX, PopReal[self]];
$correctMY => ImagerBackdoor.SetReal[self.imager, $correctMY, PopReal[self]];
$T => ImagerBackdoor.SetT[self.imager, PopTransformation[self]];
$priorityImportant => ImagerBackdoor.SetInt[self.imager, $priorityImportant, PopCardinal[self]];
$mediumXSize => ImagerBackdoor.SetReal[self.imager, $mediumXSize, PopReal[self]];
$mediumYSize => ImagerBackdoor.SetReal[self.imager, $mediumYSize, PopReal[self]];
$fieldXMin => ImagerBackdoor.SetReal[self.imager, $fieldXMin, PopReal[self]];
$fieldYMin => ImagerBackdoor.SetReal[self.imager, $fieldYMin, PopReal[self]];
$fieldXMax => ImagerBackdoor.SetReal[self.imager, $fieldXMax, PopReal[self]];
$fieldYMax => ImagerBackdoor.SetReal[self.imager, $fieldYMax, PopReal[self]];
$font => Imager.SetFont[self.imager, PopFont[self]];
$color => Imager.SetColor[self.imager, PopColor[self]];
$noImage => ImagerBackdoor.SetInt[self.imager, $noImage, PopCardinal[self]];
$strokeWidth => ImagerBackdoor.SetReal[self.imager, $strokeWidth, PopReal[self]];
$strokeEnd => ImagerBackdoor.SetInt[self.imager, $strokeEnd, PopCardinal[self]];
$strokeJoint => ImagerBackdoor.SetInt[self.imager, $strokeJoint, PopCardinal[self]];
$underlineStart => ImagerBackdoor.SetReal[self.imager, $underlineStart, PopReal[self]];
$amplifySpace => ImagerBackdoor.SetReal[self.imager, $amplifySpace, PopReal[self]];
$correctPass => ImagerBackdoor.SetInt[self.imager, $correctPass, PopCardinal[self]];
$correctShrink => ImagerBackdoor.SetReal[self.imager, $correctShrink, PopReal[self]];
$correctTX => ImagerBackdoor.SetReal[self.imager, $correctTX, PopReal[self]];
$correctTY => ImagerBackdoor.SetReal[self.imager, $correctTY, PopReal[self]];
$clipper => ImagerBackdoor.SetClipper[self.imager, PopClipper[self]];
ENDCASE => ERROR;
};
ApplyDROUND:
PUBLIC
PROC [self: Ref] ~ {
p: VEC ~ PopVec[self];
PushVec[self, ImagerTransformation.DRound[p]];
};
ApplyMAKET:
PUBLIC
PROC [self: Ref] ~ {
f: REAL ~ PopReal[self]; e: REAL ~ PopReal[self]; d: REAL ~ PopReal[self];
c: REAL ~ PopReal[self]; b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self];
PushTransformation[self, ImagerTransformation.Create[a, b, c, d, e, f]];
};
ApplyOPENT:
PUBLIC
PROC [self: Ref] ~ {
m: Transformation ~ PopTransformation[self];
PushReal[self, m.a]; PushReal[self, m.b]; PushReal[self, m.c];
PushReal[self, m.d]; PushReal[self, m.e]; PushReal[self, m.f];
};
ApplyTRANSLATE:
PUBLIC
PROC [self: Ref] ~ {
t: VEC ~ PopVec[self];
PushTransformation[self, ImagerTransformation.Translate[t]];
};
ApplyROTATE:
PUBLIC
PROC [self: Ref] ~ {
a: REAL ~ PopReal[self];
PushTransformation[self, ImagerTransformation.Rotate[a]];
};
ApplySCALE:
PUBLIC
PROC [self: Ref] ~ {
s: REAL ~ PopReal[self];
PushTransformation[self, ImagerTransformation.Scale[s]];
};
ApplySCALE2:
PUBLIC
PROC [self: Ref] ~ {
s: VEC ~ PopVec[self];
PushTransformation[self, ImagerTransformation.Scale2[s]];
};
ApplyCONCAT:
PUBLIC
PROC [self: Ref] ~ {
n: Transformation ~ PopTransformation[self];
m: Transformation ~ PopTransformation[self];
PushTransformation[self, ImagerTransformation.Concat[m, n]];
};
ApplyINVERT:
PUBLIC
PROC [self: Ref] ~ {
m: Transformation ~ PopTransformation[self];
PushTransformation[self, ImagerTransformation.Invert[m]];
};
ApplyTRANSFORM:
PUBLIC
PROC [self: Ref] ~ {
m: Transformation ~ PopTransformation[self];
p: VEC ~ PopVec[self];
PushVec[self, m.Transform[p]];
};
ApplyTRANSFORMVEC:
PUBLIC
PROC [self: Ref] ~ {
m: Transformation ~ PopTransformation[self];
v: VEC ~ PopVec[self];
PushVec[self, m.TransformVec[v]];
};
ApplyROUNDXY:
PUBLIC
PROC [self: Ref] ~ {
m: Transformation ~ PopTransformation[self];
p: VEC ~ PopVec[self];
PushVec[self, m.RoundXY[p]];
};
ApplyROUNDXYVEC:
PUBLIC
PROC [self: Ref] ~ {
m: Transformation ~ PopTransformation[self];
v: VEC ~ PopVec[self];
PushVec[self, m.RoundXYVec[v]];
};
ApplyCONCATT:
PUBLIC
PROC [self: Ref] ~ {
m: Transformation ~ PopTransformation[self];
Imager.ConcatT[self.imager, m];
};
ApplyMOVE:
PUBLIC
PROC [self: Ref] ~ {
Imager.Move[self.imager];
};
ApplyTRANS:
PUBLIC
PROC [self: Ref] ~ {
Imager.Trans[self.imager];
};
ApplySHOW:
PUBLIC
PROC [self: Ref] ~ {
v: Vector ~ PopVector[self];
string: XStringProc ~ { StringFromVector[v, charAction] };
Imager.Show[context: self.imager, string: string];
};
ApplySHOWANDXREL:
PUBLIC
PROC [self: Ref] ~ {
v: Vector ~ PopVector[self];
string: XStringProc ~ { StringFromVector[v, charAction] };
Imager.Show[context: self.imager, string: string, xrel: TRUE];
};
ApplySHOWANDFIXEDXREL:
PUBLIC
PROC [self: Ref] ~ {
x: REAL ~ PopReal[self];
v: Vector ~ PopVector[self];
string: XStringProc ~ { StringFromVector[v, charAction] };
ImagerExtras.ShowAndFixedXRel[context: self.imager, string: string, x: x];
};
ApplySETXY:
PUBLIC
PROC [self: Ref] ~ {
Imager.SetXY[self.imager, PopVec[self]];
};
ApplySETXYREL:
PUBLIC
PROC [self: Ref] ~ {
Imager.SetXYRel[self.imager, PopVec[self]];
};
ApplySETXREL:
PUBLIC
PROC [self: Ref] ~ {
Imager.SetXRel[self.imager, PopReal[self]];
};
ApplySETYREL:
PUBLIC
PROC [self: Ref] ~ {
Imager.SetYRel[self.imager, PopReal[self]];
};
ApplyGETCP:
PUBLIC
PROC [self: Ref] ~ {
PushVec[self, ImagerBackdoor.GetCP[context: self.imager]];
};
ApplyGETCPROUNDED:
PUBLIC
PROC [self: Ref] ~ {
PushVec[self, ImagerBackdoor.GetCP[context: self.imager, rounded: TRUE]];
};
ApplyMAKEPIXELARRAY:
PUBLIC
PROC [self: Ref] ~ {
samples: Vector ~ PopVector[self];
m: Transformation ~ PopTransformation[self];
samplesInterleaved: BOOL ~ PopBool[self];
maxSampleValue: Vector ← IF TopType[self]=vector THEN PopVector[self] ELSE NIL;
maxSampleValueI: Cardinal ~ IF maxSampleValue=NIL THEN PopCardinal[self] ELSE 0;
samplesPerPixel: Cardinal ~ PopCardinal[self];
yPixels: Cardinal ~ PopCardinal[self];
xPixels: Cardinal ~ PopCardinal[self];
PushPixelArray[self, IPImager.MakePixelArray[
xPixels: xPixels, yPixels: yPixels, samplesPerPixel: samplesPerPixel,
maxSampleValue: maxSampleValue, maxSampleValueI: maxSampleValueI,
samplesInterleaved: samplesInterleaved, m: m, samples: samples]];
};
ApplyEXTRACTPIXELARRAY:
PUBLIC
PROC [self: Ref] ~ {
select: Vector ~ PopVector[self];
selectShape: VectorShape ~ Shape[select];
pa: PixelArray ~ PopPixelArray[self];
Select: PROC [i: NAT] RETURNS [NAT] ~ {RETURN [GetCardinal[select, i]]};
IF selectShape.lowerBound#0 THEN MasterError[$misshapedVector, "EXTRACTPIXELARRAY select Vector should be origin zero."];
PushPixelArray[self, ImagerPixelArray.Extract[old: pa, samplesPerPixel: selectShape.size, select: Select]];
};
ApplyJOINPIXELARRAYS:
PUBLIC
PROC [self: Ref] ~ {
MasterError[$unimplemented, "JOINPIXELARRAYS is not implemented."];
};
ApplyFINDDECOMPRESSOR:
PUBLIC
PROC [self: Ref] ~ {
v: Vector ~ PopVector[self];
PushOperator[self, FindDecompressor[self, v]];
MasterError[$unimplemented, "FINDDECOMPRESSOR is not implemented."];
};
ApplyFINDCOLOR:
PUBLIC
PROC [self: Ref] ~ {
v: Vector ~ PopVector[self];
PushColor[self, IPImager.FindColor[self, v]];
};
ApplyFINDCOLOROPERATOR:
PUBLIC
PROC [self: Ref] ~ {
v: Vector ~ PopVector[self];
PushOperator[self, IPImager.FindColorOperator[self, v]];
};
ApplyFINDCOLORMODELOPERATOR:
PUBLIC
PROC [self: Ref] ~ {
v: Vector ~ PopVector[self];
PushOperator[self, IPImager.FindColorModelOperator[self, v]];
};
ApplyMAKEGRAY:
PUBLIC
PROC [self: Ref] ~ {
f: REAL ~ PopReal[self];
PushColor[self, Imager.MakeGray[f]];
};
ApplyMAKESAMPLEDCOLOR:
PUBLIC
PROC [self: Ref] ~ {
colorOperator: Operator ~ PopOperator[self];
um: Transformation ~ PopTransformation[self];
pa: PixelArray ~ PopPixelArray[self];
PushColor[self, ImagerColor.MakeSampledColor[pa, um, IPImager.ColorOperatorFromOperator[colorOperator]]];
};
ApplyMAKESAMPLEDBLACK:
PUBLIC
PROC [self: Ref] ~ {
clear: BOOL ~ PopBool[self];
um: Transformation ~ PopTransformation[self];
pa: PixelArray ~ PopPixelArray[self];
PushColor[self, ImagerColor.MakeSampledBlack[pa, um, clear]];
};
ApplySETGRAY:
PUBLIC
PROC [self: Ref] ~ {
f: REAL ~ PopReal[self];
Imager.SetGray[self.imager, f];
};
ApplySETSAMPLEDCOLOR:
PUBLIC
PROC [self: Ref] ~ {
colorOperator: Operator ~ PopOperator[self];
m: Transformation ~ PopTransformation[self];
pa: PixelArray ~ PopPixelArray[self];
Imager.SetSampledColor[self.imager, pa, m, IPImager.ColorOperatorFromOperator[colorOperator]];
};
ApplySETSAMPLEDBLACK:
PUBLIC
PROC [self: Ref] ~ {
clear: BOOL ~ PopBool[self];
m: Transformation ~ PopTransformation[self];
pa: PixelArray ~ PopPixelArray[self];
Imager.SetSampledBlack[self.imager, pa, m, clear];
};
ApplyMOVETO:
PUBLIC
PROC [self: Ref] ~ {
p: VEC ~ PopVec[self];
PushTrajectory[self, ImagerPath.MoveTo[p]];
};
ApplyLINETO:
PUBLIC
PROC [self: Ref] ~ {
p: VEC ~ PopVec[self];
t: Trajectory ~ PopTrajectory[self];
PushTrajectory[self, ImagerPath.LineTo[t, p]];
};
ApplyLINETOX:
PUBLIC
PROC [self: Ref] ~ {
x: REAL ~ PopReal[self];
t: Trajectory ~ PopTrajectory[self];
PushTrajectory[self, ImagerPath.LineToX[t, x]];
};
ApplyLINETOY:
PUBLIC
PROC [self: Ref] ~ {
y: REAL ~ PopReal[self];
t: Trajectory ~ PopTrajectory[self];
PushTrajectory[self, ImagerPath.LineToY[t, y]];
};
ApplyCURVETO:
PUBLIC
PROC [self: Ref] ~ {
p3: VEC ~ PopVec[self];
p2: VEC ~ PopVec[self];
p1: VEC ~ PopVec[self];
t: Trajectory ~ PopTrajectory[self];
PushTrajectory[self, ImagerPath.CurveTo[t, p1, p2, p3]];
};
ApplyCONICTO:
PUBLIC
PROC [self: Ref] ~ {
r: REAL ~ PopReal[self];
p2: VEC ~ PopVec[self];
p1: VEC ~ PopVec[self];
t: Trajectory ~ PopTrajectory[self];
PushTrajectory[self, ImagerPath.ConicTo[t, p1, p2, r]];
};
ApplyARCTO:
PUBLIC
PROC [self: Ref] ~ {
p2: VEC ~ PopVec[self];
p1: VEC ~ PopVec[self];
t: Trajectory ~ PopTrajectory[self];
PushTrajectory[self, ImagerPath.ArcTo[t, p1, p2]];
};
MakeOutline:
PROC [self: Ref, oddWrap:
BOOL] ~ {
n: Cardinal ~ PopCardinal[self];
outline: Outline ~ NEW[OutlineRep[n] ← [oddWrap: oddWrap, seq: ]];
FOR i: NAT DECREASING IN[0..outline.size) DO outline[i] ← PopTrajectory[self] ENDLOOP;
PushOutline[self, outline];
};
ApplyMAKEOUTLINE: PUBLIC PROC [self: Ref] ~ { MakeOutline[self, FALSE] };
ApplyMAKEOUTLINEODD: PUBLIC PROC [self: Ref] ~ { MakeOutline[self, TRUE] };
ApplyMASKFILL:
PUBLIC
PROC [self: Ref] ~ {
o: Outline ~ PopOutline[self];
path: ImagerPath.PathProc ~ {
FOR i:
NAT
IN[0..o.size)
DO
ImagerPath.MapTrajectory[o[i], moveTo, lineTo, curveTo, conicTo, arcTo];
ENDLOOP;
};
Imager.MaskFill[context: self.imager, path: path, parity: o.oddWrap];
};
ApplyMASKFILLPARITY:
PUBLIC
PROC [self: Ref] ~ {
o: Outline ~ PopOutline[self];
path: ImagerPath.PathProc ~ {
FOR i:
NAT
IN[0..o.size)
DO
ImagerPath.MapTrajectory[o[i], moveTo, lineTo, curveTo, conicTo, arcTo];
ENDLOOP;
};
Imager.MaskFill[context: self.imager, path: path, parity: TRUE];
};
ApplyMASKSTROKE:
PUBLIC
PROC [self: Ref] ~ {
t: Trajectory ~ PopTrajectory[self];
Imager.MaskStrokeTrajectory[context: self.imager, trajectory: t];
};
ApplyMASKSTROKECLOSED:
PUBLIC
PROC [self: Ref] ~ {
t: Trajectory ~ PopTrajectory[self];
Imager.MaskStrokeTrajectory[context: self.imager, trajectory: t, closed: TRUE];
};
ApplyMASKRECTANGLE:
PUBLIC
PROC [self: Ref] ~ {
h: REAL ~ PopReal[self]; w: REAL ~ PopReal[self];
y: REAL ~ PopReal[self]; x: REAL ~ PopReal[self];
Imager.MaskRectangle[self.imager, [x: x, y: y, w: w, h: h]];
};
ApplyMASKVECTOR:
PUBLIC
PROC [self: Ref] ~ {
p2: VEC ~ PopVec[self];
p1: VEC ~ PopVec[self];
Imager.MaskVector[self.imager, p1, p2];
};
ApplySTARTUNDERLINE:
PUBLIC
PROC [self: Ref] ~ {
Imager.StartUnderline[self.imager];
};
ApplyMASKUNDERLINE:
PUBLIC
PROC [self: Ref] ~ {
h: REAL ~ PopReal[self]; dy: REAL ~ PopReal[self];
Imager.MaskUnderline[self.imager, dy, h];
};
ApplyMASKTRAPEZOIDX:
PUBLIC
PROC [self: Ref] ~ {
x4: REAL ~ PopReal[self]; y3: REAL ~ PopReal[self]; x3: REAL ~ PopReal[self];
x2: REAL ~ PopReal[self]; y1: REAL ~ PopReal[self]; x1: REAL ~ PopReal[self];
path: ImagerPath.PathProc ~ {
moveTo[[x1, y1]]; lineTo[[x2, y1]]; lineTo[[x3, y3]]; lineTo[[x4, y3]];
};
Imager.MaskFill[self.imager, path];
};
ApplyMASKTRAPEZOIDY:
PUBLIC
PROC [self: Ref] ~ {
y4: REAL ~ PopReal[self]; y3: REAL ~ PopReal[self]; x3: REAL ~ PopReal[self];
y2: REAL ~ PopReal[self]; y1: REAL ~ PopReal[self]; x1: REAL ~ PopReal[self];
path: ImagerPath.PathProc ~ {
moveTo[[x1, y1]]; lineTo[[x1, y2]]; lineTo[[x3, y3]]; lineTo[[x3, y4]];
};
Imager.MaskFill[self.imager, path];
};
ApplyMASKDASHEDSTROKE:
PUBLIC
PROC [self: Ref] ~ {
length: REAL ~ PopReal[self];
offset: REAL ~ PopReal[self];
pattern: Vector ~ PopVector[self];
pShape: VectorShape ~ Shape[pattern];
pGet: PROC [i: NAT] RETURNS [REAL] ~ { RETURN[GetReal[pattern, pShape.lowerBound+i]] };
t: Trajectory ~ PopTrajectory[self];
ImagerExtras.MaskDashedStrokeTrajectory[self.imager, t, pShape.size, pGet, offset, length];
};
ApplyMASKPIXEL:
PUBLIC
PROC [self: Ref] ~ {
pa: PixelArray ~ PopPixelArray[self];
Imager.MaskPixel[self.imager, pa];
};
ApplyCLIPOUTLINE:
PUBLIC
PROC [self: Ref] ~ {
o: Outline ~ PopOutline[self];
path: ImagerPath.PathProc ~ {
FOR i:
NAT
IN[0..o.size)
DO
ImagerPath.MapTrajectory[o[i], moveTo, lineTo, curveTo, conicTo, arcTo];
ENDLOOP;
};
Imager.Clip[context: self.imager, path: path, parity: o.oddWrap];
};
ApplyCLIPRECTANGLE:
PUBLIC
PROC [self: Ref] ~ {
h: REAL ~ PopReal[self]; w: REAL ~ PopReal[self];
y: REAL ~ PopReal[self]; x: REAL ~ PopReal[self];
Imager.ClipRectangle[context: self.imager, r: [x: x, y: y, w: w, h: h]];
};
ApplyMASKCHAR:
PUBLIC
PROC [self: Ref] ~ {
i: Cardinal ~ PopCardinal[self];
fd: Vector ~ PopVector[self];
IPImager.MaskChar[self, fd, i];
PushVector[self, fd];
};
ApplyMAKEFONT:
PUBLIC
PROC [self: Ref] ~ {
v: Vector ~ PopVector[self];
PushFont[self, IPImager.MakeFont[self, v]];
};
ApplyFINDFONT:
PUBLIC
PROC [self: Ref] ~ {
v: Vector ~ PopVector[self];
PushFont[self, IPImager.FindFont[self, v]];
};
ApplyMODIFYFONT:
PUBLIC
PROC [self: Ref] ~ {
m: Transformation ~ PopTransformation[self];
font: Font ~ PopFont[self];
PushFont[self, ImagerFont.Modify[font, m]];
};
ApplySETFONT:
PUBLIC
PROC [self: Ref] ~ {
n: Cardinal ~ PopCardinal[self];
font: Font ~ FontFromAny[FGet[self, n]];
Imager.SetFont[self.imager, font];
};
ApplyCORRECTMASK:
PUBLIC
PROC [self: Ref] ~ {
Imager.CorrectMask[self.imager];
};
ApplyCORRECTSPACE:
PUBLIC
PROC [self: Ref] ~ {
Imager.CorrectSpace[self.imager, PopVec[self]];
};
ApplyCORRECT:
PUBLIC
PROC [self: Ref] ~ {
frame: Vector ~ Frame[self];
env: Vector ~ Env[self];
index: INT ~ self.index;
action:
PROC ~ {
inner: PROC ~ { CallInlineBody[self: self, frame: frame, env: env] };
self.index ← index;
DoWithMarkProtection[self, inner]};
Imager.Correct[self.imager, action];
};
ApplySETCORRECTMEASURE:
PUBLIC
PROC [self: Ref] ~ {
Imager.SetCorrectMeasure[self.imager, PopVec[self]];
};
ApplySETCORRECTTOLERANCE:
PUBLIC
PROC [self: Ref] ~ {
Imager.SetCorrectTolerance[self.imager, PopVec[self]];
};
ApplySPACE:
PUBLIC
PROC [self: Ref] ~ {
Imager.Space[self.imager, PopReal[self]];
};
ApplyAMPLIFIEDSPACE:
PUBLIC
PROC [self: Ref] ~ {
x: REAL ~ PopReal[self];
amplifySpace: REAL ~ ImagerBackdoor.GetReal[self.imager, $amplifySpace];
Imager.Space[self.imager, x*amplifySpace];
};
END.