GGParseOutImpl.mesa
Last edited by Bier, July 17, 1986 10:19:31 pm PDT
Copyright © 1986 by Xerox Corporation. All rights reserved.
Contents: Routines which turn various Gargoyle data structures into Rope.ROPEs and write them onto a file stream.
Pier, October 29, 1986 7:57:38 pm PST
DIRECTORY
GGBasicTypes, GGParseOut, Imager, ImagerColor, ImagerColorPrivate, ImagerTransformation, IO, Rope;
GGParseOutImpl: CEDAR PROGRAM
IMPORTS ImagerColorPrivate, IO
EXPORTS GGParseOut = BEGIN
Color: TYPE = Imager.Color;
Point: TYPE = GGBasicTypes.Point;
StrokeEnd: TYPE = Imager.StrokeEnd;
WriteColor: PUBLIC PROC [f: IO.STREAM, color: Color] = {
r, g, b: REAL;
noColor: BOOL ← color=NIL;
IF noColor THEN f.PutRope["none"]
ELSE {
cc: ImagerColor.ConstantColor ← NARROW[color];
r ← ImagerColorPrivate.ComponentFromColor[cc, $Red];
g ← ImagerColorPrivate.ComponentFromColor[cc, $Green];
b ← ImagerColorPrivate.ComponentFromColor[cc, $Blue];
f.PutF["[%g,%g,%g]",[real[r]], [real[g]], [real[b]]];
};
};
WriteStrokeEnd: PUBLIC PROC [f: IO.STREAM, lineEnds: StrokeEnd] = {
rope: Rope.ROPE;
SELECT lineEnds FROM
square => rope ← "square";
butt => rope ← "butt";
round => rope ← "round";
ENDCASE => ERROR;
f.PutRope[rope];
};
WritePoint: PUBLIC PROC [f: IO.STREAM, point: Point] = {
f.PutF["[%g,%g]", [real[point.x]], [real[point.y]]];
};
WriteTransformation: PUBLIC PROC [f: IO.STREAM, transform: ImagerTransformation.Transformation] = {
f.PutF["[%g %g %g ", [real[transform.a]], [real[transform.b]], [real[transform.c]]];
f.PutF["%g %g %g]", [real[transform.d]], [real[transform.e]], [real[transform.f]]];
};
WriteBOOL: PUBLIC PROC [f: IO.STREAM, bool: BOOL] = {
IF bool THEN f.PutRope["TRUE"] ELSE f.PutRope["FALSE"];
};
WriteProps: PUBLIC PROC [f: IO.STREAM, props: LIST OF REF ANY] = {
f.PutChar[IO.SP];
FOR name: LIST OF REF ANY ← props, name.rest UNTIL name=NIL DO
f.PutRope[NARROW[name.first]]; f.PutChar[IO.SP];
ENDLOOP;
};
END.