IPImagePrimitivesImpl.mesa
Last edited by:
Doug Wyatt, April 29, 1983 1:58 pm
DIRECTORY
IPBasic USING [Any, Integer, Operator, State, Vector],
IPErrors USING [MasterError],
IPGeometry USING [CurveTo, LineTo, LineToX, LineToY, MakeOutline, MoveTo],
IPImagerBasic USING [Color, Outline, Pair, PixelArray, Trajectory, Transformation],
IPImagerOps -- USING everything --,
IPImagePrimitives USING [],
IPStack USING [PopAny, PopBool, PopInteger, PopOperator, PopReal, PopVector, PushAny, PushOperator, PushReal, PushVector],
IPTransform USING [Concat, DRound, Invert, MakeT, Rotate, RoundXY, RoundXYVec, Scale, Scale2, Transform, TransformVec, Translate];
IPImagePrimitivesImpl: CEDAR PROGRAM
IMPORTS IPErrors, IPGeometry, IPImagerOps, IPStack, IPTransform
EXPORTS IPImagePrimitives
= BEGIN OPEN IPImagerOps, IPStack, IPImagerBasic, IPBasic;
4.2 Imager state
ApplyIGET: PUBLIC PROC[self: State] = {
n: Integer = PopInteger[self];
x: Any = IGet[self, n];
PushAny[self, x];
};
ApplyISET: PUBLIC PROC[self: State] = {
n: Integer = PopInteger[self];
x: Any = PopAny[self];
ISet[self, x, n];
};
4.3 Coordinate systems
ApplyDROUND: PUBLIC PROC[self: State] = {
p: Pair = PopPair[self];
r: Pair = IPTransform.DRound[p];
PushPair[self, r];
};
4.4 Transformations
ApplyMAKET: PUBLIC PROC[self: State] = {
f: REAL = PopReal[self]; e: REAL = PopReal[self];
d: REAL = PopReal[self]; c: REAL = PopReal[self];
b: REAL = PopReal[self]; a: REAL = PopReal[self];
m: Transformation = IPTransform.MakeT[a, b, c, d, e, f];
PushTransformation[self, m];
};
ApplyOPENT: PUBLIC PROC[self: State] = {
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: State] = {
y: REAL = PopReal[self]; x: REAL = PopReal[self];
m: Transformation = IPTransform.Translate[x, y];
PushTransformation[self, m];
};
ApplyROTATE: PUBLIC PROC[self: State] = {
a: REAL = PopReal[self];
m: Transformation = IPTransform.Rotate[a];
PushTransformation[self, m];
};
ApplySCALE: PUBLIC PROC[self: State] = {
s: REAL = PopReal[self];
m: Transformation = IPTransform.Scale[s];
PushTransformation[self, m];
};
ApplySCALE2: PUBLIC PROC[self: State] = {
sy: REAL = PopReal[self]; sx: REAL = PopReal[self];
m: Transformation = IPTransform.Scale2[sx, sy];
PushTransformation[self, m];
};
ApplyCONCAT: PUBLIC PROC[self: State] = {
n: Transformation = PopTransformation[self];
m: Transformation = PopTransformation[self];
p: Transformation = IPTransform.Concat[m, n];
PushTransformation[self, p];
};
ApplyINVERT: PUBLIC PROC[self: State] = {
m: Transformation = PopTransformation[self];
n: Transformation = IPTransform.Invert[m];
PushTransformation[self, n];
};
ApplyTRANSFORM: PUBLIC PROC[self: State] = {
m: Transformation = PopTransformation[self];
p: Pair = PopPair[self];
q: Pair = IPTransform.Transform[m, p];
PushPair[self, q];
};
ApplyTRANSFORMVEC: PUBLIC PROC[self: State] = {
m: Transformation = PopTransformation[self];
v: Pair = PopPair[self];
w: Pair = IPTransform.TransformVec[m, v];
PushPair[self, w];
};
ApplyROUNDXY: PUBLIC PROC[self: State] = {
m: Transformation = PopTransformation[self];
p: Pair = PopPair[self];
q: Pair = IPTransform.RoundXY[m, p];
PushPair[self, q];
};
ApplyROUNDXYVEC: PUBLIC PROC[self: State] = {
m: Transformation = PopTransformation[self];
v: Pair = PopPair[self];
w: Pair = IPTransform.RoundXYVec[m, v];
PushPair[self, w];
};
ApplyCONCATT: PUBLIC PROC[self: State] = {
m: Transformation = PopTransformation[self];
ConcatT[self, m];
};
ApplyMOVE: PUBLIC PROC[self: State] = {
Move[self];
};
ApplyTRANS: PUBLIC PROC[self: State] = {
Trans[self];
};
ApplySHOW: PUBLIC PROC[self: State] = {
v: Vector = PopVector[self];
Show[self, v];
};
ApplySHOWANDXREL: PUBLIC PROC[self: State] = {
v: Vector = PopVector[self];
ShowAndXRel[self, v];
};
4.5 Current position operators
ApplySETXY: PUBLIC PROC[self: State] = {
p: Pair = PopPair[self];
SetXY[self, p];
};
ApplySETXYREL: PUBLIC PROC[self: State] = {
v: Pair = PopPair[self];
SetXYRel[self, v];
};
ApplySETXREL: PUBLIC PROC[self: State] = {
x: REAL = PopReal[self];
SetXYRel[self, [x, 0]];
};
ApplySETYREL: PUBLIC PROC[self: State] = {
y: REAL = PopReal[self];
SetXYRel[self, [0, y]];
};
ApplyGETCP: PUBLIC PROC[self: State] = {
p: Pair = GetCP[self];
PushPair[self, p];
};
ApplyGETCPROUNDED: PUBLIC PROC[self: State] = {
p: Pair = GetCP[self, TRUE];
PushPair[self, p];
};
4.6 Pixel arrays
ApplyMAKEPIXELARRAY: PUBLIC PROC[self: State] = {
samples: Vector = PopVector[self];
m: Transformation = PopTransformation[self];
samplesInterleaved: BOOL = PopBool[self];
maxSampleValue: Integer = PopInteger[self];
samplesPerPixel: Integer = PopInteger[self];
yPixels: Integer = PopInteger[self];
xPixels: Integer = PopInteger[self];
pa: PixelArray = MakePixelArray[xPixels: xPixels, yPixels: yPixels,
samplesPerPixel: samplesPerPixel, maxSampleValue: maxSampleValue,
samplesInterleaved: samplesInterleaved, m: m, samples: samples];
PushPixelArray[self, pa];
};
ApplyFINDDECOMPRESSOR: PUBLIC PROC[self: State] = {
v: Vector = PopVector[self];
op: Operator = FindDecompressor[self, v];
PushOperator[self, op];
};
4.7 Color
ApplyFINDCOLOR: PUBLIC PROC[self: State] = {
v: Vector = PopVector[self];
col: Color = FindColor[self, v];
PushColor[self, col];
};
ApplyFINDCOLOROPERATOR: PUBLIC PROC[self: State] = {
v: Vector = PopVector[self];
op: Operator = FindColorOperator[self, v];
PushOperator[self, op];
};
ApplyFINDCOLORMODELOPERATOR: PUBLIC PROC[self: State] = {
v: Vector = PopVector[self];
op: Operator = FindColorModelOperator[self, v];
PushOperator[self, op];
};
ApplyMAKEGRAY: PUBLIC PROC[self: State] = {
f: REAL = PopReal[self];
col: Color = MakeGray[f];
PushColor[self, col];
};
ApplySETGRAY: PUBLIC PROC[self: State] = {
f: REAL = PopReal[self];
SetGray[self, f];
};
ApplyMAKESAMPLEDBLACK: PUBLIC PROC[self: State] = {
transparent: BOOL = PopBool[self];
um: Transformation = PopTransformation[self];
pa: PixelArray = PopPixelArray[self];
col: Color = MakeSampledBlack[pa, um, transparent];
PushColor[self, col];
};
ApplyMAKESAMPLEDCOLOR: PUBLIC PROC[self: State] = {
colorOperator: Operator = PopOperator[self];
um: Transformation = PopTransformation[self];
pa: PixelArray = PopPixelArray[self];
col: Color = MakeSampledColor[pa, um, colorOperator];
PushColor[self, col];
};
4.8 Mask operators
ApplyMOVETO: PUBLIC PROC[self: State] = {
p: Pair = PopPair[self];
t: Trajectory = IPGeometry.MoveTo[p];
PushTrajectory[self, t];
};
ApplyLINETO: PUBLIC PROC[self: State] = {
p: Pair = PopPair[self];
t1: Trajectory = PopTrajectory[self];
t2: Trajectory = IPGeometry.LineTo[t1, p];
PushTrajectory[self, t2];
};
ApplyLINETOX: PUBLIC PROC[self: State] = {
x: REAL = PopReal[self];
t1: Trajectory = PopTrajectory[self];
t2: Trajectory = IPGeometry.LineToX[t1, x];
PushTrajectory[self, t2];
};
ApplyLINETOY: PUBLIC PROC[self: State] = {
y: REAL = PopReal[self];
t1: Trajectory = PopTrajectory[self];
t2: Trajectory = IPGeometry.LineToY[t1, y];
PushTrajectory[self, t2];
};
ApplyCURVETO: PUBLIC PROC[self: State] = {
p3: Pair = PopPair[self];
p2: Pair = PopPair[self];
p1: Pair = PopPair[self];
t1: Trajectory = PopTrajectory[self];
t2: Trajectory = IPGeometry.CurveTo[t1, p1, p2, p3];
PushTrajectory[self, t2];
};
ApplyARCTO: PUBLIC PROC[self: State] = {
ERROR IPErrors.MasterError[Unimplemented];
};
ApplyCONICTO: PUBLIC PROC[self: State] = {
ERROR IPErrors.MasterError[Unimplemented];
};
ApplyMAKEOUTLINE: PUBLIC PROC[self: State] = {
n: Integer = PopInteger[self];
p: PROC RETURNS[Trajectory] = { RETURN[PopTrajectory[self]] };
o: Outline = IPGeometry.MakeOutline[n, p];
PushOutline[self, o];
};
ApplyMASKFILL: PUBLIC PROC[self: State] = {
o: Outline = PopOutline[self];
MaskFill[self, o];
};
ApplyMASKSTROKE: PUBLIC PROC[self: State] = {
t: Trajectory = PopTrajectory[self];
MaskStroke[self, t, FALSE];
};
ApplyMASKSTROKECLOSED: PUBLIC PROC[self: State] = {
t: Trajectory = PopTrajectory[self];
MaskStroke[self, t, TRUE];
};
ApplyMASKRECTANGLE: PUBLIC PROC[self: State] = {
h: REAL = PopReal[self]; w: REAL = PopReal[self];
y: REAL = PopReal[self]; x: REAL = PopReal[self];
MaskRectangle[self, x, y, w, h];
};
ApplyMASKVECTOR: PUBLIC PROC[self: State] = {
p2: Pair = PopPair[self];
p1: Pair = PopPair[self];
MaskVector[self, p1, p2];
};
ApplySTARTUNDERLINE: PUBLIC PROC[self: State] = {
StartUnderline[self];
};
ApplyMASKUNDERLINE: PUBLIC PROC[self: State] = {
h: REAL = PopReal[self]; dy: REAL = PopReal[self];
MaskUnderline[self, dy, h];
};
ApplyMASKTRAPEZOIDX: PUBLIC PROC[self: State] = {
x4: REAL = PopReal[self];
y3: REAL = PopReal[self];
x3: REAL = PopReal[self];
x2: REAL = PopReal[self];
y1: REAL = PopReal[self];
x1: REAL = PopReal[self];
MaskTrapezoidX[self, x1, y1, x2, x3, y3, x4];
};
ApplyMASKTRAPEZOIDY: PUBLIC PROC[self: State] = {
y4: REAL = PopReal[self];
y3: REAL = PopReal[self];
x3: REAL = PopReal[self];
y2: REAL = PopReal[self];
y1: REAL = PopReal[self];
x1: REAL = PopReal[self];
MaskTrapezoidY[self, x1, y1, y2, x3, y3, y4];
};
ApplyMASKPIXEL: PUBLIC PROC[self: State] = {
pa: PixelArray = PopPixelArray[self];
MaskPixel[self, pa];
};
ApplyCLIPOUTLINE: PUBLIC PROC[self: State] = {
ERROR IPErrors.MasterError[Unimplemented];
};
ApplyCLIPRECTANGLE: PUBLIC PROC[self: State] = {
ERROR IPErrors.MasterError[Unimplemented];
};
4.9 Character operators
ApplyFINDFONT: PUBLIC PROC[self: State] = {
v: Vector = PopVector[self];
w: Vector = FindFont[self, v];
PushVector[self, w];
};
ApplyFINDFONTVEC: PUBLIC PROC[self: State] = {
ERROR IPErrors.MasterError[Unimplemented];
};
ApplyMODIFYFONT: PUBLIC PROC[self: State] = {
m: Transformation = PopTransformation[self];
v: Vector = PopVector[self];
w: Vector = ModifyFont[v, m];
PushVector[self, w];
};
ApplySETFONT: PUBLIC PROC[self: State] = {
n: Integer = PopInteger[self];
SetFont[self, n];
};
4.10 Spacing correction
ApplyCORRECTMASK: PUBLIC PROC[self: State] = {
CorrectMask[self];
};
ApplyCORRECTSPACE: PUBLIC PROC[self: State] = {
v: Pair = PopPair[self];
CorrectSpace[self, v];
};
ApplyCORRECT: PUBLIC PROC[self: State] = {
Correct[self];
};
ApplySETCORRECTMEASURE: PUBLIC PROC[self: State] = {
v: Pair = PopPair[self];
SetCorrectMeasure[self, v];
};
ApplySETCORRECTTOLERANCE: PUBLIC PROC[self: State] = {
v: Pair = PopPair[self];
SetCorrectTolerance[self, v];
};
ApplySPACE: PUBLIC PROC[self: State] = {
x: REAL = PopReal[self];
Space[self, x];
};
END.