ImagerJaM:
CEDAR PROGRAM
IMPORTS Basics, Font, Imager, IO, JaM, JaMImagerContexts, JaMIPrivate, JaMImager, Real, ImagerAISUtil, ImagerPD, Rope, UFPressFontReader, UFFileManager, ImagerBrick, ImagerHalftone, ImagerPixelMaps
EXPORTS JaMIPrivate
= BEGIN
Context: TYPE = Imager.Context;
Pair: TYPE = ImagerBasic.Pair;
ROPE: TYPE = Rope.ROPE;
Transformation:
TYPE = ImagerBasic.Transformation;
PopPair:
PROC [state: JaM.State]
RETURNS [Pair] = {
y: REAL ← JaM.PopReal[state];
x: REAL ← JaM.PopReal[state];
RETURN [[x, y]]
};
ConicTo:
PROC [state: JaM.State] = {
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[state];
r: REAL ← JaM.PopReal[state];
p2: Pair ← PopPair[state];
p1: Pair ← PopPair[state];
IF info.trajectory # NIL THEN info.trajectory.first ← info.trajectory.first.ConicTo[p1, p2, r];
};
ArcTo:
PROC [state: JaM.State] = {
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[state];
p2: Pair ← PopPair[state];
p1: Pair ← PopPair[state];
IF info.trajectory # NIL THEN info.trajectory.first ← info.trajectory.first.ArcTo[p1, p2];
};
Move:
PROC [state: JaM.State] = {
Paint: PROC [dc: Context] = {dc.Move};
JaMImager.Painter[Paint, state];
};
Trans:
PROC [state: JaM.State] = {
Paint: PROC [dc: Context] = {dc.Trans};
JaMImager.Painter[Paint, state];
};
SetXY:
PROC [state: JaM.State] = {
p: Pair ← PopPair[state];
Paint: PROC [dc: Context] = {dc.SetXY[p]};
JaMImager.Painter[Paint, state];
};
SetXYRel:
PROC [state: JaM.State] = {
p: Pair ← PopPair[state];
Paint: PROC [dc: Context] = {dc.SetXYRel[p]};
JaMImager.Painter[Paint, state];
};
MakeGray:
PROC [state: JaM.State] = {
JaM.Push[state, Imager.MakeGray[JaM.PopReal[state]]];
};
Black:
PROC [state: JaM.State] = {
JaM.Push[state, Imager.black];
};
White:
PROC [state: JaM.State] = {
JaM.Push[state, Imager.white];
};
MakeStipple:
PROC [state: JaM.State] = {
JaM.Push[state, Imager.MakeStipple[JaM.PopInt[state]]];
};
SetColor:
PROC [state: JaM.State] = {
color: Imager.Color ← NARROW[JaM.Pop[state]];
Paint: PROC [dc: Context] = {dc.SetColor[color]};
JaMImager.Painter[Paint, state];
};
SetSampledColor:
PROC [state: JaM.State] = {
aisName: ROPE ← JaM.PopRope[state];
color: ImagerBasic.SampledColor ← ImagerAISUtil.AISToColor[aisName];
Paint:
PROC [dc: Context] = {
trans: Transformation ← NARROW[dc.state, ImagerDefault.State].T;
copy: ImagerBasic.SampledColor ← NEW[ImagerBasic.ColorRep.sampled ← color^];
copy.m ← trans;
dc.SetColor[copy];
};
JaMImager.Painter[Paint, state];
};
--the old version takes: PixelArray transparent
SetSampledBlackIdent:
PROC [state: JaM.State] = {
transparent: BOOLEAN ← JaM.PopBool[state];
pa: ImagerBasic.PixelArray ← NARROW[JaM.Pop[state]];
Paint:
PROC [dc: Context] = {
dc.SetSampledBlack[pa, Imager.Rotate[0], transparent];
};
JaMImager.Painter[Paint, state];
};
--new version takes: PixelArray Transformation transparent
SetSampledBlack:
PROC [state: JaM.State] = {
transparent: BOOLEAN ← JaM.PopBool[state];
trans: Transformation ← NARROW[JaM.Pop[state]];
pa: ImagerBasic.PixelArray ← NARROW[JaM.Pop[state]];
Paint:
PROC [dc: Context] = {
dc.SetSampledBlack[pa, trans, transparent];
};
JaMImager.Painter[Paint, state];
};
MakeSampledBlack:
PROC [state: JaM.State] = {
transparent: BOOLEAN ← JaM.PopBool[state];
trans: Transformation ← NARROW[JaM.Pop[state]];
pa: ImagerBasic.PixelArray ← NARROW[JaM.Pop[state]];
color: ImagerBasic.SampledColor ~
NEW[ImagerBasic.ColorRep.sampled ← [sampled[
transparent: transparent,
pa: pa,
m: trans,
colorOperator: $SampledBlack
]]];
JaM.Push[state,color];
};
ConcatT:
PROC [state: JaM.State] = {
m: Imager.Transformation ← NARROW[JaM.Pop[state]];
Paint:
PROC [dc: Context] = {
dc.ConcatT[m];
};
JaMImager.Painter[Paint, state];
};
MakeT:
PROC [state: JaM.State] = {
f: REAL ← JaM.PopReal[state];
e: REAL ← JaM.PopReal[state];
d: REAL ← JaM.PopReal[state];
c: REAL ← JaM.PopReal[state];
b: REAL ← JaM.PopReal[state];
a: REAL ← JaM.PopReal[state];
JaM.Push[state, Imager.MakeT[a: a, b: b, c: c, d: d, e: e, f: f]];
};
Translate:
PROC [state: JaM.State] = {
y: REAL ← JaM.PopReal[state];
x: REAL ← JaM.PopReal[state];
JaM.Push[state, Imager.Translate[x: x, y: y]];
};
Scale:
PROC [state: JaM.State] = {
JaM.Push[state, Imager.Scale[s: JaM.PopReal[state]]];
};
Scale2:
PROC [state: JaM.State] = {
y: REAL ← JaM.PopReal[state];
x: REAL ← JaM.PopReal[state];
JaM.Push[state, Imager.Scale2[sx: x, sy: y]];
};
Rotate:
PROC [state: JaM.State] = {
JaM.Push[state, Imager.Rotate[a: JaM.PopReal[state]]];
};
Invert:
PROC [state: JaM.State] = {
JaM.Push[state, Imager.Invert[m: NARROW[JaM.Pop[state]]]];
};
GetCP:
PROC [state: JaM.State] = {
cp: Pair ← [0, 0];
Paint: PROC [dc: Context] = {cp ← NARROW[dc.class, ImagerPrivate.Class].GetCP[dc]};
JaMImager.Painter[Paint, state];
state.PushReal[cp.x];
state.PushReal[cp.y];
};
SetStrokeWidth:
PROC [state: JaM.State] = {
w: REAL ← JaM.PopReal[state];
Paint: PROC [dc: Context] = {dc.SetStrokeWidth[w]};
JaMImager.Painter[Paint, state];
};
SetStrokeEnd:
PROC [state: JaM.State] = {
i: INT ← JaM.PopInt[state];
Paint: PROC [dc: Context] = {dc.SetStrokeEnd[IF i=1 THEN square ELSE IF i=2 THEN round ELSE butt]};
JaMImager.Painter[Paint, state];
};
SetNoImage:
PROC [state: JaM.State] = {
b: BOOLEAN ← JaM.PopBool[state];
encode: ARRAY BOOLEAN OF INTEGER = [FALSE: 0, TRUE: 1];
Paint:
PROC [dc: Context] = {
class: ImagerPrivate.Class ← NARROW[dc.class];
class.ISetInt[dc, $noImage, encode[b]]
};
JaMImager.Painter[Paint, state];
};
MaskFill:
PROC [state: JaM.State] = {
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[state];
Paint: PROC [dc: Context] = {dc.MaskFill[info.trajectory]};
JaMImager.Painter[Paint, state];
};
MaskStroke:
PROC [state: JaM.State] = {
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[state];
Paint: PROC [dc: Context] = {dc.MaskStroke[info.trajectory.first]};
IF info.trajectory # NIL THEN JaMImager.Painter[Paint, state];
};
MaskStrokeClosed:
PROC [state: JaM.State] = {
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[state];
Paint: PROC [dc: Context] = {dc.MaskStrokeClosed[info.trajectory.first]};
IF info.trajectory # NIL THEN JaMImager.Painter[Paint, state];
};
MaskRectangle:
PROC [state: JaM.State] = {
wh: Pair ← PopPair[state];
xy: Pair ← PopPair[state];
Paint: PROC [dc: Context] = {dc.MaskRectangle[xy.x, xy.y, wh.x, wh.y]};
JaMImager.Painter[Paint, state];
};
MaskVector:
PROC [state: JaM.State] = {
p2: Pair ← PopPair[state];
p1: Pair ← PopPair[state];
Paint: PROC [dc: Context] = {dc.MaskVector[p1, p2]};
JaMImager.Painter[Paint, state];
};
StartUnderline:
PROC [state: JaM.State] = {
Paint: PROC [dc: Context] = {dc.StartUnderline};
JaMImager.Painter[Paint, state];
};
MaskUnderline:
PROC [state: JaM.State] = {
h: REAL ← JaM.PopReal[state];
dy: REAL ← JaM.PopReal[state];
Paint:
PROC [dc: Context] = {
dc.MaskUnderline[dy, h];
};
JaMImager.Painter[Paint, state];
};
SetAmplifySpace:
PROC [state: JaM.State] = {
e: REAL ← JaM.PopReal[state];
Paint: PROC [dc: Context] = {dc.SetAmplifySpace[e]};
JaMImager.Painter[Paint, state];
};
SetPriorityImportant:
PROC [state: JaM.State] = {
b: BOOLEAN ← JaM.PopBool[state];
Paint: PROC [dc: Context] = {dc.SetPriorityImportant[b]};
JaMImager.Painter[Paint, state];
};
CorrectMask:
PROC [state: JaM.State] = {
Paint: PROC [dc: Context] = {dc.CorrectMask};
JaMImager.Painter[Paint, state];
};
CorrectSpace:
PROC [state: JaM.State] = {
p: Pair ← PopPair[state];
Paint: PROC [dc: Context] = {dc.CorrectSpace[p]};
JaMImager.Painter[Paint, state];
};
DoSave:
PROC [state: JaM.State] = {
op: REF ← JaM.Pop[state];
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[state];
Body: PROC = {JaM.Execute[state, op]};
dcList: JaMImagerContexts.DCList ← info.dcList;
venabled: BOOLEAN ← info.venabled;
{
ENABLE
UNWIND => {info.dcList ← dcList; info.venabled ← venabled};
info.dcList ← NIL;
IF info.venabled
THEN {
info.vdc.DoSave[Body];
};
info.venabled ← FALSE;
FOR dcListItem: JaMImagerContexts.DCList ← dcList, dcListItem.next
UNTIL dcListItem =
NIL
DO
next: JaMImagerContexts.DCList ← dcListItem.next;
{
ENABLE
UNWIND => dcListItem.next ← next;
info.dcList ← dcListItem;
dcListItem.next ← NIL;
IF dcListItem.enabled
THEN {
dcListItem.dc.DoSave[Body];
};
};
dcListItem.next ← next;
ENDLOOP;
};
info.dcList ← dcList;
info.venabled ← venabled;
};
DoSaveAll:
PROC [state: JaM.State] = {
op: REF ← JaM.Pop[state];
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[state];
Body: PROC = {JaM.Execute[state, op]};
dcList: JaMImagerContexts.DCList ← info.dcList;
venabled: BOOLEAN ← info.venabled;
{
ENABLE
UNWIND => {info.dcList ← dcList; info.venabled ← venabled};
info.dcList ← NIL;
IF info.venabled
THEN {
info.vdc.DoSaveAll[Body];
};
info.venabled ← FALSE;
FOR dcListItem: JaMImagerContexts.DCList ← dcList, dcListItem.next
UNTIL dcListItem =
NIL
DO
next: JaMImagerContexts.DCList ← dcListItem.next;
{
ENABLE
UNWIND => dcListItem.next ← next;
info.dcList ← dcListItem;
dcListItem.next ← NIL;
IF dcListItem.enabled
THEN {
dcListItem.dc.DoSaveAll[Body];
};
};
dcListItem.next ← next;
ENDLOOP;
};
info.dcList ← dcList;
info.venabled ← venabled;
};
Correct:
PROC [state: JaM.State] = {
op: REF ← JaM.Pop[state];
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[state];
Body: PROC = {JaM.Execute[state, op]};
dcList: JaMImagerContexts.DCList ← info.dcList;
venabled: BOOLEAN ← info.venabled;
{
ENABLE
UNWIND => {info.dcList ← dcList; info.venabled ← venabled};
info.dcList ← NIL;
IF info.venabled
THEN {
info.vdc.Correct[Body];
};
info.venabled ← FALSE;
FOR dcListItem: JaMImagerContexts.DCList ← dcList, dcListItem.next
UNTIL dcListItem =
NIL
DO
next: JaMImagerContexts.DCList ← dcListItem.next;
{
ENABLE
UNWIND => dcListItem.next ← next;
info.dcList ← dcListItem;
dcListItem.next ← NIL;
IF dcListItem.enabled
THEN {
dcListItem.dc.Correct[Body];
};
};
dcListItem.next ← next;
ENDLOOP;
};
info.dcList ← dcList;
info.venabled ← venabled;
};
SetCorrectMeasure:
PROC [state: JaM.State] = {
p: Pair ← PopPair[state];
Paint: PROC [dc: Context] = {dc.SetCorrectMeasure[p]};
JaMImager.Painter[Paint, state];
};
SetCorrectTolerance:
PROC [state: JaM.State] = {
p: Pair ← PopPair[state];
Paint: PROC [dc: Context] = {dc.SetCorrectTolerance[p]};
JaMImager.Painter[Paint, state];
};
SetCorrectShrink:
PROC [state: JaM.State] = {
e: REAL ← JaM.PopReal[state];
Paint: PROC [dc: Context] = {dc.SetCorrectShrink[e]};
JaMImager.Painter[Paint, state];
};
Space:
PROC [state: JaM.State] = {
e: REAL ← JaM.PopReal[state];
Paint: PROC [dc: Context] = {dc.Space[e]};
JaMImager.Painter[Paint, state];
};
IState:
PROC [state: JaM.State] = {
s: IO.STREAM ← IO.ROS[];
Paint:
PROC [dc: Context] = {
s.Put[IO.refAny[dc.state]];
s.PutChar['\n];
};
JaMImager.Painter[Paint, state];
JaM.Push[state, IO.RopeFromROS[s]];
};
AnyToRope:
PROC [state: JaM.State] = {
r: REF ← JaM.Pop[state];
s: IO.STREAM ← IO.ROS[];
s.Put[IO.refAny[r]];
s.PutChar['\n];
JaM.Push[state, IO.RopeFromROS[s]];
};
PlatemakerTemplate: ImagerPD.PDFileDescriptionRep ← [
fileName: NIL,
deviceCode: mig,
sResolution: 880,
fResolution: 880,
imageSSize: 9680,
imageFSize: 7480,
nColors: 1,
bandSSize: 16,
maxLoadWords: 60000,
leftovers: TRUE,
copies: 1
];
VersatecTemplate: ImagerPD.PDFileDescriptionRep ← [
fileName: NIL,
deviceCode: mig,
sResolution: 200,
fResolution: 200,
imageSSize: 20000,
imageFSize: 8000,
nColors: 1,
bandSSize: 64,
maxLoadWords: 60000,
leftovers: FALSE,
copies: 1
];
PlateMakerParam:
PROC[fileName:
ROPE]
RETURNS [param: ImagerPD.PDFileDescription] = {
param ← NEW[ImagerPD.PDFileDescriptionRep ← PlatemakerTemplate];
param.fileName ← fileName;
};
VersatecParam:
PROC[fileName:
ROPE]
RETURNS [param: ImagerPD.PDFileDescription] = {
param ← NEW[ImagerPD.PDFileDescriptionRep ← VersatecTemplate];
param.fileName ← fileName;
};
ColorVersatecParam:
PROC[fileName:
ROPE]
RETURNS [param: ImagerPD.PDFileDescription] = {
param ← NEW[ImagerPD.PDFileDescriptionRep ← VersatecTemplate];
param.fileName ← fileName;
param.nColors ← 4;
};
SetLineScreen:
PROC[state: JaM.State] = {
angle: REAL ← JaM.PopReal[state];
linesPerInch: REAL ← JaM.PopReal[state];
Paint:
PROC [dc: Context] = {
param: ImagerPD.PDFileDescription ← NARROW[Imager.GetProp[dc, $PDParam]];
IF param #
NIL
THEN {
dtheta: REAL ← IF param.imageSSize < param.imageFSize THEN 90 ELSE 0;
brick: ImagerBrick.Brick ← ImagerBrick.BuildBrick[freq: param.sResolution/linesPerInch, angle: angle+dtheta, filter: ImagerHalftone.LineScreen];
Imager.PutProp[dc, $CustomBrick, brick];
};
};
JaMImager.Painter[Paint, state];
};
SetDotScreen:
PROC[state: JaM.State] = {
angle: REAL ← JaM.PopReal[state];
linesPerInch: REAL ← JaM.PopReal[state];
ratio: REAL ← MIN[MAX[JaM.PopReal[state], 0], 1];
DotScreen:
PROC [x, y:
REAL]
RETURNS [fvalue:
REAL] ~ {
tx: REAL ← (x-1)*(x-1)*(x+1)*(x+1);
ty: REAL ← (y-1)*(y-1)*(y+1)*(y+1);
fvalue ← tx*ratio+ty*(1-ratio);
};
Paint:
PROC [dc: Context] = {
param: ImagerPD.PDFileDescription ← NARROW[Imager.GetProp[dc, $PDParam]];
IF param #
NIL
THEN {
dtheta: REAL ← IF param.imageSSize < param.imageFSize THEN 90 ELSE 0;
brick: ImagerBrick.Brick ← ImagerBrick.BuildBrick[freq: param.sResolution/linesPerInch, angle: angle+dtheta, filter: DotScreen];
Imager.PutProp[dc, $CustomBrick, brick];
};
};
JaMImager.Painter[Paint, state];
};
SetCustomScreen:
PROC[state: JaM.State] = {
phase: INT ← JaM.PopInt[state];
dotsPerLine: INT ← JaM.PopInt[state];
linesPerBrick: INT ← JaM.PopInt[state];
brick: ImagerBrick.Brick ← NEW[ImagerBrick.BrickRep[dotsPerLine*linesPerBrick]];
Paint:
PROC [dc: Context] = {
param: ImagerPD.PDFileDescription ← NARROW[Imager.GetProp[dc, $PDParam]];
IF param # NIL THEN Imager.PutProp[dc, $CustomBrick, brick];
};
brick.fSize ← dotsPerLine;
brick.sSize ← linesPerBrick;
brick.phase ← phase;
FOR i:
INT
DECREASING
IN [0..dotsPerLine*linesPerBrick)
DO
brick[i] ← JaM.PopReal[state];
ENDLOOP;
JaMImager.Painter[Paint, state];
};
SetAISScreen:
PROC[state: JaM.State] = {
angle: REAL ← JaM.PopReal[state];
imagesPerInch: REAL ← JaM.PopReal[state];
aisName: ROPE ← JaM.PopRope[state];
pixelMap: ImagerPixelMaps.PixelMap ← ImagerAISUtil.PixelMapFromAIS[aisName].pixelMap;
maxPixel: CARDINAL ← Basics.BITSHIFT[1, Basics.BITSHIFT[1, pixelMap.refRep.lgBitsPerPixel]] - 1;
mult: REAL ← 1.0/maxPixel;
AISScreen:
PROC [x, y:
REAL]
RETURNS [fvalue:
REAL] ~ {
sr: REAL ← (1-y)/2.0*pixelMap.sSize;
fr: REAL ← (1+x)/2.0*pixelMap.fSize;
f: CARDINAL ← Real.Fix[fr];
s: CARDINAL ← Real.Fix[sr];
RETURN [pixelMap.GetPixel[f, s]*mult]
};
Paint:
PROC [dc: Context] = {
param: ImagerPD.PDFileDescription ← NARROW[Imager.GetProp[dc, $PDParam]];
IF param #
NIL
THEN {
dtheta: REAL ← IF param.imageSSize < param.imageFSize THEN 90 ELSE 0;
brick: ImagerBrick.Brick ← ImagerBrick.BuildBrick[freq: param.sResolution/imagesPerInch, angle: angle+dtheta, filter: AISScreen];
Imager.PutProp[dc, $CustomBrick, brick];
};
};
JaMImager.Painter[Paint, state];
};
OpenPlatemakerPD:
PROC[state: JaM.State] = {
name: ROPE = JaM.PopRope[state];
param: ImagerPD.PDFileDescription ← PlateMakerParam[name];
context: Imager.Context ← Imager.Create[$PD, param];
Imager.PutProp[context, $PDParam, param];
JaMImagerContexts.AddContext[state, context, PDCallMe, $PD];
context.ScaleT[0.0254/72];
};
PDCallMe: JaMImagerContexts.CallMe ~ {
IF command = initdc
THEN {context.Reset; context.ScaleT[0.0254/72]}};
OpenVersatecPD:
PROC[state: JaM.State] = {
name: ROPE = JaM.PopRope[state];
param: ImagerPD.PDFileDescription ← VersatecParam[name];
context: Imager.Context ← Imager.Create[$PD, param];
Imager.PutProp[context, $PDParam, param];
JaMImagerContexts.AddContext[state, context, PDCallMe, $PD];
context.ScaleT[0.0254/72];
};
OpenColorVersatecPD:
PROC[state: JaM.State] = {
name: ROPE = JaM.PopRope[state];
param: ImagerPD.PDFileDescription ← ColorVersatecParam[name];
context: Imager.Context ← Imager.Create[$PD, param];
Imager.PutProp[context, $PDParam, param];
JaMImagerContexts.AddContext[state, context, PDCallMe, $PD];
context.ScaleT[0.0254/72];
};
OpenHornetPD:
PROC[state: JaM.State] = {
name: ROPE = JaM.PopRope[state];
param: ImagerPD.PDFileDescription ← ImagerPD.Hornet[name];
context: Imager.Context ← Imager.Create[$PD, param];
Imager.PutProp[context, $PDParam, param];
JaMImagerContexts.AddContext[state, context, PDCallMe, $PD];
context.ScaleT[0.0254/72];
};
OpenRavenPD:
PROC[state: JaM.State] = {
name: ROPE = JaM.PopRope[state];
param: ImagerPD.PDFileDescription ← ImagerPD.Raven[name];
context: Imager.Context ← Imager.Create[$PD, param];
Imager.PutProp[context, $PDParam, param];
JaMImagerContexts.AddContext[state, context, PDCallMe, $PD];
context.ScaleT[0.0254/72];
};
NewToner:
PROC[state: JaM.State] = {
Paint:
PROC [dc: Context] = {
param: ImagerPD.PDFileDescription ← NARROW[Imager.GetProp[dc, $PDParam]];
IF param #
NIL
THEN {
[] ← Imager.SpecialOp[dc, $NewToner, NIL];
};
};
JaMImager.Painter[Paint, state];
};
NewPage:
PROC[state: JaM.State] = {
Paint:
PROC [dc: Context] = {
param: ImagerPD.PDFileDescription ← NARROW[Imager.GetProp[dc, $PDParam]];
IF param #
NIL
THEN {
[] ← Imager.SpecialOp[dc, $NewPage, NIL];
};
};
JaMImager.Painter[Paint, state];
};
ClosePD:
PROC[state: JaM.State] = {
dc: Context ← JaMImagerContexts.RemoveContext[state, $PD];
IF dc # NIL THEN [] ← Imager.SpecialOp[dc, $Close, NIL];
};
lastInt: REAL ~ 2147483647.0;
Trunc:
PROC[state: JaM.State] = {
r: REAL = JaM.PopReal[state];
IF ABS[r] > lastInt THEN {JaM.PushReal[state, r]}
ELSE JaM.PushInt[state, Real.Fix[r]];
};
Round:
PROC[state: JaM.State] = {
r: REAL = JaM.PopReal[state];
IF ABS[r] > lastInt THEN {JaM.PushReal[state, r]}
ELSE JaM.PushInt[state, Real.RoundLI[r]];
};
Floor:
PROC[state: JaM.State] = {
r: REAL = JaM.PopReal[state];
IF ABS[r] > lastInt THEN {JaM.PushReal[state, r]}
ELSE {
i: INT ← Real.RoundLI[r];
WHILE i >= r DO i←i-1 ENDLOOP;
WHILE i < r DO i←i+1 ENDLOOP;
JaM.PushInt[state, i];
};
};
Ceil:
PROC[state: JaM.State] = {
r: REAL = JaM.PopReal[state];
i: INT ← Real.RoundLI[r];
IF ABS[r] > lastInt THEN {JaM.PushReal[state, r]}
ELSE {
i: INT ← Real.RoundLI[r];
WHILE i <= r DO i←i+1 ENDLOOP;
WHILE i > r DO i←i-1 ENDLOOP;
JaM.PushInt[state, i];
};
};
MakeBitArray:
PROC[state: JaM.State] = {
bits: PACKED ARRAY [0..1024) OF [0..1];
columns: INT ← JaM.PopInt[state];
rows: INT ← JaM.PopInt[state];
FOR i:
INT
DECREASING
IN [0..columns*rows)
DO
bits[i] ← JaM.PopInt[state];
ENDLOOP;
TRUSTED {JaM.Push[state, Imager.MakePixelArrayFromBits[@bits, columns, columns, rows]]};
};
MaskPixel:
PROC[state: JaM.State] = {
pa: ImagerBasic.PixelArray ← NARROW[JaM.Pop[state]];
Paint:
PROC [dc: Context] = {
dc.MaskPixel[pa];
};
JaMImager.Painter[Paint, state];
};
PixelArrayFromAC:
PROC[state: JaM.State] = {
char: CHAR ← JaM.PopRope[state].Fetch[0];
acName: ROPE ← JaM.PopRope[state];
fontKey: UFPressFontReader.FontKey ← [UFFileManager.KeyOf[acName], 0];
pa: ImagerBasic.PixelArray ← UFPressFontReader.GetCharRaster[fontKey, char];
JaM.Push[state, pa];
};
deviceType: ATOM ← $Ideal;
NSRSetFont:
PROC[state: JaM.State] = {
rotation: REAL ← JaM.PopReal[state];
size: REAL ← JaM.PopReal[state];
name: ROPE ← JaM.PopRope[state];
font: Font.FONT ← Font.Create[name, Imager.Concat[Imager.Scale[size], Imager.Rotate[rotation]], deviceType];
Paint:
PROC [dc: Context] = {
dc.SetFont[font];
};
JaMImager.Painter[Paint, state];
};
Show:
PROC[state: JaM.State] = {
text: ROPE ← JaM.PopRope[state];
Paint:
PROC [dc: Context] = {
dc.ShowCharacters[text];
};
JaMImager.Painter[Paint, state];
};
Ddt:
PROC[state: JaM.State] = {
any: REF ← JaM.Pop[state];
context: Imager.Context ← NIL;
Paint:
PROC [dc: Context] = {
IF context = NIL THEN context ← dc;
};
RaiseError: PROC ~ {ERROR};
JaMImager.Painter[Paint, state];
RaiseError[! ABORTED => CONTINUE];
};
ImagerReset:
PROC[state: JaM.State] = {
Paint:
PROC [dc: Context] = {
brick: REF ← Imager.GetProp[dc, $CustomBrick];
dc.Reset;
dc.ScaleT[0.0254/72];
Imager.PutProp[dc, $CustomBrick, brick];
};
JaMImager.Painter[Paint, state];
};
RegisterImager:
PUBLIC PROC [state: JaM.State] = {
JaM.Register[state, ".move", Move];
JaM.Register[state, ".trans", Trans];
JaM.Register[state, ".setxy", SetXY];
JaM.Register[state, ".setxyrel", SetXYRel];
JaM.Register[state, ".makegray", MakeGray];
JaM.Register[state, ".black", Black];
JaM.Register[state, ".white", White];
JaM.Register[state, ".makestipple", MakeStipple];
JaM.Register[state, ".setcolor", SetColor];
JaM.Register[state, ".setsampledcolor", SetSampledColor];
JaM.Register[state, ".setsampledblack", SetSampledBlack];
JaM.Register[state, ".makesampledblack", MakeSampledBlack];
JaM.Register[state, ".setsampledblackident", SetSampledBlackIdent];
JaM.Register[state, ".concatT", ConcatT];
JaM.Register[state, ".makeT", MakeT];
JaM.Register[state, ".makeTranslate", Translate];
JaM.Register[state, ".makeScale", Scale];
JaM.Register[state, ".makeScale2", Scale2];
JaM.Register[state, ".makeRotate", Rotate];
JaM.Register[state, ".invert", Invert];
JaM.Register[state, ".makebitarray", MakeBitArray];
JaM.Register[state, ".maskpixel", MaskPixel];
JaM.Register[state, ".pixelarrayfromac", PixelArrayFromAC];
JaM.Register[state, ".conicto", ConicTo];
JaM.Register[state, ".arcto", ArcTo];
JaM.Register[state, ".getcp", GetCP];
JaM.Register[state, ".setstrokewidth", SetStrokeWidth];
JaM.Register[state, ".setstrokeend", SetStrokeEnd];
JaM.Register[state, ".setnoimage", SetNoImage];
JaM.Register[state, ".maskfill", MaskFill];
JaM.Register[state, ".maskstroke", MaskStroke];
JaM.Register[state, ".maskstrokeclosed", MaskStrokeClosed];
JaM.Register[state, ".maskrectangle", MaskRectangle];
JaM.Register[state, ".maskvector", MaskVector];
JaM.Register[state, ".startunderline", StartUnderline];
JaM.Register[state, ".maskunderline", MaskUnderline];
JaM.Register[state, ".setamplifyspace", SetAmplifySpace];
JaM.Register[state, ".setpriorityimportant", SetPriorityImportant];
JaM.Register[state, ".correctmask", CorrectMask];
JaM.Register[state, ".correctspace", CorrectSpace];
JaM.Register[state, ".dosave", DoSave];
JaM.Register[state, ".dosaveall", DoSaveAll];
JaM.Register[state, ".correct", Correct];
JaM.Register[state, ".setcorrectmeasure", SetCorrectMeasure];
JaM.Register[state, ".setcorrecttolerance", SetCorrectTolerance];
JaM.Register[state, ".setcorrectshrink", SetCorrectShrink];
JaM.Register[state, ".space", Space];
JaM.Register[state, ".istate", IState];
JaM.Register[state, ".anytorope", AnyToRope];
JaM.Register[state, ".openhornetpd", OpenHornetPD];
JaM.Register[state, ".openplatemakerpd", OpenPlatemakerPD];
JaM.Register[state, ".openravenpd", OpenRavenPD];
JaM.Register[state, ".openversatecpd", OpenVersatecPD];
JaM.Register[state, ".opencolorversatecpd", OpenColorVersatecPD];
JaM.Register[state, ".newtoner", NewToner];
JaM.Register[state, ".newpage", NewPage];
JaM.Register[state, ".closepd", ClosePD];
JaM.Register[state, ".nsrsetfont", NSRSetFont];
JaM.Register[state, ".show", Show];
JaM.Register[state, ".ddt", Ddt];
JaM.Register[state, ".setlinescreen", SetLineScreen];
JaM.Register[state, ".setdotscreen", SetDotScreen];
JaM.Register[state, ".setcustomscreen", SetCustomScreen];
JaM.Register[state, ".setaisscreen", SetAISScreen];
JaM.Register[state, ".imagerreset", ImagerReset];
JaM.Register[state, ".trunc", Trunc];
JaM.Register[state, ".round", Round];
JaM.Register[state, ".floor", Floor];
JaM.Register[state, ".ceil", Ceil];
};
END.