imagerProcs:
REF GraphicsProcs ~
NEW[GraphicsProcs ← [
GetCP: ImagerGetCP,
SetCP: ImagerSetCP,
DrawTo: ImagerDrawTo,
DrawStroke: ImagerDrawStroke,
DrawArea: ImagerDrawArea,
DrawBox: ImagerDrawBox,
DrawImage: ImagerDrawImage,
Translate: ImagerTranslate,
Concat: ImagerConcat,
WorldToUser: ImagerWorldToUser,
UserToWorld: ImagerUserToWorld,
SetColor: ImagerSetColor,
GetColor: ImagerGetColor,
SetPaintMode: ImagerSetPaintMode,
SetFat: ImagerSetFat,
GetDefaultFont: ImagerGetDefaultFont,
SetDefaultFont: ImagerSetDefaultFont,
DrawChars: ImagerDrawChars,
ClipArea: ImagerClipArea,
ClipBox: ImagerClipBox,
IsPointVisible: ImagerIsPointVisible,
IsRectangular: ImagerIsRectangular,
GetBounds: ImagerGetBounds,
Visible: ImagerVisible,
Save: ImagerSave,
Restore: ImagerRestore,
DrawBits: ImagerDrawBits,
UserToDevice: ImagerUserToDevice,
DeviceToUser: ImagerDeviceToUser,
GetYMode: ImagerGetYMode,
SetYMode: ImagerSetYMode,
DrawTexturedBox: ImagerDrawTexturedBox,
Disable: ImagerDisable,
MoveDeviceRectangle: ImagerMoveDeviceRectangle
]];
Path Stuff
Path: TYPE ~ REF PathRep;
PathRep: PUBLIC TYPE ~ RECORD[list: LIST OF Imager.Trajectory];
NewPath:
PUBLIC
PROC[size:
INT ← 0]
RETURNS[Path] = {
RETURN[NEW[PathRep ← [list: NIL]]];
};
LastPoint:
PUBLIC
PROC[self: Path]
RETURNS[x, y:
REAL] = {
p: Imager.Pair ← [0, 0];
IF self.list#NIL THEN p ← Imager.LastPoint[self.list.first];
RETURN[p.x, p.y];
};
FlushPath:
PUBLIC
PROC[self: Path] = {
self.list ← NIL;
};
MoveTo:
PUBLIC
PROC[self: Path, x, y:
REAL, flush:
BOOLEAN ←
TRUE] = {
IF flush THEN self.list ← NIL;
self.list ← CONS[Imager.MoveTo[x, y], self.list];
};
LineTo:
PUBLIC
PROC[self: Path, x, y:
REAL] = {
IF self.list=NIL THEN MoveTo[self, 0, 0];
self.list.first ← self.list.first.LineTo[x, y];
};
CurveTo:
PUBLIC
PROC[self: Path, x1, y1, x2, y2, x3, y3:
REAL] = {
IF self.list=NIL THEN MoveTo[self, 0, 0];
self.list.first ← self.list.first.CurveTo[x1, y1, x2, y2, x3, y3];
};
Rectangle:
PUBLIC
PROC[self: Path, x0, y0, x1, y1:
REAL] = {
t: Imager.Trajectory ~ Imager.MoveTo[x0, y0].LineToX[x1].LineToY[y1].LineToX[x0];
self.list ← CONS[t, self.list];
};
Context procedures
ImagerGetCP:
PROC[self: Context, rounded:
BOOLEAN]
RETURNS[x,y:
REAL] ~ {
ERROR Warning[notImplemented];
};
ImagerSetCP:
PROC[self: Context, x,y:
REAL, rel:
BOOLEAN] ~ {
WITH self.data
SELECT
FROM
context: Imager.Context => {
IF rel THEN context.SetXYRel[x, y] ELSE context.SetXY[x, y];
};
ENDCASE => ERROR Error[bug];
};
ImagerDrawTo:
PROC[self: Context, x,y:
REAL, rel:
BOOLEAN] ~ {
SIGNAL Warning[notImplemented];
};
ImagerDrawStroke:
PROC[self: Context, path: Path,
width: REAL, closed: BOOLEAN, ends: StrokeEnds] ~ {
WITH self.data
SELECT
FROM
context: Imager.Context => {
context.SetStrokeWidth[width];
context.SetStrokeEnd[
SELECT ends
FROM
butt => butt, square => square, round => round, ENDCASE => ERROR];
FOR list:
LIST
OF Imager.Trajectory ← path.list, list.rest
UNTIL list=
NIL
DO
IF closed THEN context.MaskStrokeClosed[list.first]
ELSE context.MaskStroke[list.first];
ENDLOOP;
};
ENDCASE => ERROR Error[bug];
};
ImagerDrawArea:
PROC[self: Context, path: Path, parityFill:
BOOLEAN] ~ {
WITH self.data
SELECT
FROM
context: Imager.Context => {
IF parityFill THEN SIGNAL Warning[notImplemented];
IF path.list#NIL THEN context.MaskFill[path.list];
};
ENDCASE => ERROR Error[bug];
};
ImagerDrawBox:
PROC[self: Context, box: Box] ~ {
WITH self.data
SELECT
FROM
context: Imager.Context => {
context.MaskRectangle[
x: box.xmin, y: box.ymin, w: box.xmax-box.xmin, h: box.ymax-box.ymin];
};
ENDCASE => ERROR Error[bug];
};
ImagerDrawImage:
PROC[self: Context, image: ImageRef, raw:
BOOLEAN] ~ {
SIGNAL Warning[notImplemented];
};
ImagerTranslate:
PROC[self: Context, tx,ty:
REAL, round:
BOOLEAN] ~ {
WITH self.data
SELECT
FROM
context: Imager.Context => {
IF round THEN SIGNAL Warning[notImplemented];
context.TranslateT[tx, ty];
};
ENDCASE => ERROR Error[bug];
};
ImagerConcat:
PROC[self: Context, m11,m12,m21,m22:
REAL] ~ {
WITH self.data
SELECT
FROM
context: Imager.Context => {
m: Imager.Transformation ~ Imager.MakeT[[m11, m21, 0, m12, m22, 0]];
context.ConcatT[m];
};
ENDCASE => ERROR Error[bug];
};
ImagerWorldToUser:
PROC[self: Context, wx,wy:
REAL]
RETURNS[x,y:
REAL] ~ {
SIGNAL Warning[notImplemented];
};
ImagerUserToWorld:
PROC[self: Context, x,y:
REAL]
RETURNS[wx,wy:
REAL] ~ {
SIGNAL Warning[notImplemented];
};
ImagerSetColor:
PROC[self: Context, color: Color] ~ {
SIGNAL Warning[notImplemented];
};
ImagerGetColor:
PROC[self: Context]
RETURNS[Color] ~ {
ERROR Warning[notImplemented];
};
ImagerSetPaintMode:
PROC[self: Context, mode: PaintMode]
RETURNS[PaintMode] ~ {
ERROR Warning[notImplemented];
};
ImagerSetFat:
PROC[self: Context, fat:
BOOLEAN]
RETURNS[
BOOLEAN] ~ {
ERROR Warning[notImplemented];
};
ImagerGetDefaultFont:
PROC[self: Context]
RETURNS[FontRef] ~ {
ERROR Warning[notImplemented];
};
ImagerSetDefaultFont:
PROC[self: Context, font: FontRef] ~ {
SIGNAL Warning[notImplemented];
};
ImagerDrawChars:
PROC[self: Context, font: FontRef,
map: PROC[PROC[CHAR] RETURNS[BOOL]]] ~ {
SIGNAL Warning[notImplemented];
};
ImagerClipArea:
PROC[self: Context, path: Path, parityFill:
BOOLEAN, exclude:
BOOLEAN] ~ {
WITH self.data
SELECT
FROM
context: Imager.Context => {
IF parityFill THEN SIGNAL Warning[notImplemented];
IF path.list=NIL THEN RETURN;
IF exclude THEN context.ExcludeOutline[path.list]
ELSE context.ClipOutline[path.list];
};
ENDCASE => ERROR Error[bug];
};
ImagerClipBox:
PROC[self: Context, box: Box, exclude:
BOOLEAN] ~ {
WITH self.data
SELECT
FROM
context: Imager.Context => {
IF exclude
THEN context.ExcludeRectangle[
x: box.xmin, y: box.ymin, w: box.xmax-box.xmin, h: box.ymax-box.ymin]
ELSE context.ClipRectangle[
x: box.xmin, y: box.ymin, w: box.xmax-box.xmin, h: box.ymax-box.ymin];
};
ENDCASE => ERROR Error[bug];
};
ImagerIsPointVisible:
PROC[self: Context, x,y:
REAL]
RETURNS[
BOOLEAN] ~ {
ERROR Warning[notImplemented];
};
ImagerIsRectangular:
PROC[self: Context]
RETURNS[
BOOLEAN] ~ {
ERROR Warning[notImplemented];
};
ImagerGetBounds:
PROC[self: Context]
RETURNS[Box] ~ {
ERROR Warning[notImplemented];
};
ImagerVisible:
PROC[self: Context]
RETURNS[
BOOLEAN] ~ {
ERROR Warning[notImplemented];
};
ImagerSave:
PROC[self: Context]
RETURNS[Mark] ~ {
ERROR Warning[notImplemented];
};
ImagerRestore:
PROC[self: Context, mark: Mark] ~ {
ERROR Warning[notImplemented];
};
ImagerDrawBits:
UNSAFE
PROC[self: Context,
base: LONG POINTER, raster: CARDINAL, bitsPerPixel: [0..16),
x, y, w, h: CARDINAL, xorigin, yorigin: INTEGER] ~ {
SIGNAL Warning[notImplemented];
};
ImagerUserToDevice:
PROC[self: Context, x, y:
REAL, rel:
BOOLEAN]
RETURNS[tx, ty:
REAL] ~ {
ERROR Warning[notImplemented];
};
ImagerDeviceToUser:
PROC[self: Context, tx, ty:
REAL, rel:
BOOLEAN]
RETURNS[x, y:
REAL] ~ {
ERROR Warning[notImplemented];
};
ImagerGetYMode:
PROC[self: Context]
RETURNS[GraphicsBasic.YMode] ~ {
ERROR Warning[notImplemented];
};
ImagerSetYMode:
PROC[self: Context, mode: GraphicsBasic.YMode] ~ {
ERROR Warning[notImplemented];
};
ImagerDrawTexturedBox:
PROC[self: Context, box: Box, texture: GraphicsBasic.Texture] ~ {
ERROR Warning[notImplemented];
};
ImagerDisable:
PROC[self: Context] ~ {
ERROR Warning[notImplemented];
};
ImagerMoveDeviceRectangle:
PROC[self: Context, width, height, fromX, fromY, toX, toY:
NAT] ~ {
ERROR Warning[notImplemented];
};