DIRECTORY Rope USING [ ROPE ]; EdgeBlt: CEDAR DEFINITIONS ~ BEGIN EdgeDesc: TYPE ~ RECORD[ val: INT32, -- current value for incrementation, byte address or value stepsLeft: WORD _ 0, -- number of increments remaining length: WORD _ 0, -- total number of increments to make hiccups: WORD _ 0, -- number of offsets (hiccups) to make lngthIncr: INTEGER _ 0, -- amount to increment by hicIncr: INTEGER _ 0, -- amount to offset at hiccup bias: INTEGER _ 0, -- change to number of increments to first offset (for wizards) indirect: BOOLEAN _ TRUE, -- incrementing addresses if TRUE, else values nextEdge: CARD16 _ 0 -- next edge if part of a chain of edges (index in Sequence) ]; EdgeSequence: TYPE ~ RECORD [length: NAT _ 0, s: SEQUENCE maxLength: NAT OF EdgeBlt.EdgeDesc ]; EdgeBltOptions: TYPE ~ RECORD[ includeStart: BOOL _ TRUE, -- include start point includeEnd: BOOL _ TRUE -- include endpoint ]; defaultOptions: EdgeBltOptions ~ [TRUE, TRUE]; EdgeBltTable: TYPE ~ RECORD[ dst, src: EdgeDesc, options: EdgeBltOptions _ defaultOptions ]; EdgeBltError: SIGNAL [reason: ErrorDesc]; ErrorDesc: TYPE ~ RECORD [code: ATOM, explanation: Rope.ROPE]; Incr: PROC[edge: EdgeDesc, array: REF EdgeSequence _ NIL] RETURNS[EdgeDesc]; Blt: PROC[ebt: EdgeBltTable]; END. ςEdgeBlt.mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Frank Crow, June 12, 1987 3:49:32 pm PDT A general-purpose Bresenham incrementer. Type Definitions Basic Procedures The fractional increment Dy/Dx must be added to y for every new position x. Whenever the fraction overflows, y is incremented, effectively subtracting 1 from the fraction. By removing the fractional part from y, we can instead increment by Dy until Dx is reached. To center the positions of the y-increments along x, the incrementation by Dy should be started at Dx/2. To further simplify, decrement by 2Dy and start at Dx, testing for < 0. In the following read Dx as longSize and Dy as shortSize. Increments EdgeDesc once unless runToHiccup is set Κ-˜Ihead2šœ ™ šœ<™˜JLšœ œŸ!˜7LšœœŸ&˜:Lšœ œŸ'˜;Lšœ œŸ˜1Lšœ œŸ˜4LšœœŸ?˜TLšœ œœŸ.˜HLšœ œŸ<˜QLšœ˜—Lš œœœ œœ œœ˜uašœœœ˜MšœœœŸ˜3Mšœ œœŸ˜.M˜—Mšœ"œœ˜/šœœœ˜Mšœ˜Mšœ(˜(Mšœ˜—Mšœœ˜)Jš œ œœœœ˜?—™LšœΟgœ œΥ œ œZ œ œ) œ œ+ œ œ™ψš žœœœœœ ˜LLšœ2™2—šžœœ˜L˜—L˜—Jšœ˜—…— 9