IIImpl.mesa
Copyright © 1984, 1985, 1986 by Xerox Corporation. All rights reserved.
Michael Plass, December 10, 1986 4:22:34 pm PST
Doug Wyatt, March 20, 1986 2:39:42 pm PST
DIRECTORY
Atom USING [PropList],
Basics USING [bitsPerWord, LongMult],
II USING [Box, Color, ColorOperator, ConstantColor, Context, ErrorDesc, Font, Object, Outline, PathProc, PixelArray, PixelMap, Rectangle, ROPE, SampleMap, ScanMode, SpecialColor, StrokeEnd, StrokeJoint, Trajectory, Transformation, VEC, XChar, XStringProc, zeroVEC],
IIBackdoor USING [Clipper, CoordSys, IntKey, RealKey, Visibility],
IIColor USING [ColorFromGray, ColorFromStipple],
IIFont USING [FindScaled, MapRope],
IIPath USING [MapOutline, MapTrajectory],
IIPrivate USING [Class, ClassRep],
IISample USING [ObtainUnsafeDescriptor, ReleaseDescriptor],
ImmutablePropList USING [Get, Put],
Process USING [CheckForAbort],
SF USING [Vec];
IIImpl: CEDAR PROGRAM
IMPORTS Basics, IIColor, IIFont, IIPath, IISample, ImmutablePropList, Process
EXPORTS II, IIBackdoor
~ BEGIN OPEN II, IIBackdoor;
Class: TYPE ~ IIPrivate.Class;
ClassRep: PUBLIC TYPE ~ IIPrivate.ClassRep; -- export to II.ClassRep
Error: PUBLIC ERROR [error: ErrorDesc] ~ CODE;
GetClass: PUBLIC PROC [context: Context] RETURNS [ATOM] ~ {
class: Class ~ context.class;
RETURN[class.type];
};
GetProp: PUBLIC PROC [context: Context, key: REF] RETURNS [val: REF] ~ {
RETURN[ImmutablePropList.Get[context.propList, key]];
};
PutProp: PUBLIC PROC [context: Context, key: REF, val: REF] ~ {
context.propList ← ImmutablePropList.Put[context.propList, key, val];
};
DoSave: PUBLIC PROC [context: Context, action: PROC] ~ {
class: Class ~ context.class;
propList: Atom.PropList ~ context.propList;
class.DoSave[context: context, action: action, all: FALSE !
UNWIND
=> context.propList ← propList];
context.propList ← propList;
};
DoSaveAll: PUBLIC PROC [context: Context, action: PROC] ~ {
class: Class ~ context.class;
propList: Atom.PropList ~ context.propList;
class.DoSave[context: context, action: action, all: TRUE !
UNWIND
=> context.propList ← propList];
context.propList ← propList;
};
ConcatT: PUBLIC PROC [context: Context, m: Transformation] ~ {
class: Class ~ context.class;
class.ConcatT[context: context, m: m];
};
ScaleT: PUBLIC PROC [context: Context, s: REAL] ~ {
class: Class ~ context.class;
class.Scale2T[context: context, s: [s, s]];
};
Scale2T: PUBLIC PROC [context: Context, s: VEC] ~ {
class: Class ~ context.class;
class.Scale2T[context: context, s: s];
};
RotateT: PUBLIC PROC [context: Context, a: REAL] ~ {
class: Class ~ context.class;
class.RotateT[context: context, a: a];
};
TranslateT: PUBLIC PROC [context: Context, t: VEC] ~ {
class: Class ~ context.class;
class.TranslateT[context: context, t: t];
};
Move: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
class.Move[context: context, rounded: FALSE];
};
Trans: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
class.Move[context: context, rounded: TRUE];
};
SetXY: PUBLIC PROC [context: Context, p: VEC] ~ {
class: Class ~ context.class;
class.SetXY[context: context, p: p];
};
SetXYI: PUBLIC PROC [context: Context, x, y: INTEGER] ~ {
class: Class ~ context.class;
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;
class.SetXYRel[context: context, v: [x, y]];
};
SetXRel: PUBLIC PROC [context: Context, x: REAL] ~ {
class: Class ~ context.class;
class.SetXYRel[context: context, v: [x, 0]];
};
SetXRelI: PUBLIC PROC [context: Context, x: INTEGER] ~ {
class: Class ~ context.class;
class.SetXYRel[context: context, v: [x, 0]];
};
SetYRel: PUBLIC PROC [context: Context, y: REAL] ~ {
class: Class ~ context.class;
class.SetXYRel[context: context, v: [0, y]];
};
SetYRelI: PUBLIC PROC [context: Context, y: INTEGER] ~ {
class: Class ~ context.class;
class.SetXYRel[context: context, v: [0, y]];
};
FindFontScaled: PUBLIC PROC [name: ROPE, s: REAL] RETURNS [Font] ~ {
RETURN [IIFont.FindScaled[name, s]]
};
SetFont: PUBLIC PROC [context: Context, font: Font] ~ {
class: Class ~ context.class;
class.SetFont[context: context, font: font];
};
SetAmplifySpace: PUBLIC PROC [context: Context, amplifySpace: REAL] ~ {
class: Class ~ context.class;
class.SetReal[context: context, key: $amplifySpace, val: amplifySpace];
};
Show: PUBLIC PROC [context: Context, string: XStringProc, xrel: BOOLFALSE] ~ {
class: Class ~ context.class;
Process.CheckForAbort[];
class.Show[context: context, string: string, xrel: xrel];
};
ShowAndFixedXRel: PUBLIC PROC [context: Context, string: XStringProc, x: REAL] ~ {
class: Class ~ context.class;
Process.CheckForAbort[];
class.ShowAndFixedXRel[context, string, x];
};
ShowChar: PUBLIC PROC [context: Context, char: CHAR] ~ {
string: XStringProc ~ { charAction[[set: 0, code: ORD[char]]] };
class: Class ~ context.class;
Process.CheckForAbort[];
class.Show[context: context, string: string, xrel: FALSE];
};
ShowXChar: PUBLIC PROC [context: Context, char: XChar] ~ {
string: XStringProc ~ { charAction[char] };
class: Class ~ context.class;
Process.CheckForAbort[];
class.Show[context: context, string: string, xrel: FALSE];
};
ShowRope: PUBLIC PROC [context: Context, rope: ROPE,
start: INT ← 0, len: INTINT.LAST, xrel: BOOLFALSE] ~ {
string: XStringProc ~ { IIFont.MapRope[
rope: rope, start: start, len: len, charAction: charAction] };
class: Class ~ context.class;
Process.CheckForAbort[];
class.Show[context: context, string: string, xrel: xrel];
};
ShowText: PUBLIC PROC [context: Context, text: REF READONLY TEXT,
start: NAT ← 0, len: NATNAT.LAST, xrel: BOOLFALSE] ~ {
class: Class ~ context.class;
Process.CheckForAbort[];
class.ShowText[context: context, text: text, start: start, len: len, xrel: xrel];
};
StartUnderline: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
class.StartUnderline[context: context];
};
MaskUnderline: PUBLIC PROC [context: Context, dy, h: REAL] ~ {
class: Class ~ context.class;
class.MaskUnderline[context: context, dy: dy, h: h];
};
MaskUnderlineI: PUBLIC PROC [context: Context, dy, h: INTEGER] ~ {
class: Class ~ context.class;
class.MaskUnderline[context: context, dy: dy, h: h];
};
CorrectMask: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
class.CorrectMask[context: context];
};
CorrectSpace: PUBLIC PROC [context: Context, v: VEC] ~ {
class: Class ~ context.class;
class.CorrectSpace[context: context, v: v];
};
Space: PUBLIC PROC [context: Context, x: REAL] ~ {
class: Class ~ context.class;
class.Space[context: context, x: x];
};
SpaceI: PUBLIC PROC [context: Context, x: INTEGER] ~ {
class: Class ~ context.class;
class.Space[context: context, x: x];
};
SetCorrectMeasure: PUBLIC PROC [context: Context, v: VEC] ~ {
class: Class ~ context.class;
class.SetCorrectMeasure[context: context, v: v];
};
SetCorrectTolerance: PUBLIC PROC [context: Context, v: VEC] ~ {
class: Class ~ context.class;
class.SetCorrectTolerance[context: context, v: v];
};
SetCorrectShrink: PUBLIC PROC [context: Context, correctShrink: REAL] ~ {
class: Class ~ context.class;
class.SetReal[context: context, key: $correctShrink, val: correctShrink];
};
Correct: PUBLIC PROC [context: Context, action: PROC] ~ {
class: Class ~ context.class;
class.Correct[context: context, action: action];
};
DontCorrect: PUBLIC PROC [context: Context, action: PROC, saveCP: BOOLFALSE] ~ {
class: Class ~ context.class;
class.DontCorrect[context: context, action: action, saveCP: saveCP];
};
SetColor: PUBLIC PROC [context: Context, color: Color] ~ {
class: Class ~ context.class;
class.SetColor[context: context, color: color];
};
black: PUBLIC ConstantColor ← IIColor.ColorFromGray[1];
white: PUBLIC ConstantColor ← IIColor.ColorFromGray[0];
MakeGray: PUBLIC PROC [f: REAL] RETURNS [ConstantColor] ~ {
IF f>=1.0 THEN RETURN[black];
IF f<=0.0 THEN RETURN[white];
RETURN[IIColor.ColorFromGray[f]];
};
SetGray: PUBLIC PROC [context: Context, f: REAL] ~ {
class: Class ~ context.class;
class.SetGray[context: context, f: f];
};
SetSampledColor: PUBLIC PROC [context: Context, pa: PixelArray,
m: Transformation, colorOperator: ColorOperator] ~ {
class: Class ~ context.class;
class.SetSampledColor[context: context, pa: pa, m: m, colorOperator: colorOperator];
};
SetSampledBlack: PUBLIC PROC [context: Context, pa: PixelArray,
m: Transformation, clear: BOOLFALSE] ~ {
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;
class.SetInt[context: context, key: $priorityImportant, val: IF priorityImportant THEN 1 ELSE 0];
};
SetNoImage: PUBLIC PROC [context: Context, noImage: BOOL] ~ {
class: Class ~ context.class;
class.SetInt[context: context, key: $noImage, val: IF noImage THEN 1 ELSE 0];
};
MaskFill: PUBLIC PROC [context: Context, path: PathProc, oddWrap: BOOLFALSE] ~ {
class: Class ~ context.class;
class.MaskFill[context: context, path: path, oddWrap: oddWrap];
};
MaskFillTrajectory: PUBLIC PROC [context: Context, trajectory: Trajectory, oddWrap: BOOLFALSE] ~ {
class: Class ~ context.class;
path: PathProc ~ { IIPath.MapTrajectory[trajectory: trajectory,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo] };
class.MaskFill[context: context, path: path, oddWrap: oddWrap];
};
MaskFillOutline: PUBLIC PROC [context: Context, outline: Outline] ~ {
class: Class ~ context.class;
path: PathProc ~ { IIPath.MapOutline[outline: outline,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo] };
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;
class.MaskRectangleI[context: context, x: x, y: y, w: w, h: h];
};
MaskBox: PUBLIC PROC [context: Context, box: Box] ~ {
class: Class ~ context.class;
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;
class.SetReal[context: context, key: $strokeWidth, val: strokeWidth];
};
SetStrokeEnd: PUBLIC PROC [context: Context, strokeEnd: StrokeEnd] ~ {
class: Class ~ context.class;
class.SetInt[context: context, key: $strokeEnd, val: ORD[strokeEnd]];
};
SetStrokeJoint: PUBLIC PROC [context: Context, strokeJoint: StrokeJoint] ~ {
class: Class ~ context.class;
class.SetInt[context: context, key: $strokeJoint, val: ORD[strokeJoint]];
};
MaskStroke: PUBLIC PROC [context: Context, path: PathProc,
closed: BOOLFALSE] ~ {
class: Class ~ context.class;
class.MaskStroke[context: context, path: path, closed: closed];
};
MaskStrokeTrajectory: PUBLIC PROC [context: Context, trajectory: Trajectory,
closed: BOOLFALSE] ~ {
class: Class ~ context.class;
path: PathProc ~ { IIPath.MapTrajectory[trajectory: trajectory,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo] };
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;
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 ~ { IIPath.MapTrajectory[trajectory: trajectory,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo] };
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;
class.MaskVector[context: context, p1: [x1, y1], p2: [x2, y2]];
};
MaskPixel: PUBLIC PROC [context: Context, pa: PixelArray] ~ {
class: Class ~ context.class;
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 ~ IISample.ObtainUnsafeDescriptor[
size: [sSize, fSize],
bitsPerSample: 1,
bitsPerLine: wordsPerLine*Basics.bitsPerWord,
base: [word: base, bit: 0],
ref: NIL,
words: Basics.LongMult[sMin+sSize, wordsPerLine],
rawMin: [sMin, fMin]
];
MaskBitmap[context: context, bitmap: bitmap, referencePoint: [0, 0], scanMode: [slow: down, fast: right], position: [tx, ty]];
IISample.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 ~ IISample.ObtainUnsafeDescriptor[
size: [sSize, fSize],
bitsPerSample: 1,
bitsPerLine: wordsPerLine*Basics.bitsPerWord,
base: [word: base, bit: 0],
ref: NIL,
words: Basics.LongMult[sMin+sSize, wordsPerLine],
rawMin: [sMin, fMin]
];
DrawBitmap[context: context, bitmap: bitmap, referencePoint: [0, 0], scanMode: [slow: down, fast: right], position: [tx, ty]];
IISample.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;
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;
class.DrawPixels[context: context, pixelMap: pixelMap, colorOperator: colorOperator, referencePoint: referencePoint, scanMode: scanMode, position: position];
};
Clip: PUBLIC PROC [context: Context, path: PathProc, oddWrap, exclude: BOOLFALSE] ~ {
class: Class ~ context.class;
class.Clip[context: context, path: path, oddWrap: oddWrap, exclude: exclude];
};
ClipOutline: PUBLIC PROC [context: Context, outline: Outline, exclude: BOOLFALSE] ~ {
class: Class ~ context.class;
path: PathProc ~ { IIPath.MapOutline[outline: outline,
moveTo: moveTo, lineTo: lineTo, curveTo: curveTo, conicTo: conicTo, arcTo: arcTo] };
class.Clip[context: context, path: path, oddWrap: outline.oddWrap, exclude: exclude];
};
ClipRectangle: PUBLIC PROC [context: Context, r: Rectangle, exclude: BOOLFALSE] ~ {
class: Class ~ context.class;
class.ClipRectangle[context: context, r: r, exclude: exclude];
};
ClipRectangleI: PUBLIC PROC [context: Context, x, y, w, h: INTEGER, exclude: BOOLFALSE] ~ {
class: Class ~ context.class;
class.ClipRectangleI[context: context, x: x, y: y, w: w, h: h, exclude: exclude];
};
SetInt: PUBLIC PROC [context: Context, key: IntKey, val: INT] ~ {
class: Class ~ context.class;
class.SetInt[context, key, val];
};
SetReal: PUBLIC PROC [context: Context, key: RealKey, val: REAL] ~ {
class: Class ~ context.class;
class.SetReal[context, key, val];
};
SetT: PUBLIC PROC [context: Context, m: Transformation] ~ {
class: Class ~ context.class;
class.SetT[context, m];
};
SetClipper: PUBLIC PROC [context: Context, clipper: Clipper] ~ {
class: Class ~ context.class;
class.SetClipper[context, clipper];
};
GetInt: PUBLIC PROC [context: Context, key: IntKey] RETURNS [INT] ~ {
class: Class ~ context.class;
RETURN[class.GetInt[context, key]];
};
GetReal: PUBLIC PROC [context: Context, key: RealKey] RETURNS [REAL] ~ {
class: Class ~ context.class;
RETURN[class.GetReal[context, key]];
};
GetT: PUBLIC PROC [context: Context] RETURNS [Transformation] ~ {
class: Class ~ context.class;
RETURN[class.GetT[context]];
};
GetFont: PUBLIC PROC [context: Context] RETURNS [Font] ~ {
class: Class ~ context.class;
RETURN[class.GetFont[context]];
};
GetColor: PUBLIC PROC [context: Context] RETURNS [Color] ~ {
class: Class ~ context.class;
RETURN[class.GetColor[context]];
};
GetClipper: PUBLIC PROC [context: Context] RETURNS [Clipper] ~ {
class: Class ~ context.class;
RETURN[class.GetClipper[context]];
};
GetCP: PUBLIC PROC [context: Context, rounded: BOOLFALSE] RETURNS [VEC] ~ {
class: Class ~ context.class;
RETURN[class.GetCP[context: context, rounded: rounded]];
};
ViewReset: PUBLIC PROC [context: Context] ~ {
class: Class ~ context.class;
class.ViewReset[context];
};
ViewTranslateI: PUBLIC PROC [context: Context, x, y: INTEGER] ~ {
class: Class ~ context.class;
class.ViewTranslateI[context, x, y]
};
ViewClip: PUBLIC PROC [context: Context, path: PathProc, oddWrap: BOOL, exclude: BOOL] ~ {
class: Class ~ context.class;
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;
class.ViewClipRectangleI[context: context, x: x, y: y, w: w, h: h, exclude: exclude];
};
TransformPoint: PUBLIC PROC [context: Context, p: VEC, from, to: CoordSys] RETURNS [pT: VEC ← zeroVEC] ~ {
class: Class ~ context.class;
RETURN [class.Transform[context: context, v: p, from: from, to: to, vec: FALSE]]
};
TransformVec: PUBLIC PROC [context: Context, v: VEC, from, to: CoordSys] RETURNS [vT: VEC ← zeroVEC] ~ {
class: Class ~ context.class;
RETURN [class.Transform[context: context, v: v, from: from, to: to, vec: TRUE]]
};
GetTransformation: PUBLIC PROC [context: Context, from, to: CoordSys] RETURNS [composite: Transformation ← NIL] ~ {
class: Class ~ context.class;
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;
class.MoveViewRectangle[context: context, width: width, height: height, fromX: fromX, fromY: fromY, toX: toX, toY: toY]
};
Visibility: TYPE ~ IIBackdoor.Visibility;
TestViewRectangle: PUBLIC PROC [context: Context, x, y, w, h: INTEGER]
RETURNS
[Visibility] ~ {
class: Class ~ context.class;
RETURN[class.TestViewRectangle[context: context, x: x, y: y, w: w, h: h]]
};
GetBounds: PUBLIC PROC [context: Context] RETURNS [Rectangle] ~ {
class: Class ~ context.class;
RETURN[class.GetBounds[context: context]];
};
DoIfVisible: PUBLIC PROC [context: Context, r: Rectangle, action: PROC] ~ {
class: Class ~ context.class;
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;
class.DoWithBuffer[context, action, x, y, w, h, backgroundColor];
};
DrawObject: PUBLIC PROC [context: Context, object: Object, position: VEC, interactive: BOOL] ~ {
class: Class ~ context.class;
class.DrawObject[context: context, object: object, position: position, interactive: interactive];
};
invert: PUBLIC SpecialColor ← IIColor.ColorFromStipple[
word: WORD.LAST, function: [xor, null]];
MakeStipple: PUBLIC PROC [stipple: WORDWORD.LAST, xor: BOOLFALSE]
RETURNS [SpecialColor] ~ {
IF xor AND stipple=WORD.LAST THEN RETURN[invert];
RETURN[IIColor.ColorFromStipple[
word: stipple, function: (IF xor THEN [xor, null] ELSE [null, null])]];
};
BitmapContext: PUBLIC PROC [bitmap: Bitmap] RETURNS [Context] ~ {
refRep: REF IIPixelMap.PixelMapRep ~ NEW[IIPixelMap.PixelMapRep ← [
ref: bitmap.ref, pointer: bitmap.base, words: LONG[bitmap.wordsPerLine]*bitmap.height,
lgBitsPerPixel: 0, rast: bitmap.wordsPerLine, lines: bitmap.height
]];
frame: IIPixelMap.PixelMap ~ [
sOrigin: 0, fOrigin: 0, sMin: 0, fMin: 0,
sSize: bitmap.height, fSize: bitmap.width, refRep: refRep
];
RETURN[IIRaster.Create[IIRaster.NewBitmapDevice[frame], TRUE]];
};
END.