ImagerUtilsImpl.mesa
Copyright © 1984 Xerox Corporation. All rights reserved.
Doug Wyatt, October 8, 1984 4:55:13 pm PDT
DIRECTORY
Imager USING [Context],
ImagerPath USING [PathProc],
ImagerUtils USING [],
Vector2 USING [VEC];
ImagerUtilsImpl: CEDAR PROGRAM
EXPORTS ImagerUtils
VEC: TYPE ~ Vector2.VEC;
PathProc: TYPE ~ ImagerPath.PathProc;
Context: TYPE ~ Imager.Context;
MaskRectangleViaMaskFill:
PUBLIC
PROC[
context: Context, x, y, w, h: REAL] ~ {
rectangle: PathProc ~ {
moveTo[[x, y]]; lineTo[[x+w, y]]; lineTo[[x+w, y+h]]; lineTo[[x, y+h]];
};
context.class.MaskFill[context, rectangle, NIL, FALSE];
};
MaskRectangleIViaMaskFill:
PUBLIC
PROC[
context: Context, x, y, w, h: INTEGER] ~ {
rectangle: PathProc ~ {
moveTo[[x, y]]; lineTo[[x+w, y]]; lineTo[[x+w, y+h]]; lineTo[[x, y+h]];
};
context.class.MaskFill[context, rectangle, NIL, FALSE];
};
MaskRectangleIViaMaskRectangle:
PUBLIC
PROC[
context: Context, x, y, w, h: INTEGER] ~ {
context.class.MaskRectangle[context, x, y, w, h];
};
MaskVectorViaMaskStroke:
PUBLIC
PROC[
context: Context, p1, p2: VEC] ~ {
vector: PathProc ~ { moveTo[p1]; lineTo[p2] };
context.class.MaskStroke[context, vector, NIL, FALSE];
};
MaskVectorIViaMaskStroke:
PUBLIC
PROC[
context: Context, x1, y1, x2, y2: INTEGER] ~ {
vector: PathProc ~ { moveTo[[x1, y1]]; lineTo[[x2, y2]] };
context.class.MaskStroke[context, vector, NIL, FALSE];
};
MaskVectorIViaMaskVector:
PUBLIC
PROC[
context: Context, x1, y1, x2, y2: INTEGER] ~ {
context.class.MaskVector[context, [x1, y1], [x2, y2]];
};
MaskUnderlineIViaMaskUnderline:
PUBLIC
PROC[
context: Context, dy, h: INTEGER] ~ {
context.class.MaskUnderline[context, dy, h];
};
ClipRectangleViaClipOutline:
PUBLIC
PROC[
context: Context, x, y, w, h: REAL, exclude: BOOL] ~ {
rectangle: PathProc ~ {
moveTo[[x, y]]; lineTo[[x+w, y]]; lineTo[[x+w, y+h]]; lineTo[[x, y+h]];
};
context.class.ClipOutline[context, rectangle, NIL, exclude];
};
ClipRectangleIViaClipOutline:
PUBLIC
PROC[
context: Context, x, y, w, h: INTEGER, exclude: BOOL] ~ {
rectangle: PathProc ~ {
moveTo[[x, y]]; lineTo[[x+w, y]]; lineTo[[x+w, y+h]]; lineTo[[x, y+h]];
};
context.class.ClipOutline[context, rectangle, NIL, exclude];
};
ClipRectangleIViaClipRectangle:
PUBLIC
PROC[
context: Context, x, y, w, h: INTEGER, exclude: BOOL] ~ {
context.class.ClipRectangle[context, x, y, w, h, exclude];
};
ShowCharViaShowText: PUBLIC PROC[
context: Context, char: CHAR, set: CARDINAL] ~ {
text: REF TEXT ~ RefText.ObtainScratch[1];
text[0] ← char; text.length ← 1;
context.class.ShowText[context: context, text: text, start: 0, len: 1, set: set];
RefText.ReleaseScratch[text];
};
ShowTextViaShowChar: PUBLIC PROC[
context: Context, text: REF READONLY TEXT, start, len: NAT, set: CARDINAL] ~ {
rem: NAT ~ text.length-start;
state: {run, escape, escape2, extended, extended2} ← run;
offset: BYTE ← set;
FOR i: NAT IN[start..start+MIN[rem, len]) DO
char: CHAR ~ text[i];
SELECT state FROM
run => IF char='\377 THEN state ← escape
ELSE context.class.ShowChar[context, char, offset];
escape => IF char='\377 THEN state ← escape2
ELSE { offset ← ORD[char]; state ← run };
escape2 => IF char='\000 THEN state ← extended ELSE ERROR;
extended => IF char='\377 THEN state ← escape
ELSE { offset ← ORD[char]; state ← extended2 };
extended2 => { context.class.ShowChar[context, char, offset]; state ← extended };
ENDCASE => ERROR;
ENDLOOP;
};
SpaceIViaSpace:
PUBLIC
PROC[
context: Context, x: INTEGER] ~ {
context.class.Space[context, x];
};
END.