DIRECTORY ImagerBasic USING [Vec, IntVec, Rectangle, IntRectangle, Context, ImagingDevice, InteractiveImagingDevice, Procs, DeviceProcs, Path, SampledSource, SourceRecord, StrokeEnds, PixelArray, RGBValue, AISFile, Visibility]; Imager: CEDAR DEFINITIONS = BEGIN Rectangle: TYPE = ImagerBasic.Rectangle; -- RECORD [x, y, w, h: REAL] IntRectangle: TYPE = ImagerBasic.IntRectangle; -- RECORD [x, y, w, h: INTEGER] Vec: TYPE = ImagerBasic.Vec; -- RECORD [x, y: REAL] IntVec: TYPE = ImagerBasic.IntVec; -- RECORD [x, y: INTEGER] Context: TYPE = REF ContextRep; -- Holds the imager state ContextRep: TYPE = RECORD [ procs: ImagerInternalDefs.Procs, data: REF ANY ]; CreateContext: PROC [device: ImagingDevice] RETURNS [Context]; DestroyContext: PROC [context: Context]; Inclusions: TYPE = { all, allButCP, clientOnly, viewerOnly }; Mark: TYPE[1]; nullMark: Mark _ NULL; -- default mark indicating "use most recent save" Save: PROC [context: Context, what: Inclusions] RETURNS [Mark]; Restore: PROC [context: Context, mark: Mark _ nullMark]; NewFrame: PROC [context: Context]; -- who keeps the background color?? Translate: PROC [context: Context, dx, dy: REAL]; Rotate: PROC [context: Context, degrees: REAL]; Scale: PROC [context: Context, sx, sy: REAL]; IntTranslate: PROC [context: Context, dx, dy: INTEGER]; IntRotate: PROC [context: Context, degrees: INTEGER]; -- Fast if a multiple of 90 IntScale: PROC [context: Context, sx, sy: INTEGER]; -- Fast for mirror transforms ResetTransform: PROC [context: Context]; -- reset to identity Visibility: TYPE = ImagerBasic.Visibility; -- {visible, partlyVisible, invisible} SetClipArea: PROC [context: Context, area: Path]; ConcatArea: PROC [context: Context, area: Path, exclude: BOOLEAN _ FALSE]; TestArea: PROC [context: Context, area: Path] RETURNS [Visibility]; TestPoint: PROC [context: Context, point: Vec] RETURNS [BOOLEAN]; -- true if visible ClipArea: PROC [context: Context, area: Path] RETURNS [Path]; SetClipIntRectangle: PROC [context: Context, area: IntRectangle]; ConcatIntRectangle: PROC [context: Context, area: IntRectangle]; TestIntRectangle: PROC [context: Context, area: IntRectangle] RETURNS [Visibility]; TestIntPoint: PROC [context: Context, point: IntVec] RETURNS [BOOLEAN]; ClipIntRectangle: PROC [context: Context, area: IntRectangle] RETURNS [IntRectangle]; DoWithoutClipping: PROC [context: Context, callBack: PROC[Context]]; ImagingDevice: TYPE = ImagerBasic.ImagingDevice; InteractiveImagingDevice: TYPE = ImagerBasic.InteractiveImagingDevice; RegisterDevice: PROC [name: ImagingDevice, procs: ImagerBasic.DeviceProcs]; EnumerateRegisteredDevices: PROC [] RETURNS [LIST OF ImagingDevice]; SetDevice: PROC [context: Context, device: ImagingDevice]; GetDevice: PROC [context: Context] RETURNS [ImagingDevice]; Font: TYPE = REF; -- Will be more concrete when the new font interface is done. SetFont: PROC [context: Context, font: Font]; GetFont: PROC [context: Context] RETURNS [font: Font]; SourceRecord: TYPE = ImagerBasic.SourceRecord; RGBValue: TYPE = ImagerBasic.RGBValue; AISFile: TYPE = ImagerBasic.AISFile; PixelArray: TYPE = ImagerBasic.PixelArray; SampledSource: TYPE = ImagerBasic.SampledSource; SetSource: PROC [context: Context, source: SourceRecord]; GetSource: PROC [context: Context] RETURNS [SourceRecord]; SourceFromColor: PROC [context: Context, color: RGBValue] RETURNS [SourceRecord]; SourceFromImage: PROC [context: Context] RETURNS [SourceRecord]; SourceFromAIS: PROC [file: AISFile] RETURNS [SourceRecord]; Path: TYPE = ImagerBasic.Path; PathFromIntRectangle: PROC [area: IntRectangle] RETURNS [Path]; StrokeEnds: TYPE = ImagerBasic.StrokeEnds; -- {butt, square, round} MaskStroke: PROC [context: Context, path: Path]; MaskFill: PROC [context: Context, path: Path]; MaskPixel: PROC [context: Context, pixelArray: PixelArray]; MoveTo: PROC [context: Context, p: IntVec] = INLINE { Imager.SetIntCP[context, p] }; DrawTo: PROC [context: Context, p: IntVec]; DrawPath: PROC [context: Context, path: Path]; FillRectangle: PROC [context: Context, area: IntRectangle]; SetCP: PROC [context: Context, cp: Vec]; GetCP: PROC [context: Context, cp: Vec]; SetIntCP: PROC [context: Context, cp: IntVec]; GetIntCP: PROC [context: Context, cp: IntVec]; MaskChar: PROC [context: Context, char: CHAR]; MaskCharacters: PROC [ context: Context, characters: REF, -- may be a Rope.ROPE or a REF TEXT, for non-cedar probably a LONG STRING start: INT _ 0, length: INT _ LAST[INT] ]; MaskCharSeq: PROC [ context: Context, length: NAT, charPtr: LONG POINTER TO CHAR, charIncrement: NAT, deltaXptr: LONG POINTER TO INTEGER, deltaXincrement: NAT, deltaYptr: LONG POINTER TO INTEGER, deltaYincrement: NAT ]; Interactive: PROC [context: Context] RETURNS [BOOLEAN] = INLINE {RETURN [context.interactive]}; HiliteArea: PROC [context: Context, area: Path]; -- Invert on LF, device dependent HiliteIntRectangle: PROC [context: Context, area: IntRectangle]; MoveIntRectangle: PROC [context: Context, source: IntRectangle, destination: IntVec]; GetPixelArray: PROC [context: Context, source: IntRectangle, image: PixelArray _ NIL] RETURNS [PixelArray]; PutPixelArray: PROC [context: Context, destination: IntRectangle, image: PixelArray]; StartDoubleBuffering: PROC [context: Context]; StopDoubleBuffering: PROC [context: Context]; Procs: TYPE = ImagerBasic.Procs; DefaultProcs: PROC RETURNS [Procs]; ProcsRec: PUBLIC TYPE = RECORD [ CreateContext: PROC [imagingDevice: ImagingDevice] RETURNS [Context], DestroyContext: PROC [context: Context], Save: PROC [context: Context, what: Inclusions] RETURNS [Mark], Restore: PROC [context: Context, mark: Mark], NewFrame: PROC [context: Context], Translate: PROC [context: Context, dx, dy: REAL], Rotate: PROC [context: Context, degrees: REAL], Scale: PROC [context: Context, sx, sy: REAL], IntTranslate: PROC [context: Context, dx, dy: INTEGER], IntRotate: PROC [context: Context, degrees: INTEGER], IntScale: PROC [context: Context, x, y: INTEGER], ResetTransform: PROC [context: Context], SetClipArea: PROC [context: Context, area: Path], ConcatArea: PROC [context: Context, area: Path, exclude: BOOLEAN _ FALSE], TestArea: PROC [context: Context, area: Path] RETURNS [Visibility], TestPoint: PROC [context: Context, point: Vec] RETURNS [BOOLEAN], ClipArea: PROC [context: Context, area: Path] RETURNS [Path], SetClipRectangle: PROC [context: Context, area: IntRectangle], ConcatRectangle: PROC [context: Context, area: IntRectangle], TestRectangle: PROC [context: Context, area: IntRectangle] RETURNS [Visibility], TestIntPoint: PROC [context: Context, point: IntVec] RETURNS [BOOLEAN], ClipRectangle: PROC [context: Context, area: IntRectangle] RETURNS [IntRectangle], DoWithoutClipping: PROC [context: Context, callBack: PROC[Context]], RegisterDevice: PROC [name: ATOM, procs: ImagerBasic.DeviceProcs], EnumerateRegisteredDevices: PROC [] RETURNS [LIST OF ATOM], SetDevice: PROC [context: Context, device: ImagingDevice], GetDevice: PROC [context: Context] RETURNS [ImagingDevice], SetFont: PROC [context: Context, font: Font], GetFont: PROC [context: Context] RETURNS [font: Font], SetSource: PROC [context: Context, source: SourceRecord], GetSource: PROC [context: Context] RETURNS [source: SourceRecord], SourceFromColor: PROC [color: RGBValue] RETURNS [source: SourceRecord], SourceFromImage: PROC [context: Context] RETURNS [source: SourceRecord], SourceFromAIS: PROC [file: AISFile] RETURNS [source: SourceRecord], PathFromIntRectangle: PROC [area: IntRectangle] RETURNS [Path], MaskStroke: PROC [context: Context, path: Path], MaskFill: PROC [context: Context, path: Path], MaskPixel: PROC [context: Context, pixelArray: PixelArray], MoveTo: PROC [context: Context, p: IntVec], DrawTo: PROC [context: Context, p: IntVec], DrawPath: PROC [context: Context, path: Path], FillRectangle: PROC [context: Context, r: Rectangle], SetCP: PROC [context: Context, cp: Vec], GetCP: PROC [context: Context, cp: Vec], SetIntCP: PROC [context: Context, cp: IntVec], GetIntCP: PROC [context: Context, cp: IntVec], MaskChar: PROC [context: Context, char: CHAR], MaskCharacters: PROC [context: Context, characters: REF, start: INT _ 0, length: INT _ LAST[INT]], MaskCharSeq: PROC [context: Context, length: NAT, charPtr: LONG POINTER TO CHAR, charIncrement: NAT, deltaXptr: LONG POINTER TO INTEGER, deltaXincrement: NAT, deltaYptr: LONG POINTER TO INTEGER, deltaYincrement: NAT], Interactive: PROC [context: Context] RETURNS [BOOLEAN], InvertArea: PROC [context: Context, area: Path], InvertIntRectangle: PROC [context: Context, area: IntRectangle], MoveIntRectangle: PROC [context: Context, source: IntRectangle, destination: IntVec], GetPixelArray: PROC [context: Context, source: IntRectangle, image: PixelArray _ NIL] RETURNS [PixelArray], PutPixelArray: PROC [context: Context, destination: IntRectangle, image: PixelArray], StartDoubleBuffering: PROC [context: Context], StopDoubleBuffering: PROC [context: Context] ]; END. 4Imager.mesa This interface is the public expression of the client view of the procedures, structures, etc. for making images on all devices. At this level (client), only operations which affect only the client world are allowed. Therefore, updates to the viewers or device parameters go through lower level interfaces. There are two "tracks" for many operations: a "Fast Track" for efficient operations, using integers, and a "General Track" for more general operations, using floating point. Last Edited by: Crow, June 17, 1983 6:50 pm Wyatt, February 23, 1983 12:09 pm Plass, March 14, 1983 2:13 pm Basic Numbers and Shapes Context (interface designed - fcc) Making a new context, clients would not generally use these procedures directly Called by the viewers package, or other utilities, to set up a context. Returns NIL if unable to create the context. Remove all traces of the given context, clean up VM. Save/Restore Should be set representing all possible entries in context record Note the current state of the display context, and return a mark value which can later be passed to Restore. Restore the state of the display context to its condition prior to the call on Save that returned the given mark. Defaulting the mark means restore to the most recent Save. Clear, Next Page, etc. If printer or InterPress, start new page; if double-buffering, display newly completed image; otherwise clear inside context. Transformations (implemented - fcc) These calls, for clients, automatically concatenate to the current client transform. General Track Fast Track Clipping (fast track implemented - fcc) These routines allow the definition and testing of client clipping paths. Clipping paths are assumed to be glued to the viewer once defined. Subsequent changes in the client transform do not effect previously defined clipping paths. Testing and clipping operations are always done in device coordinates. Therefore items to be clipped must first be transformed. General Track Establishes clipped area Modifies old clipping region by supplied area. Exclude sets clipping outside path rather than inside. Enables use of "DoWithoutClipping" if returns visible Returns subarea which lies entirely inside clipping area Fast Track Enables use of "DoWithoutClipping" if returns visible Returns a subrectangle which lies entirely inside clipping area. Not recommended for use with nonconvex clipping paths. For clients who are able to use the tests above to verify that no clipping is needed. Each call must be preceded by a successful call to TestArea or TestIntRectangle. The client assumes liability for garbaged displays. Devices (interface under construction - fcc) ATOM; -- eg. $LF, $CRT8, $CRT24, $PD, $IP, etc. This affects only the device transforms, clipping, etc. Fonts (awaiting M. Plass' attentions) Affects current font, stroke width, strokends Sources (interface designed - fcc) A Source is a specification for coloring the Euclidean plane. There are three levels of complexity: (1) a constant color, (2) color from an array of samples (which can be used to tile the plane), and (3) color described by a procedure with arguments x and y. A "Color" can be (1) an uninterpreted value (the interpretation is device-dependent, or deferred), or (2) a tristimulus value (RGB). Various procedures provide transformations from common color spaces to RGB. Each device provides a transformation from RGB to a device-dependent representation. Thus there could be a standard 8-bit device with a standard color map for interpreting RGB (perhaps with dithering) and then an uninterpreted 8-bit device with a (possibly dynamic) color map. Affects current color, source of sampled imagery Paths (Skeleton made - fcc) Masks (fast track partially implemented - fcc) These procedures take the current source and apply it to those pixels which lie inside an area defined by the mask parameter (stroke, area, or pixelmask). The defined area is treated as a stencil which is conceptually superposed over the page while the color or image is applied. (1) "Butt" ends are squared off at the endpoint coordinate. (2) "Square" ends are extended by half the stroke width before squaring. (3) "Round" ends have semicircular caps at the ends. Form a stencil of "width" thickness around a spine defined by "path". Connected path segments will be mitered together. The client's path expansion scheme determines whether the path is open or closed. Use the path to outline an area to be filled with the source Use the supplied pixel array as the stencil. The origin of the pixel array will be placed at the origin of the client space. The samples will be assumed to be placed at one unit intervals in the client space. Fast Track. The width of lines, etc. is device dependent, approximately .1% page height. Sets current position Draw line using source for color Draw whole path using source for color Fill rectangular area with source Characters (awaiting M. Plass' attentions) Use the font interface to obtain FONTs and their metrics. Affects current position. Uses the DeviceWidth of each character for positioning. Displays a batch of characters, with all positioning provided by the client. Use this where speed is important. Interactive graphics (interface designed - fcc) These operations may not work on all devices, will no-op on noninteractive devices. If true, the interactive operations should work. General Track Fast Track Client's way to use BitBlt These use uninterpreted Pixel Arrays, clip to rectangle. Handy for rubber-stamping, etc.) Maintain shadow pixel array on the side for building images, use with "NewFrame". Implementer private data Κ έ– "cedar" style˜headšœ ™ J™δunitšœ™Jšœ™Jšœ!™!J™—šΟk ˜ Jšœ œ?˜PJšœI˜IJšœM˜M——head3šœœ ˜Jšœ˜—šΟb™Lšœ œΟc˜ELšœœŸ˜NLšœœŸ˜4LšœœŸ˜=—šž Οi™#Jšœ œœŸ˜?šœ œœ˜J˜ Jšœœœ˜Jšœ˜—Ihead4š O™OšΟn œœœ ˜>JšœPœ!™t—š‘œœ˜(Jšœ4™4—š  ™ šœ œ-˜=J™A—Jšœœ˜JšœœŸ1˜H—š‘œœ%œ˜?Jšœl™l—š‘œœ+˜8Jšœ¬™¬—š ™š‘œœŸ#˜GJšœ}™}—J˜——šžœ ™%™TLš  ™ —Jš‘ œœœ˜1Jš‘œœœ˜/š‘œœœ˜-Lš  ™ —Jš‘ œœœ˜7Jš‘ œœœŸ ˜UJš‘œœœŸ!˜ULš‘œœŸ˜>—šžœ ™)J™μšœ œŸ&˜QLš  ™ —š‘ œœ ˜1JšŸ™—š‘ œœ(œœ˜JJšœf™f—š‘œœ œ˜CJ™5—Jš ‘ œœ œœŸ˜Tš‘œœ œ˜=J™8Lš  ™ —Jš‘œœ(˜AJš‘œœ'˜@š‘œœ(œ˜SJ™5—Jš‘ œœ#œœ˜Gš‘œœ(œ˜UJ™w—š‘œœœ ˜DJšœŠ‘œ‘œ6™ά——šžœ $™-šœœœ˜0JšœŸ)™0—Jšœœœ˜FLš‘œœ7˜KJš ‘œœœœœ˜Dš‘ œœ+˜:J™7—Jš‘ œœœ˜;—šž ™&JšœœœŸ=˜O˜J™-—Jš‘œœ ˜-Jš‘œœœ˜6—šž  ™#Jšœξ™ξLšœœ˜.Jšœ œ˜&Jšœ œ˜$Jšœ œ˜*Jšœœ˜0˜J™0—Jš‘ œœ*˜9Jš‘ œœœ˜;Jš‘œœ%œ˜QJš‘œœœ˜@Jš‘ œœœ˜;J˜—šžœ ™Jšœœ˜Lš‘œœœ˜?J˜—šžœ (™/Jšœ—™—šœ œŸ˜EJšœ;™;JšœH™HJšœ4™4—š‘ œœ ˜0šœE™EJšœ„™„——š‘œœ˜.J™<—š‘ œœ+˜;JšœΠ™Π—J™šœY™YLšŸ™—Jš‘œœ!œ#˜Vš‘œœ˜+J™ —š‘œœ ˜.J™&—š‘ œœ'˜;J™!——šž  ™+šœ9™9Lš ™—Jš‘œœ˜(Jš‘œœ˜(Jš‘œœ ˜.Jš‘œœ ˜.Lš‘œœœ˜.š‘œœ˜Jšœ˜Jšœ œŸI˜ZJšœœ˜Jšœœœœ˜Jšœ˜J™7—š‘ œœ˜Jšœœ˜Jš œ œœœœœ˜2Jš œ œœœœœ˜9Jš œ œœœœ˜8Jšœ˜JšŸoœ™p——šž ™/J™Sš‘ œœœœ˜6Jšœœœ˜(J™0Lš  ™ —š‘ œœ"Ÿ!˜SLš  ™ —Jš‘œœ'˜@š‘œœ?˜UJ™—Lš‘ œœ>œœ˜lš‘ œœB˜UJšœZ™Z—Lš‘œœ˜.š‘œœ˜-J™Q——šž™Jšœœ˜ Lš‘ œœœ ˜#šœ œœœ˜ Jš‘ œœ œ ˜EJš‘œœ˜(Jš‘œœ%œ˜?Jš‘œœ ˜-Jš‘œœ˜"Lš‘ œœœ˜1Jš‘œœœ˜/Jš‘œœœ˜-Jš‘ œœœ˜7Jš‘ œœœ˜5Jš‘œœœ˜1Jš‘œœ˜(Lš‘ œœ ˜1Jš‘ œœ(œœ˜JJš‘œœ œ˜CJš ‘ œœ œœŸ˜AJš‘œœ œ˜=Jš‘œœ(˜>Jš‘œœ'˜=Jš‘ œœ(œ˜PJš‘ œœ#œœ˜GJš‘ œœ(œ˜RJš‘œœœ ˜DLš‘œœœ"˜BJš ‘œœœœœœ˜;Jš‘ œœ+˜:Jš‘ œœœ˜;Lš‘œœ ˜-Jš‘œœœ˜6Lš‘ œœ*˜9Jš‘ œœœ˜BJš‘œœœ˜GJš‘œœœ˜HJš‘ œœœ˜CLš‘œœœ˜?Lš‘ œœ ˜0Jš‘œœ˜.Jš‘ œœ+˜;Jš‘œœ˜+Jš‘œœ˜+Jš‘œœ ˜.Jš‘ œœ!˜5J˜Jš‘œœ˜(Jš‘œœ˜(Jš‘œœ ˜.Jš‘œœ ˜.Jš‘œœœ˜.Jš‘œœ œ œœœœ˜bJš$‘ œœœ œœœœœ œœœœœ œœœœœ˜ΩLš‘ œœœœ˜7Jš‘ œœ ˜0Jš‘œœ'˜@Jš‘œœ?˜UJš‘ œœ>œœ˜lJš‘ œœB˜UJš‘œœ˜.Jš‘œœ˜,—J˜—Lšœ˜—…—#E#