ImagerImpl.mesa
Michael Plass, August 1, 1983 4:25 pm
DIRECTORY Atom, Imager, ImagerBasic, ImagerRegistration, Real, Rope, UnifiedFonts;
ImagerImpl:
CEDAR
PROGRAM
IMPORTS Atom, Real
EXPORTS Imager, ImagerRegistration
~ BEGIN
Rectangle: TYPE ~ Imager.Rectangle;
IntRectangle: TYPE ~ Imager.IntRectangle;
Pair: TYPE ~ Imager.Pair;
IntPair: TYPE ~ Imager.IntPair;
Context: TYPE ~ Imager.Context;
Transformation: TYPE ~ Imager.Transformation;
Clipper: TYPE ~ Imager.Clipper;
Visibility: TYPE ~ Imager.Visibility;
Path: TYPE ~ Imager.Path;
StrokeEnds: TYPE ~ Imager.StrokeEnds;
Color: TYPE ~ Imager.Color;
UnImplementedDevice: PUBLIC ERROR ~ CODE;
IncompatibleContexts: PUBLIC ERROR ~ CODE;
Card:
PROC [real:
REAL]
RETURNS [card:
CARDINAL] ~ {
int: INT ← Real.RoundLI[real*LAST[CARDINAL]];
card ← MAX[MIN[int, LAST[CARDINAL]], 0];
};
black: PUBLIC Color ← NEW[ImagerBasic.CIEColorRep ← [x: Card[0.3101], y: Card[0.3163], Y: Card[0]]];
white: PUBLIC Color ← NEW[ImagerBasic.CIEColorRep ← [x: Card[0.3101], y: Card[0.3163], Y: Card[1]]];
RegisterDevice:
PUBLIC
PROC [class:
REF Imager.ClassRep] ~ {
Atom.PutProp[class.deviceType, imagerRegistrationKey, class];
};
imagerRegistrationKey: REF TEXT ← "Imager Device Class ";
Create:
PUBLIC
PROC [deviceType:
ATOM, name: Rope.
ROPE]
RETURNS [context: Context] ~ {
WITH Atom.GetProp[deviceType, imagerRegistrationKey]
SELECT
FROM
class:
REF Imager.ClassRep => {
context ← NEW[Imager.ContextRep ← [class: class, data: NIL]];
class.Init[context, name, Imager.nullBounds];
};
ENDCASE => ERROR UnImplementedDevice;
};
CreateBuffer:
PUBLIC
PROC [deviceType:
ATOM, box: IntRectangle]
RETURNS [context: Context] ~ {
WITH Atom.GetProp[deviceType, imagerRegistrationKey]
SELECT
FROM
class:
REF Imager.ClassRep => {
context ← NEW[Imager.ContextRep ← [class: class, data: NIL]];
class.Init[context, NIL, box];
};
ENDCASE => ERROR UnImplementedDevice;
};
END.