DIRECTORY Imager, Rope, SF, ViewerClasses; Draw2d: CEDAR DEFINITIONS IMPORTS Imager ~ BEGIN VEC: TYPE ~ Imager.VEC; Context: TYPE ~ Imager.Context; ROPE: TYPE ~ Rope.ROPE; Viewer: TYPE ~ ViewerClasses.Viewer; DrawType: TYPE ~ {solid, dashed, dotted}; MarkType: TYPE ~ {cross, x, asterisk, dot, none}; DrawProc: TYPE ~ PROC [ context: Context, -- Imager context clientData: REF ANY ¬ NIL, -- client supplied data whatChanged: REF ANY ¬ NIL, -- as in ViewerOps viewer: Viewer ¬ NIL -- NIL if for Interpress master ]; PixelProc: TYPE ~ PROC [x, y: INTEGER] RETURNS [continue: BOOL ¬ TRUE]; IntegerBox: TYPE ~ RECORD [x, y, w, h: INTEGER]; Zip: TYPE ~ REF ZipRep; ZipRep: TYPE ~ RECORD [ box: SF.Box, rasterDevice: BOOL ¬ FALSE, transform: Imager.Transformation ]; BoxFromContext: PROC [context: Context] RETURNS [IntegerBox]; ScreenScale: PROC [viewer: Viewer, aspectRatio: REAL ¬ 4.0/3.0] RETURNS [REAL]; Clear: PROC [context: Context, color: Imager.Color ¬ Imager.white]; Label: PROC [context: Context, position: VEC, rope: ROPE]; AssureFont: PROC [context: Context]; DoWithBuffer: PROC [context: Context, action: PROC, clear: BOOL ¬ TRUE]; IPOut: PROC [fileName: ROPE, drawProc: DrawProc, clientData: REF ANY ¬ NIL]; GetZip: PROC [context: Context, zip: Zip ¬ NIL] RETURNS [Zip]; ReleaseZip: PROC [zip: Zip]; Line: PROC [context: Context, vec0, vec1: VEC, drawType: DrawType ¬ solid, zip: Zip ¬ NIL]; DoWithLine: PUBLIC PROC [vec0, vec1: VEC, pixelProc: PixelProc]; Mark: PROC [context: Context, position: VEC, markType: MarkType ¬ cross, zip: Zip ¬ NIL]; Square: PROC [context: Context, center: VEC, size: REAL]; Circle: PROC [context: Context, center: VEC, radius: REAL, fill: BOOL ¬ FALSE]; Arrow: PROC [ context: Context, tail, head: VEC, drawType: DrawType ¬ solid, vary: BOOL ¬ TRUE, zip: Zip ¬ NIL]; END. D Draw2d.mesa Copyright Σ 1985, 1991, 1992 by Xerox Corporation. All rights reserved. Bloomenthal, July 17, 1992 2:08 pm PDT Types General Utility Procedures Return the box in integer device coordinates that corresponds to the Imager context. Return the width (in pixels) of the largest rectangle with the given aspect ratio that fits inside the viewer. Clear the context to the given color. Combines AssureFont, Imager.SetXY and Imager.ShowRope.. If context has no font, initialize it to helvetica10; prevents certain Imager errors. Perform double buffered action; if clear, first clear to white. Zip is obtained and placed on context property list during action. Perform drawProc while writing to an interpress file. clientData is passed to drawProc. whatChanged argument to drawProc is $IPOut, and viewer argument is NIL. Accelerator Return an accelerator for subsequent calls to Line[]. NIL is returned if the Imager strokeWIdth is non-zero, if the context is not a raster device, or if the size of the context is zero. A new Zip is needed after any change to context's size, transformation, or display device. Companion to GetZip; releases zip.transform. Line Drawing Procedures If Imager stroke width # 0 or context expects anti-aliasing, then MaskVector is called. Otherwise a pixel wide line from vec0 to vec1 is drawn with Bresenham's algorithm. This is faster than Imager.MaskVector, but slower than ImagerCG6Context.LineCG6. This procedure will work for gray or stippled lines. Apply pixelProc to each pixel of the line, as determined by the Bresenham algorithm. Miscellaneous Marking Procedures Draw a mark at position. Draw a solid square centered at center with edges at +/- size. Draw a circle at the given center with the given radius. Draw an arrow from tail to head; if vary, arrowhead size varies according to arrow length. Κ•NewlineDelimiter –(cedarcode) style™šœ ™ Jšœ Οeœ=™HJ™&J˜JšΟk œ!˜*J˜—šΠblœžœž ˜Jšžœ˜J˜Jšœž˜—headšΟl™Jšžœžœ žœ˜Jšœ žœ˜ Jšžœžœžœ˜šœ žœ˜%J˜—Jšœ žœ˜)šœ žœ#˜1J˜—šœ žœžœ˜JšœΟc˜.Jšœžœžœžœ‘˜:Jšœžœžœžœ‘˜5Jšœžœ‘Πcs‘˜=Jšœ˜J˜—š œ žœžœžœžœ žœžœ˜HJ˜—šœ žœžœžœ˜0J˜—Jšœžœžœ˜šœ žœžœ˜Jšœ žœ˜Jšœžœžœ˜J˜"J˜——š ™šΟnœžœžœ˜=J™TJ˜—š £ œžœžœ žœžœ˜OJ™QJ™J™—š£œžœ8˜CJ™%J™—š£œžœžœžœ˜:Jšœ7™7J™—š£ œžœ˜$J™UJ˜—š £ œžœžœ žœžœ˜HJšœ?™?JšœB™BJ™—š £œžœ žœ"žœžœžœ˜LJšœX™XJšœCΟsœ™G——š  ™ š£œžœžœžœ˜>J™5Jš€œB™EJšœ>™>J™ZJ™—š£ œžœ ˜J™,——š ™š£œžœ žœ)žœ˜[JšœW™WJšœR™RJšœP™PJšœ4™4J™—š£ œžœžœžœ˜@JšœT™T——š  ™ š£œžœžœ)žœ˜YJšœ™J™—š£œžœžœžœ˜9Jšœ>™>J™—š £œžœžœ žœžœžœ˜OJ™8J™—š£œžœ˜ Jšœ˜Jšœ žœ˜J˜Jšœžœžœ˜Jšœ žœ˜J™Z—J™—Jšžœ˜J˜J˜—…—X±