--GraphicsToImager.tioga --Maureen Stone December 16, 1983 3:48 pm --Types Path Trajectory, Polygon, Outline Context Context DeviceRef FontRef FONT ImageRef Color Color ConstantColor Texture Color StrokeEnds: TYPE = {butt, square, round}; StrokeEnd: TYPE = {nil, square, butt, round}; Box: TYPE = RECORD[xmin,ymin,xmax,ymax: REAL] Rectangle: TYPE = RECORD [x, y, w, h: REAL]; IntRectangle: TYPE = RECORD [x, y, w, h: INTEGER]; --eliminated baseMark, Box, DeviceRef, Mark, nullMark, YMode, PaintMode --new PixelArray, Transformation, Visibility, Pair, RopeOrRefText, IntPair, IntRectangle <<>> <> NewContext: PROC[device: DeviceRef _ NIL] RETURNS[Context]; Create: PROC[deviceType: ATOM, data: REF _ NIL] RETURNS [Context]; CopyContext: PROC[self: Context] RETURNS[Context]; Gone --Imager State The imager state for a particular context is accessable through the class procedures IGet, IGetReal, and IGetInt. <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<>> Name: TYPE = {DCScpx, DCScpy, correctMX, correctMY, T, priorityImportant, mediumXSize, mediumYSize, fieldXMin, fieldYMin, fieldXMax, fieldYMax, showVec, color, noImage, strokeWidth, strokeEnd, underlineStart, amplifySpace, correctPass, correctShrink, correctTX, correctTY, clipOutline}; context: Imager.Context; value: REF _ context.class.IGet[context: Context, n: Name]; --works for anything real: REAL _ context.class.IGet[context: Context, n: Name]; --ie. n: DCScpx int: INT _ context.class.IGet[context: Context, n: Name]; --ie. n: <> GetCP: PROC[self: Context, rounded: BOOLEAN] RETURNS[x,y: REAL], x _ self.class.IGetReal[self,DCScpx]; y _ self.class.IGetReal[self,DCScpy]; SetCP: PROC[self: Context, x,y: REAL, rel: BOOLEAN], SetXY: PROC[context: Context, p: Pair]; IntegerSetXY: PROC[context: Context, x, y: INTEGER]; SetXYRel: PROC[context: Context, v: Pair]; IntegerSetXYRel: PROC[context: Context, x, y: INTEGER]; SetXRel: PROC[context: Context, x: REAL]; IntegerSetXRel: PROC[context: Context, x: INTEGER]; SetYRel: PROC[context: Context, y: REAL]; IntegerSetYRel: PROC[context: Context, y: INTEGER]; DrawTo: PROC[self: Context, x,y: REAL, rel: BOOLEAN], MaskVector: PROC[context: Context, p1, p2: Pair, strokeWidth: REAL _ defaultStrokeWidth, strokeEnd: StrokeEnd _ defaultStrokeEnd]; Path operators (now called Mask Operators). The semantics of paths have changed some. A Graphics.Path is equivalent to an Imager.Outline. An Imager.Outline is a list of Imager.Trajectory. An Imager.Trajectory is a single geometric trace or loop. Simple shapes are usually a single trajectory. You only need to create an outline if you have more than one trajectory in your shape (ie. a closed path with holes). All trajectory operations are of the form: trajectory _ op[trajectory]; You start a Trajectory by doing a MoveTo, add to it by using LineTo, CurveTo, etc. NewPath: PROC[size: INT _ 0] RETURNS[Path]; --part of MoveTo LastPoint: PROC[self: Path] RETURNS[x, y: REAL]; LastPoint: PROC[t: Trajectory] RETURNS[Pair]; FlushPath: PROC[self: Path]; --gone MoveTo: PROC[self: Path, x, y: REAL, flush: BOOLEAN _ TRUE]; MoveTo: PROC[p: Pair] RETURNS[Trajectory]; LineTo: PROC[self: Path, x, y: REAL]; LineTo: PROC[t: Trajectory, p: Pair] RETURNS[Trajectory]; LineToX: PROC[t: Trajectory, x: REAL] RETURNS[Trajectory]; LineToY: PROC[t: Trajectory, y: REAL] RETURNS[Trajectory]; CurveTo: PROC[self: Path, x1, y1, x2, y2, x3, y3: REAL]; CurveTo: PROC[t: Trajectory, p1, p2, p3: Pair] RETURNS[Trajectory]; ConicTo: PROC[t: Trajectory, p1, p2: Pair, r: REAL] RETURNS[Trajectory]; ArcTo: PROC[t: Trajectory, p1, p2: Pair] RETURNS[Trajectory]; Rectangle: PROC[self: Path, x0, y0, x1, y1: REAL]; MaskRectangle: PROC[context: Context, x, y, w, h: REAL]; IntegerMaskRectangle: PROC[context: Context, x, y, w, h: INTEGER]; ClipRectangle: PROC[context: Context, x, y, w, h: REAL]; IntegerClipRectangle: PROC[context: Context, x, y, w, h: INTEGER]; IntegerExcludeRectangle: PROC[context: Context, x, y, w, h: INTEGER]; --new for the imager MakeOutline: PROC[LIST OF Trajectory] RETURNS[Outline]; --drawing routines DrawStroke: PROC[self: Context, path: Path, width: REAL, closed: BOOLEAN, ends: StrokeEnds], MaskStroke: PROC[context: Context, t: Trajectory, strokeWidth: REAL _ defaultStrokeWidth, strokeEnd: StrokeEnd _ defaultStrokeEnd]; MaskStrokeClosed: PROC[context: Context, t: Trajectory, strokeWidth: REAL _ defaultStrokeWidth]; SetStrokeWidth: PROC[context: Context, strokeWidth: REAL]; SetStrokeEnd: PROC[context: Context, strokeEnd: StrokeEnd]; DrawArea: PROC[self: Context, path: Path, parityFill: BOOLEAN], MaskFill: PROC[context: Context, outline: REF]; DrawBox: PROC[self: Context, box: Box], MaskRectangle: PROC[context: Context, x, y, w, h: REAL]; IntegerMaskRectangle: PROC[context: Context, x, y, w, h: INTEGER]; --New for the imager MaskPixel: PROC[context: Context, pa: PixelArray]; DrawImage: PROC[self: Context, image: ImageRef, raw: BOOLEAN], --make sampled color, then MaskRectangle --Transformations Translate: PROC[self: Context, tx,ty: REAL, round: BOOLEAN], TranslateT: PROC[context: Context, x, y: REAL]; Scale: PROC[self: Context, sx,sy: REAL] ScaleT: PROC[context: Context, s: REAL]; Scale2T: PROC[context: Context, sx, sy: REAL]; Rotate: PROC[self: Context, angle: REAL]; RotateT: PROC[context: Context, a: REAL]; Concat: PROC[self: Context, m11,m12,m21,m22: REAL], ConcatT: PROC[context: Context, m: Transformation]; --new to Imager Move: PROC[context: Context]; <> Trans: PROC[context: Context]; <> --Gone ?? Map: PROC[sc,dc: Context, sx,sy: REAL] RETURNS[dx,dy: REAL] WorldToUser: PROC[self: Context, wx,wy: REAL] RETURNS[x,y: REAL], UserToWorld: PROC[self: Context, x,y: REAL] RETURNS[wx,wy: REAL], --Color. --Color now includes flat colors and sampled colors (images) SetColor: PROC[self: Context, color: Color], SetColor: PROC[context: Context, color: Color]; GetColor: PROC[self: Context] RETURNS[Color], --iget? SetPaintMode: PROC[self: Context, mode: PaintMode] RETURNS[PaintMode], invert: SetColor[context: Context, color: Imager.XOR]; opaque: standard transparent: look at MaskPixel: PROC[context: Context, pa: PixelArray]; SetFat: PROC[self: Context, fat: BOOLEAN] RETURNS[BOOLEAN], --gone? --Fonts and Text. Font properties are defined in Font.mesa MakeFont: PROC[name: Rope.ROPE] RETURNS[FontRef]; MakeFont: PROC[name: ROPE, size: REAL] RETURNS[FONT]; SetDefaultFont: PROC[self: Context, font: FontRef], SetFont: PROC[context: Context, font: FONT]; GetDefaultFont: PROC[self: Context] RETURNS[FontRef], --IGet? DrawChar: PROC[self: Context, char: CHARACTER,font: FontRef _ NIL]; ShowChar: PROC[context: Context, char: CHAR, font: FONT _ NIL]; DrawRope: PROC[self: Context, rope: Rope.ROPE, start: INT _ 0, len: INT _ Rope.MaxLen, font: FontRef _ NIL]; ShowCharacters: PROC[context: Context, characters: RopeOrRefText, font: FONT _ NIL, start: INT _ 0, length: INT _ LAST[INT]]; --From Font RopeBox: PROC[font: FontRef, rope: Rope.ROPE, start: INT _ 0, len: INT _ Rope.MaxLen] --gone? RopeWidth: PROC[font: FontRef, rope: Rope.ROPE, start: INT _ 0, len: INT _ Rope.MaxLen] TextWidth: PROC [font: FONT, text: RopeOrRefText] RETURNS [REAL]; CharBox: PROC[font: FontRef, char: CHARACTER] RETURNS[xmin,ymin,xmax,ymax: REAL]; Font.BoundingBox: PROC [font: FONT, char: CHAR] RETURNS [Box]; CharWidth: PROC[font: FontRef, char: CHARACTER] RETURNS[xw,yw: REAL]; Font.Width: PROC [font: FONT, char: CHAR] RETURNS [REAL]; FontBox: PROC[font: FontRef] RETURNS[xmin,ymin,xmax,ymax: REAL]; Font.FontBoundingBox: PROC [font: FONT] RETURNS [Box] ClipArea: PROC[self: Context, path: Path, parityFill: BOOLEAN, exclude: BOOLEAN], ClipOutline: PROC[context: Context, outline: REF]; ExcludeOutline: PROC[context: Context, outline: REF]; ClipBox: PROC[self: Context, box: Box, exclude: BOOLEAN], ClipRectangle: PROC[context: Context, x, y, w, h: REAL]; ExcludeRectangle: PROC[context: Context, x, y, w, h: REAL]; IntegerClipRectangle: PROC[context: Context, x, y, w, h: INTEGER]; IntegerExcludeRectangle: PROC[context: Context, x, y, w, h: INTEGER]; --culling IsPointVisible: PROC[self: Context, x,y: REAL] RETURNS[BOOLEAN], IsRectangular: PROC[self: Context] RETURNS[BOOLEAN], Visible: PROC[self: Context] RETURNS[BOOLEAN], Visibility: TYPE = {visible, partlyVisible, invisible}; TestRectangle: PROC[context: Context, x, y, w, h: REAL] RETURNS[Visibility]; GetBounds: PROC[self: Context] RETURNS[Box], GetSurfaceBounds: PROC[context: Context] RETURNS[IntRectangle]; <> GetViewBounds: PROC[context: Context] RETURNS[IntRectangle]; <> --The model for saving and restoring state has changed. Instead of a stack, the user must package sets of operations in procedures. The state is saved at the call and restored at the return. DoSave and DoSaveAll differ in the amount of state that is saved. Save: PROC[self: Context] RETURNS[Mark], Restore: PROC[self: Context, mark: Mark], DoSave: PROC[context: Context, body: PROC]; DoSaveAll: PROC[context: Context, body: PROC]; DrawBits: UNSAFE PROC[self: Context, base: LONG POINTER, raster: CARDINAL, bitsPerPixel: [0..16), x, y, w, h: CARDINAL, xorigin, yorigin: INTEGER], DrawBitmap: PROC[context: Context, base: LONG POINTER, raster: CARDINAL, area: IntRectangle]; MaskPixel: PROC[context: Context, pa: PixelArray]; UserToDevice: PROC[self: Context, x, y: REAL, rel: BOOLEAN] RETURNS[tx, ty: REAL], DeviceToUser: PROC[self: Context, tx, ty: REAL, rel: BOOLEAN] RETURNS[x, y: REAL], GetYMode: PROC[self: Context] RETURNS[GraphicsBasic.YMode], SetYMode: PROC[self: Context, mode: GraphicsBasic.YMode], --Gone DrawTexturedBox: PROC[self: Context, box: Box, texture: GraphicsBasic.Texture], MakeStipple: PROC[CARDINAL] RETURNS[Color]; IntegerMaskRectangle: PROC[context: Context, x, y, w, h: INTEGER]; Disable: PROC[self: Context], Gone? MoveDeviceRectangle: PROC[self: Context, width, height, fromX, fromY, toX, toY: NAT] MoveSurfaceRectangle: PROC [context: Context, source: IntRectangle, dest: IntPair]; ];