JunoGraphics.mesa
Coded July 1982 by Donna M. Auguste & Greg Nelson
Last edited December 7, 1982 3:20 pm
Last edited by Stolfi June 6, 1984 3:53:02 am PDT
TO FIX:
callers: replace SetpaintMode by SetColor[invert].
callers: Blink, ViewerToJuno, JunoToViewer, StartImageViewer, imageViewer have moved to JunoUserEvents.
DIRECTORY
Imager USING [Trajectory, Color],
Graphics USING [Context],
JunoStorage USING [Coords, IntCoords],
ViewerClasses USING [Viewer],
Rope USING [ROPE];
JunoGraphics: DEFINITIONS =
BEGIN
OPEN Rope, Stor: JunoStorage;
- - - - TYPES
Coords: TYPE = Stor.Coords; -- Juno coordinates (big points from bottom left corner of buffer)
IntCoords: TYPE = Stor.IntCoords; -- same as above, rounded to nearest integer for speed
Trajectory: TYPE = Imager.Trajectory;
PaintMode: TYPE = {opaque, invert};
Color: TYPE = Imager.Color;
Viewer: TYPE = ViewerClasses.Viewer;
- - - - GRAPHICS STATE
black, white, invert: READONLY Color;
currentColor: READONLY Color;
currentEnds: READONLY ATOM; -- $round, $butt, $square
currentWidth: READONLY REAL; -- line width for draw command (juno units)
currentFontName: READONLY ROPE; -- "Helvetica", "Times", etc
currentFontSize: READONLY REAL; -- in big points
currentFontFace: READONLY ATOM; -- $regular, $italic, $bold, $boldItalic
currentJustification: READONLY ATOM; -- $left, $center, $right (affects DrawRope)
currentPictureWidth: READONLY INTEGER; -- current picture dimensions (Juno units)
currentPictureHeight: READONLY INTEGER;
caretOn: READONLY BOOL; -- if TRUE, caret is supposed to be blinking on the image viewer
caretPos: READONLY Coords; -- current caret position, in Juno coordinates
- - - - CHANGING THE GRAPHIC STATE
SetScreenContext:
PUBLIC
PROC;
Resets the painting context to be the screen bitmap
(or, rather, an internal bitmap that is periodically copied onto the screen)
Also clears the bitmap buffer, and resets all context paramters (font, width, color, etc) to their defaults.
SetPaperContext:
PUBLIC
PROC [device:
ATOM, fileName: Rope.
ROPE, mag:
REAL ← 1.0];
Set the painting context to be a brand new context that writes into a PD file.
The device must be $Raven, $Puffin, $PlateMaker.
The context is clipped to the width and height specified by the last SetPictureSize, magnified by the given factor, and centered on the page.
SetPictureSize:
PUBLIC
PROC [width, height:
INTEGER];
Replaces the internal bitmap buffer by a new one having the specified dimensions.
The ink on the old bitmap will be lost.
SetColor: PUBLIC PROC [color: Color] RETURNS [old: Color];
IntensityToColor: PUBLIC PROC [intensity: REAL] RETURNS [color: Color];
RGBToColor: PUBLIC PROC [r, g, b: REAL] RETURNS [color: Color];
SetEnds: PUBLIC PROC [ends: ATOM] RETURNS [old: ATOM];
SetWidth: PUBLIC PROC [width: REAL] RETURNS [old: REAL];
SetFontName: PUBLIC PROC [name: ROPE] RETURNS [old: ROPE];
SetFontSize: PUBLIC PROC [size: REAL] RETURNS [old: REAL];
SetFontFace: PUBLIC PROC [face: ATOM] RETURNS [old: ATOM];
SetJustification: PUBLIC PROC [justification: ATOM] RETURNS [old: ATOM];
SetCaret:
PUBLIC
PROC [on:
BOOL ←
TRUE, coords: Coords ← [0,0]];
Moves the blinking caret at the given position in the image viewer. The position is in Juno coordinates (big points from lower left corner of picture).
If on=TRUE, the caret is turned on (if not yet on). If on=FALSE, the caret is turned off (of not already off)
- - - - IMAGE BLANKING
Whiten:
PUBLIC
PROC;
Paints the entire picture white.
- - - - POINT HIGHLIGHTS (AFFECTS SCREEN IMAGE ONLY)
PointSymbol: TYPE = {dot, plus, cross, box, diamond, bigDot};
Hilyte:
PUBLIC
PROC[coords: Coords, symbol: PointSymbol];
Highlights selected point with given symbol.
Symbol is painted with color=XOR, and only if the current context is the screen one.
- - - - POINTS
DrawPoint:
PUBLIC
PROC[coords: Coords];
Draws p as a small circle of the current color and diameter equal to the current stroke width.
- - - - LINES, STROKES, FILLED PATHS
These procedures draw a straight lines or bezier arc from p.coords to q.coords.
The "Draw" procedures do the drawing immediately. If thin=FALSE, the line is drawn as a stroke (using the current line width and ends type), otherwise it is drawn 1 pixel thick.
The "Append" procedures extend a trajectory that can later be drawn as a stroke or filled with color.
DrawEdge: PUBLIC PROC [p, q: Coords, thin: BOOL ← TRUE];
DrawArc: PUBLIC PROC [p, r, s, q: Coords, thin: BOOL ← TRUE];
AppendEdge: PUBLIC PROC [t: Trajectory, p, q: Coords] RETURNS [new: Trajectory];
AppendArc: PUBLIC PROC [t: Trajectory, p, r, s, q: Coords] RETURNS [new: Trajectory];
FillTrajectory:
PUBLIC
PROC [t: Trajectory];
Fills the trajectory t with the current color.
StrokeTrajectory:
PUBLIC
PROC [t: Trajectory];
Draws the trajectory t as a stroke, using current stroke width and ends type.
GcTrajectory:
PUBLIC
PROC [t: Trajectory];
Reclaims the trajectory t (currently no-op)
- - - - CHARS AND ROPES
DrawChar:
PUBLIC
PROC [coords: Coords, char:
CHAR];
Draws a character at a specific position.
DrawRope:
PUBLIC
PROC [coords: Coords, rope:
ROPE];
Draws a rope at a specific position.
The parameter pos tells where in the rope is the refeerence point; it is one of $left, $center, $right.
GetRopeDispl:
PUBLIC
PROC[rope:
ROPE]
RETURNS [vec: Coords];
Returns the x- and y- displacement of the given rope in the current font and device.
- - - - VIEWER/JUNO COORDINATE MAPPING
ViewerToJuno:
PROC [viewer: Viewer, view: IntCoords]
RETURNS [coords: IntCoords];
Maps from viewer's coordinates (big points from upper left corner of viewer) into Juno coordinates (big points from lower left corner of bitmap buffer).
JunoToViewer:
PROC [viewer: Viewer, coords: Coords]
RETURNS [view: IntCoords];
Maps from Juno coordinates (big points from lower left corner of bitmap buffer) into viewer's coordinates (big points from upper left corner of viewer).
- - - - BUFFER PAINTING PROC
picChanged:
READONLY
BOOL;
if TRUE, the bits in the bitmap buffer, the buffer size, its position, or the caret position have changed since last call of PaintBuffer.
PaintBuffer:
PUBLIC
PROC
[viewer: Viewer, context: Graphics.Context, viewerChanged:
BOOL];
Paints the bitmap buffer in the given context.
END.