ImagerImpl.mesa
Copyright Ó 1984, 1985, 1986, 1987, 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Michael Plass, November 20, 1991 5:20 pm PST
Doug Wyatt, January 19, 1987 7:54:40 pm PST
DIRECTORY
Basics USING [bitsPerWord],
Char,
Imager USING [Outline, PathProc, Trajectory, Box, ClassRep, Color, ColorOperator, ConstantColor, Context, Font, Object, PixelArray, PixelMap, Rectangle, SampleMap, ScanMode, SpecialColor, StrokeEnd, StrokeJoint, Transformation, VEC, XChar, XStringProc, zeroVEC],
ImagerBackdoor USING [Clipper, CoordSys, IntKey, RealKey, Visibility],
ImagerBitmapContext USING [Create, SetBitmap],
ImagerColor USING [ColorFromGray],
ImagerColorPrivate USING [ColorFromStipple],
ImagerError USING [Error, ErrorDesc, Warning],
ImagerFont USING [FindScaled, MapRope],
ImagerPath USING [MapOutline, MapTrajectory],
ImagerPrivate USING [Class, ClassRep],
ImagerSample USING [GetBox, GetSize, NewSampleMap, ObtainUnsafeDescriptor, ReleaseDescriptor],
ImagerSys USING [CheckForAbort],
Prop USING [PropList, Get, Put],
Rope USING [Map, ROPE, XROPE],
SF USING [Vec];
ImagerImpl: CEDAR PROGRAM
IMPORTS Char, ImagerBitmapContext, ImagerColor, ImagerColorPrivate, ImagerError, ImagerFont, ImagerPath, ImagerSample, ImagerSys, Prop, Rope
EXPORTS Imager, ImagerBackdoor
~ BEGIN OPEN Imager;
ROPE: TYPE ~ Rope.ROPE;
XROPE: TYPE ~ Rope.XROPE;
Class: TYPE ~ ImagerPrivate.Class;
ClassRep: PUBLIC TYPE ~ ImagerPrivate.ClassRep; -- export to Imager.ClassRep
Imager Implementation
Error: PUBLIC ERROR [error: ImagerError.ErrorDesc] ¬ ImagerError.Error;
GetClass: PUBLIC PROC [context: Context] RETURNS [ATOM] ~ {
class: Class ~ context.class;
RETURN[class.type];
};
Warning: PUBLIC SIGNAL [error: ImagerError.ErrorDesc] ¬ ImagerError.Warning;
SetWarn: PUBLIC PROC [context: Context, warn: BOOL] ~ {
SetInt[context, raiseWarnings, ORD[warn]];
};
GetProp: PUBLIC PROC [context: Context, key: REF] RETURNS [val: REF] ~ {
RETURN[Prop.Get[context.propList, key]];
};
PutProp: PUBLIC PROC [context: Context, key: REF, val: REF] ~ {
ChangePropList[context, Prop.Put[context.propList, key, val]];
};
ChangePropList: PROC [context: Context, new: Prop.PropList] = INLINE {
note: BOOL = new # context.propList AND context.class.NewPropList # NIL;
context.propList ¬ new;
IF note THEN context.class.NewPropList[context];
};
DoSave: PUBLIC PROC [context: Context, action: PROC] ~ {
ref: REF ~ Save[context];
action[! UNWIND => Restore[context, ref]];
Restore[context, ref];
};
DoSaveAll: PUBLIC PROC [context: Context, action: PROC] ~ {
ref: REF ~ Save[context: context, all: TRUE];
action[! UNWIND => Restore[context, ref]];
Restore[context, ref];
};
Save: --ImagerBackdoor-- PUBLIC PROC [context: Context, all: BOOL ¬ FALSE] RETURNS [REF] = {
class: Class = context.class;
ImagerSys.CheckForAbort[];
IF context.propList # NIL THEN PutProp[context: context, key: $SavedPropList, val: context.propList];
RETURN [class.Save[context, all]];
};
Restore: --ImagerBackdoor-- PUBLIC PROC [context: Context, ref: REF] = {
class: Class = context.class;
class.Restore[context: context, ref: ref];
IF context.propList # NIL THEN ChangePropList[context, NARROW[GetProp[context: context, key: $SavedPropList]]];
};
ConcatT: PUBLIC PROC [context: Context, m: Transformation] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ConcatT[context: context, m: m];
};
ScaleT: PUBLIC PROC [context: Context, s: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Scale2T[context: context, s: [s, s]];
};
Scale2T: PUBLIC PROC [context: Context, s: VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Scale2T[context: context, s: s];
};
RotateT: PUBLIC PROC [context: Context, a: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.RotateT[context: context, a: a];
};
TranslateT: PUBLIC PROC [context: Context, t: VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.TranslateT[context: context, t: t];
};
Move: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Move[context: context, rounded: FALSE];
};
Trans: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Move[context: context, rounded: TRUE];
};
SetXY: PUBLIC PROC [context: Context, p: VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetXY[context: context, p: p];
};
SetXYI: PUBLIC PROC [context: Context, x, y: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetXY[context: context, p: [x, y]];
};
SetXYRel: PUBLIC PROC [context: Context, v: VEC] ~ {
class: Class ~ context.class;
class.SetXYRel[context: context, v: v];
};
SetXYRelI: PUBLIC PROC [context: Context, x, y: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetXYRel[context: context, v: [x, y]];
};
SetXRel: PUBLIC PROC [context: Context, x: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetXYRel[context: context, v: [x, 0]];
};
SetXRelI: PUBLIC PROC [context: Context, x: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetXYRel[context: context, v: [x, 0]];
};
SetYRel: PUBLIC PROC [context: Context, y: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetXYRel[context: context, v: [0, y]];
};
SetYRelI: PUBLIC PROC [context: Context, y: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetXYRel[context: context, v: [0, y]];
};
FindFontScaled: PUBLIC PROC [name: ROPE, s: REAL] RETURNS [Font] ~ {
RETURN [ImagerFont.FindScaled[name, s]]
};
SetFont: PUBLIC PROC [context: Context, font: Font] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetFont[context: context, font: font];
};
SetAmplifySpace: PUBLIC PROC [context: Context, amplifySpace: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetReal[context: context, key: $amplifySpace, val: amplifySpace];
};
Show: PUBLIC PROC [context: Context, string: XStringProc, xrel: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Show[context: context, string: string, xrel: xrel];
};
ShowAndFixedXRel: PUBLIC PROC [context: Context, string: XStringProc, x: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ShowAndFixedXRel[context, string, x];
};
ShowBackward: PUBLIC PROC [context: Context, string: XStringProc] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ShowBackward[context: context, string: string];
};
ShowChar: PUBLIC PROC [context: Context, char: CHAR] ~ {
string: XStringProc ~ { charAction[Char.Make[set: 0, code: ORD[char]]] };
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Show[context: context, string: string, xrel: FALSE];
};
ShowXChar: PUBLIC PROC [context: Context, char: XChar] ~ {
string: XStringProc ~ { charAction[char] };
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Show[context: context, string: string, xrel: FALSE];
};
ShowRope: PUBLIC PROC [context: Context, rope: ROPE,
start: INT ¬ 0, len: INT ¬ INT.LAST, xrel: BOOL ¬ FALSE] ~ {
string: XStringProc ~ { ImagerFont.MapRope[
rope: rope, start: start, len: len, charAction: charAction]
};
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Show[context: context, string: string, xrel: xrel];
};
ShowXRope: PUBLIC PROC [context: Context, rope: XROPE, start: INT ¬ 0, len: INT ¬ INT.LAST, xrel: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
WITH rope SELECT FROM
rope: ROPE => {
XString: XStringProc ~ {
Action: PROC [c: CHAR] RETURNS [quit: BOOL ¬ FALSE] ~ {
charAction[Char.Make[set: 0, code: ORD[c]]]
};
[] ¬ Rope.Map[base: rope, action: Action, start: start, len: len];
};
class.Show[context: context, string: XString, xrel: xrel];
};
ENDCASE => { IF rope # NIL THEN ERROR }; -- BUG - if XRope.mesa now exists, this branch nees to be implemented.
};
ShowText: PUBLIC PROC [context: Context, text: REF READONLY TEXT,
start: NAT ¬ 0, len: NAT ¬ NAT.LAST, xrel: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ShowText[context: context, text: text, start: start, len: len, xrel: xrel];
};
StartUnderline: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.StartUnderline[context: context];
};
MaskUnderline: PUBLIC PROC [context: Context, dy, h: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskUnderline[context: context, dy: dy, h: h];
};
MaskUnderlineI: PUBLIC PROC [context: Context, dy, h: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskUnderline[context: context, dy: dy, h: h];
};
CorrectMask: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.CorrectMask[context: context];
};
CorrectSpace: PUBLIC PROC [context: Context, v: VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.CorrectSpace[context: context, v: v];
};
Space: PUBLIC PROC [context: Context, x: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Space[context: context, x: x];
};
SpaceI: PUBLIC PROC [context: Context, x: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Space[context: context, x: x];
};
SetCorrectMeasure: PUBLIC PROC [context: Context, v: VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetCorrectMeasure[context: context, v: v];
};
SetCorrectTolerance: PUBLIC PROC [context: Context, v: VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetCorrectTolerance[context: context, v: v];
};
SetCorrectShrink: PUBLIC PROC [context: Context, correctShrink: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetReal[context: context, key: $correctShrink, val: correctShrink];
};
Correct: PUBLIC PROC [context: Context, action: PROC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Correct[context: context, action: action];
};
DontCorrect: PUBLIC PROC [context: Context, action: PROC, saveCP: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.DontCorrect[context: context, action: action, saveCP: saveCP];
};
SetColor: PUBLIC PROC [context: Context, color: Color] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetColor[context: context, color: color];
};
black: PUBLIC ConstantColor ¬ ImagerColor.ColorFromGray[1];
white: PUBLIC ConstantColor ¬ ImagerColor.ColorFromGray[0];
MakeGray: PUBLIC PROC [f: REAL] RETURNS [ConstantColor] ~ {
IF f>=1.0 THEN RETURN[black];
IF f<=0.0 THEN RETURN[white];
RETURN[ImagerColor.ColorFromGray[f]];
};
SetGray: PUBLIC PROC [context: Context, f: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetGray[context: context, f: f];
};
SetSampledColor: PUBLIC PROC [context: Context, pa: PixelArray,
m: Transformation, colorOperator: ColorOperator] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetSampledColor[context: context, pa: pa, m: m, colorOperator: colorOperator];
};
SetSampledBlack: PUBLIC PROC [context: Context, pa: PixelArray,
m: Transformation, clear: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
class.SetSampledBlack[context: context, pa: pa, m: m, clear: clear];
};
DrawSampledColor: PUBLIC PROC [context: Context, pa: PixelArray,
colorOperator: ColorOperator, m: Transformation, position: VEC] ~ {
drawSampledColorAction: PROC ~ {
TranslateT[context, position];
SetSampledColor[context, pa, m, colorOperator];
ConcatT[context, m];
ConcatT[context, pa.m];
MaskRectangle[context, [0, 0, pa.sSize, pa.fSize]];
};
DoSave[context, drawSampledColorAction];
};
SetPriorityImportant: PUBLIC PROC [context: Context, priorityImportant: BOOL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetInt[context: context, key: $priorityImportant, val: IF priorityImportant THEN 1 ELSE 0];
};
SetNoImage: PUBLIC PROC [context: Context, noImage: BOOL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetInt[context: context, key: $noImage, val: IF noImage THEN 1 ELSE 0];
};
MaskFill: PUBLIC PROC [context: Context, path: PathProc, oddWrap: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskFill[context: context, path: path, oddWrap: oddWrap];
};
MaskFillTrajectory: PUBLIC PROC [context: Context, trajectory: Trajectory, oddWrap: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
path: PathProc ~ { ImagerPath.MapTrajectory[trajectory: trajectory,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo]
};
ImagerSys.CheckForAbort[];
class.MaskFill[context: context, path: path, oddWrap: oddWrap];
};
MaskFillOutline: PUBLIC PROC [context: Context, outline: Outline] ~ {
class: Class ~ context.class;
path: PathProc ~ { ImagerPath.MapOutline[outline: outline,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo]
};
ImagerSys.CheckForAbort[];
class.MaskFill[context: context, path: path, oddWrap: outline.oddWrap];
};
MaskRectangle: PUBLIC PROC [context: Context, r: Rectangle] ~ {
class: Class ~ context.class;
class.MaskRectangle[context: context, r: r];
};
MaskRectangleI: PUBLIC PROC [context: Context, x, y, w, h: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskRectangleI[context: context, x: x, y: y, w: w, h: h];
};
MaskBox: PUBLIC PROC [context: Context, box: Box] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskRectangle[context: context,
r: [x: box.xmin, y: box.ymin, w: box.xmax-box.xmin, h: box.ymax-box.ymin]];
};
SetStrokeWidth: PUBLIC PROC [context: Context, strokeWidth: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetReal[context: context, key: $strokeWidth, val: strokeWidth];
};
SetStrokeEnd: PUBLIC PROC [context: Context, strokeEnd: StrokeEnd] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetInt[context: context, key: $strokeEnd, val: ORD[strokeEnd]];
};
SetStrokeJoint: PUBLIC PROC [context: Context, strokeJoint: StrokeJoint] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetInt[context: context, key: $strokeJoint, val: ORD[strokeJoint]];
};
MaskStroke: PUBLIC PROC [context: Context, path: PathProc,
closed: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskStroke[context: context, path: path, closed: closed];
};
MaskStrokeTrajectory: PUBLIC PROC [context: Context, trajectory: Trajectory,
closed: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
path: PathProc ~ { ImagerPath.MapTrajectory[trajectory: trajectory,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo]
};
ImagerSys.CheckForAbort[];
class.MaskStroke[context: context, path: path, closed: closed];
};
MaskVector: PUBLIC PROC [context: Context, p1, p2: VEC] ~ {
class: Class ~ context.class;
class.MaskVector[context: context, p1: p1, p2: p2];
};
MaskDashedStroke: PUBLIC PROC [context: Context, path: PathProc,
patternLen: NAT, pattern: PROC [NAT] RETURNS [REAL], offset, length: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskDashedStroke[context: context, path: path,
patternLen: patternLen, pattern: pattern, offset: offset, length: length];
};
MaskDashedStrokeTrajectory: PUBLIC PROC [context: Context, trajectory: Trajectory,
patternLen: NAT, pattern: PROC [NAT] RETURNS [REAL], offset, length: REAL] ~ {
class: Class ~ context.class;
path: PathProc ~ { ImagerPath.MapTrajectory[trajectory: trajectory,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo]
};
ImagerSys.CheckForAbort[];
class.MaskDashedStroke[context: context, path: path,
patternLen: patternLen, pattern: pattern, offset: offset, length: length];
};
MaskVectorI: PUBLIC PROC [context: Context, x1, y1, x2, y2: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskVector[context: context, p1: [x1, y1], p2: [x2, y2]];
};
MaskPixel: PUBLIC PROC [context: Context, pa: PixelArray] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MaskPixel[context: context, pa: pa];
};
MaskBits: PUBLIC PROC [context: Context, base: LONG POINTER, wordsPerLine: NAT, sMin, fMin, sSize, fSize: NAT, tx, ty: INTEGER] ~ TRUSTED {
class: Class ~ context.class;
bitmap: SampleMap ~ ImagerSample.ObtainUnsafeDescriptor[
size: [sSize, fSize],
bitsPerSample: 1,
bitsPerLine: wordsPerLine*Basics.bitsPerWord,
base: [word: base, bit: 0],
ref: NIL,
words: CARD[sMin+sSize]*wordsPerLine,
rawMin: [sMin, fMin]
];
MaskBitmap[context: context, bitmap: bitmap, referencePoint: [0, 0], scanMode: [slow: down, fast: right], position: [tx, ty]];
ImagerSample.ReleaseDescriptor[bitmap];
};
DrawBits: PUBLIC PROC [context: Context, base: LONG POINTER, wordsPerLine: NAT, sMin, fMin, sSize, fSize: NAT, tx, ty: INTEGER] ~ TRUSTED {
class: Class ~ context.class;
bitmap: SampleMap ~ ImagerSample.ObtainUnsafeDescriptor[
size: [sSize, fSize],
bitsPerSample: 1,
bitsPerLine: wordsPerLine*Basics.bitsPerWord,
base: [word: base, bit: 0],
ref: NIL,
words: CARD[sMin+sSize]*wordsPerLine,
rawMin: [sMin, fMin]
];
DrawBitmap[context: context, bitmap: bitmap, referencePoint: [0, 0], scanMode: [slow: down, fast: right], position: [tx, ty]];
ImagerSample.ReleaseDescriptor[bitmap];
};
MaskBitmap: PUBLIC PROC [context: Context, bitmap: SampleMap, referencePoint: SF.Vec,
scanMode: ScanMode, position: VEC] ~ {
class: Class ~ context.class;
class.MaskBitmap[context: context, bitmap: bitmap, referencePoint: referencePoint, scanMode: scanMode, position: position];
};
DrawBitmap: PUBLIC PROC [context: Context, bitmap: SampleMap, referencePoint: SF.Vec,
scanMode: ScanMode, position: VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.DrawBitmap[context: context, bitmap: bitmap, referencePoint: referencePoint, scanMode: scanMode, position: position];
};
DrawPixels: PUBLIC PROC [context: Context, pixelMap: PixelMap, colorOperator: ColorOperator, referencePoint: SF.Vec, scanMode: ScanMode, position: VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.DrawPixels[context: context, pixelMap: pixelMap, colorOperator: colorOperator, referencePoint: referencePoint, scanMode: scanMode, position: position];
};
Clip: PUBLIC PROC [context: Context, path: PathProc, oddWrap, exclude: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.Clip[context: context, path: path, oddWrap: oddWrap, exclude: exclude];
};
ClipOutline: PUBLIC PROC [context: Context, outline: Outline, exclude: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
path: PathProc ~ { ImagerPath.MapOutline[outline: outline,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo]
};
ImagerSys.CheckForAbort[];
class.Clip[context: context, path: path, oddWrap: outline.oddWrap, exclude: exclude];
};
ClipRectangle: PUBLIC PROC [context: Context, r: Rectangle, exclude: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ClipRectangle[context: context, r: r, exclude: exclude];
};
ClipRectangleI: PUBLIC PROC [context: Context, x, y, w, h: INTEGER, exclude: BOOL ¬ FALSE] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ClipRectangleI[context: context, x: x, y: y, w: w, h: h, exclude: exclude];
};
ImagerBackdoor Implementation
SetInt: PUBLIC PROC [context: Context, key: ImagerBackdoor.IntKey, val: INT] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetInt[context, key, val];
};
SetReal: PUBLIC PROC [context: Context, key: ImagerBackdoor.RealKey, val: REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetReal[context, key, val];
};
SetT: PUBLIC PROC [context: Context, m: Transformation] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetT[context, m];
};
SetClipper: PUBLIC PROC [context: Context, clipper: ImagerBackdoor.Clipper] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SetClipper[context, clipper];
};
GetInt: PUBLIC PROC [context: Context, key: ImagerBackdoor.IntKey] RETURNS [INT] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.GetInt[context, key]];
};
GetReal: PUBLIC PROC [context: Context, key: ImagerBackdoor.RealKey] RETURNS [REAL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.GetReal[context, key]];
};
GetT: PUBLIC PROC [context: Context] RETURNS [Transformation] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.GetT[context]];
};
GetFont: PUBLIC PROC [context: Context] RETURNS [Font] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.GetFont[context]];
};
GetColor: PUBLIC PROC [context: Context] RETURNS [Color] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.GetColor[context]];
};
GetClipper: PUBLIC PROC [context: Context] RETURNS [ImagerBackdoor.Clipper] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.GetClipper[context]];
};
GetCP: PUBLIC PROC [context: Context, rounded: BOOL ¬ FALSE] RETURNS [VEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.GetCP[context: context, rounded: rounded]];
};
ViewReset: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ViewReset[context];
};
ViewTranslateI: PUBLIC PROC [context: Context, x, y: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ViewTranslateI[context, x, y]
};
ViewClip: PUBLIC PROC [context: Context, path: PathProc, oddWrap: BOOL, exclude: BOOL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ViewClip[context: context, path: path, oddWrap: oddWrap, exclude: exclude];
};
ViewClipRectangleI: PUBLIC PROC [context: Context, x, y, w, h: INTEGER, exclude: BOOL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.ViewClipRectangleI[context: context, x: x, y: y, w: w, h: h, exclude: exclude];
};
TransformPoint: PUBLIC PROC [context: Context, p: VEC, from, to: ImagerBackdoor.CoordSys] RETURNS [pT: VEC ¬ zeroVEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN [class.Transform[context: context, v: p, from: from, to: to, vec: FALSE]]
};
TransformVec: PUBLIC PROC [context: Context, v: VEC, from, to: ImagerBackdoor.CoordSys] RETURNS [vT: VEC ¬ zeroVEC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN [class.Transform[context: context, v: v, from: from, to: to, vec: TRUE]]
};
GetTransformation: PUBLIC PROC [context: Context, from, to: ImagerBackdoor.CoordSys] RETURNS [composite: Transformation ¬ NIL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN [class.GetTransformation[context: context, from: from, to: to]]
};
MoveViewRectangle: PUBLIC PROC [context: Context, width, height, fromX, fromY, toX, toY: INTEGER] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.MoveViewRectangle[context: context, width: width, height: height, fromX: fromX, fromY: fromY, toX: toX, toY: toY]
};
Visibility: TYPE ~ ImagerBackdoor.Visibility;
TestViewRectangle: PUBLIC PROC [context: Context, x, y, w, h: INTEGER] RETURNS [Visibility] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.TestViewRectangle[context: context, x: x, y: y, w: w, h: h]]
};
GetBounds: PUBLIC PROC [context: Context] RETURNS [Rectangle] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
RETURN[class.GetBounds[context: context]];
};
DoIfVisible: PUBLIC PROC [context: Context, r: Rectangle, action: PROC] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.DoIfVisible[context: context, r: r, action: action];
};
DoWithBuffer: PUBLIC PROC [context: Context, action: PROC, x, y, w, h: INTEGER, backgroundColor: Color ¬ NIL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.DoWithBuffer[context, action, x, y, w, h, backgroundColor];
};
DrawObject: PUBLIC PROC [context: Context, object: Object, position: VEC, interactive: BOOL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.DrawObject[context: context, object: object, position: position, interactive: interactive];
};
NewBitmap: PUBLIC PROC [width, height: NAT] RETURNS [SampleMap] ~ {
RETURN [ImagerSample.NewSampleMap[box: [max: [s: height, f: width]]]]
};
BitmapContext: PUBLIC PROC [bitmap: SampleMap] RETURNS [Context] ~ {
IF ImagerSample.GetBox[bitmap].min # [0, 0]
THEN {
ERROR Error[[$bounds, "The lower bounds on the bitmap for BitmapContext must be zero"]];
}
ELSE {
context: Context ~ ImagerBitmapContext.Create[deviceSpaceSize: ImagerSample.GetSize[bitmap], scanMode: [slow: down, fast: right], surfaceUnitsPerInch: [72, 72], pixelUnits: TRUE, fontCacheName: $Bitmap];
ImagerBitmapContext.SetBitmap[context: context, bitmap: bitmap];
RETURN [context]
};
};
GetBufferColorOperator: PUBLIC PROC [context: Context] RETURNS [ColorOperator] ~ {
class: Class ~ context.class;
colorOperator: ColorOperator ~ class.GetBufferColorOperator[context];
ImagerSys.CheckForAbort[];
RETURN [colorOperator]
};
AccessBuffer: PUBLIC PROC [context: Context, action: PROC [pixelMap: PixelMap], path: PathProc, oddWrap: BOOL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.AccessBuffer[context, action, path, oddWrap];
};
AccessBufferRectangle: PUBLIC PROC [context: Context, action: PROC [pixelMap: PixelMap], rectangle: Rectangle] ~ {
class: Class ~ context.class;
path: PathProc ~ {
moveTo[[rectangle.x, rectangle.y]];
lineTo[[rectangle.x+rectangle.w, rectangle.y]];
lineTo[[rectangle.x+rectangle.w, rectangle.y+rectangle.h]];
lineTo[[rectangle.x, rectangle.y+rectangle.h]];
};
ImagerSys.CheckForAbort[];
class.AccessBuffer[context, action, path, FALSE];
};
SaveBuffer: PUBLIC PROC [context: Context, id: ATOM, path: PathProc, oddWrap: BOOL] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.SaveBuffer[context, id, path, oddWrap];
};
SaveBufferRectangle: PUBLIC PROC [context: Context, id: ATOM, rectangle: Rectangle] ~ {
class: Class ~ context.class;
path: PathProc ~ {
moveTo[[rectangle.x, rectangle.y]];
lineTo[[rectangle.x+rectangle.w, rectangle.y]];
lineTo[[rectangle.x+rectangle.w, rectangle.y+rectangle.h]];
lineTo[[rectangle.x, rectangle.y+rectangle.h]];
};
ImagerSys.CheckForAbort[];
class.SaveBuffer[context, id, path, FALSE];
};
RestoreBuffer: PUBLIC PROC [context: Context, id: ATOM] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.RestoreBuffer[context, id];
};
DiscardBuffer: PUBLIC PROC [context: Context, id: ATOM] ~ {
class: Class ~ context.class;
ImagerSys.CheckForAbort[];
class.DiscardBuffer[context, id];
};
invert: PUBLIC SpecialColor ¬ ImagerColorPrivate.ColorFromStipple[word: WORD.LAST, function: [xor, null]];
MakeStipple: PUBLIC PROC [stipple: WORD ¬ WORD.LAST, xor: BOOL ¬ FALSE]
RETURNS [SpecialColor] ~ {
IF xor AND stipple=WORD.LAST THEN RETURN[invert];
RETURN[ImagerColorPrivate.ColorFromStipple[word: stipple, function: (IF xor THEN [xor, null] ELSE [null, null])]];
};
END.