INTERFACE PGM; IMPORT Rd, Wr; TYPE T = RECORD nx, ny: CARDINAL; dxdy: CARDINAL; maxval: [0..255]; v: REF ARRAY OF ARRAY OF CARDINAL END; PROCEDURE New(nx, ny: CARDINAL; dxdy: CARDINAL := 0; maxval: CARDINAL := 255): T; (* Allocates a new texture, with given dimensions and all zero pixels. *) PROCEDURE Read(rd: Rd.T): T; (* Reads a texture from the given stream, assumed to be in "PGM" file format, either binary (P5) or ascii (P2). The "dxdy" parameter is set to 0. *) PROCEDURE Write(wr: Wr.T; READONLY t: T; binary: BOOLEAN := TRUE); (* Writes "t" to the given stream in the "PGM" file format; either binary (P5, default) or ascii (P2). The "dxdy" parameter is not written. *) PROCEDURE PrintParms(wr: Wr.T; READONLY t: T); (* Displays the dimensions and displacements of texture "t" on the given writer. *) PROCEDURE Reduce(READONLY t: T; VAR x, y, z: INTEGER); (* Given the grid coordinates of an arbitrary texel of the plane, returns the coordinates of an equivalent texel in the fundamental region (the block [0..t.nx-1]x[0..t.ny-1]). *) PROCEDURE Eval(READONLY t: T; x, y: REAL): CARDINAL; (* Returns the value of texture "t" at point (x,y) of the plane, taking into account the periods and displacements of "t". Each texel is assumed to be a unit-side cube, and the domain of texel [0,0] is assumed to be the cube [0__1]^2. *) END PGM.