--Griffin encoding types
--m.stone November 2, 1979 6:26 PM
-- Last Edited by: Stone, February 17, 1983 10:33 am

DIRECTORY
 PointDefs: FROM "PointDefs",
 Graphics USING [Context];

EncodingDefs: DEFINITIONS =
BEGIN

ChainHandle: TYPE = REF ChainEncoding;
AreaHandle: TYPE = REF AreaEncoding;

BYTE: TYPE = [0..256);
ChainEncoding: TYPE = RECORD
 [link: ChainHandle ← NIL,
 linknumber: [0..255] ← 0,
 tl,br: PointDefs.ScrPt ← [0,0], --bounding box
 p0: PointDefs.ScrPt ← [0,0],  --starting point
 octants: LONG DESCRIPTOR FOR PACKED ARRAY OF BYTE,
 bits: ARRAY [0..3] OF CARDINALALL[0]];


LongRun: TYPE = RECORD [lx,dx: INTEGER ← 0];
ShortRun: TYPE = RECORD [lx,dx: BYTE ← 0];
RunType: TYPE={short,long};
AreaEncoding: TYPE = RECORD
 [link: AreaHandle ← NIL,
 tl,br: PointDefs.ScrPt ← [0,0],  --bounding box. tl is origin
 codes: SELECT rep: RunType FROM
  short => [runs: LONG DESCRIPTOR FOR ARRAY OF ShortRun],
  long => [runs: LONG DESCRIPTOR FOR ARRAY OF LongRun],
  ENDCASE
 ];

--implemented by encoding
AddChainPoint: PROCEDURE[PointDefs.ScrPt];
AddChainLine: PUBLIC PROCEDURE[PointDefs.ScrPt];
MakeChainEncoding: PROCEDURE RETURNS[ChainHandle];
PlotChainChunk: PROCEDURE [encoding: ChainHandle, dc: Graphics.Context];
TestChainChunk: PROCEDURE [encoding: ChainHandle,
NextPoint: PROCEDURE[PointDefs.ScrPt] RETURNS[stop: BOOLEAN]];
DeleteChainEncoding
: PROCEDURE[ChainHandle];
CopyChainEncoding: PUBLIC PROCEDURE[chain: ChainHandle] RETURNS[newchain: ChainHandle];

MakeAreaEncoding: PROCEDURE[ChainHandle] RETURNS[AreaHandle];
PlotAreaChunk: PROCEDURE[encoding: AreaHandle, dc: Graphics.Context];
TestAreaChunk: PROCEDURE[encoding: AreaHandle,
TestLine: PROCEDURE[y,lx,dx: INTEGER] RETURNS[stop: BOOLEAN] ];
DeleteAreaEncoding: PROCEDURE[AreaHandle];
CopyAreaEncoding: PROCEDURE[oldarea: AreaHandle] RETURNS[newarea: AreaHandle];


END.