ScanConvert.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Frank Crow, October 2, 1986 11:35:57 am PDT
Fancy operations on two-dimensional arrays of pixels.
DIRECTORY
Atom     USING [PropList],
ImagerColor   USING [RGB],
Vector3d    USING [Pair],
Pixels     USING [PixelBuffer, SampleSet, SampleSetSequence];
ScanConvert: CEDAR DEFINITIONS
~ BEGIN
Type Definitions
PixelBuffer: TYPE ~ Pixels.PixelBuffer;
RGB: TYPE ~ ImagerColor.RGB;        -- RECORD[ r, g, b: REAL];
IntRGBT: TYPE ~ RECORD[ r, g, b, t: CARDINAL];
RealSequence: TYPE ~ RECORD [length: NAT ← 0, s: SEQUENCE maxLength: NAT OF REAL];
Pair: TYPE ~ Vector3d.Pair;         -- RECORD[x, y: REAL];
IntPair: TYPE ~ RECORD[x, y: INTEGER];
IntPairSequence: TYPE ~ RECORD [length: NAT, pairs: SEQUENCE maxLength: NAT OF IntPair];
SampleSet: TYPE ~ Pixels.SampleSet;
SampleSetSequence: TYPE ~ Pixels.SampleSetSequence;
ScanConvertError: SIGNAL [reason: ATOM];
Constants
justNoticeable: REAL ~ 0.02; -- percentage intensity change for a just noticeable difference
Spot - (Point/PIxel/Spot) Definitions
 A spot is the information necessary to compute one or more pixels over a given position  in an image
GetColorProc: TYPE ~ PROC[spot: Spot] RETURNS[RGB, REAL];
Spot: TYPE ~ RECORD[
x, y: NAT,         -- screen coordinates
coverage: REAL ← 1.0,       -- percentage of pixel area covered by surface
mask: CARDINALLAST[CARDINAL],  -- coding for position of covered area
val: REF RealSequence ← NIL,    -- interpolated values for shading
yIncr: REF RealSequence ← NIL,    -- vertical increments for interpolated values
xIncr: REF RealSequence ← NIL,    -- horizontal increments for interpolated values
props: Atom.PropList ← NIL,    -- catchall
proc: GetColorProc ← NIL     -- extracts color for painting display
];
SpotSequence: TYPE ~ RECORD [ length: NAT, spots: SEQUENCE maxLength: NAT OF Spot ];
Utility Procedures
Extend: PROC[ seq: REF RealSequence, newLength: NAT] RETURNS[REF RealSequence];
Power: PROC[ value: INTEGER, power: NAT] RETURNS[ result: INTEGER ];
DitheredRGB: PROC[renderMode: ATOM, x, y, red, grn, blu: INTEGER] RETURNS[INTEGER];
MappedRGB: PROC[renderMode: ATOM, clr: RGB] RETURNS[NAT];
RGBFromMap: PROC[renderMode: ATOM, value: NAT] RETURNS[RGB];
Point/Spot Operations
PutSpot: PROC [ buf: PixelBuffer, spot: Spot, op, renderMode: ATOM ];
GetSpot: PROC [ buf: PixelBuffer, spot: Spot, renderMode: ATOM ] RETURNS[ Spot ];
Currently r, g, b are returned as spot.lerp[0] - spot.lerp[2]
Scan Conversion for Lines
PutLine: PROC [buf: PixelBuffer, p1, p2: IntPair, color: SampleSet ];
Device dependent, numbers must fit PixelBuffer dimensions, bytes used as is
Scan Conversion for Convex Areas
ConstantPoly: PROC [buf: PixelBuffer, color: SampleSet, plygn: REF SpotSequence];
SmoothPoly: PROC [buf: PixelBuffer, plygn: REF SpotSequence, renderMode: ATOM];
ShinyPoly: PROC [buf: PixelBuffer, plygn: REF SpotSequence, shininess: NAT,
      renderMode: ATOM];
END.