InitBricks:
PROC ~
BEGIN
Matrix: TYPE ~ ARRAY [1 .. 4] OF ARRAY [1 .. 4] OF REAL;
FillSample: PROC [s: REF Brick, a, b, c, d: REAL] ~ BEGIN
Set: PROC [i, j: INTEGER, val: REAL] ~ BEGIN
ImagerSample.Put [map: s.sampleMap, index: [i, j], value: InlineRound [255*val]];
END;
s^ ← [maxSample: 255, sampleMap: ImagerSample.NewSampleMap [box: [max:[2, 2]], bitsPerSample: 8], phase: 0];
Set [0, 0, a]; Set [0, 1, b]; Set [1, 0, c]; Set [1, 1, d]
END; -- FillSample
FillSample9: PROC [s: REF Brick, a11, a12, a13, a21, a22, a23, a31, a32, a33: REAL] ~ BEGIN
Set: PROC [i, j: INTEGER, val: REAL] ~ BEGIN
ImagerSample.Put [map: s.sampleMap, index: [i, j], value: InlineRound [255*val]];
END;
s^ ← [maxSample: 255, sampleMap: ImagerSample.NewSampleMap [box: [max:[3, 3]], bitsPerSample: 8], phase: 0];
Set [0, 0, a11]; Set [0, 1, a12]; Set [0, 2, a13];
Set [1, 0, a21]; Set [1, 1, a22]; Set [1, 2, a23];
Set [2, 0, a31]; Set [2, 1, a32]; Set [2, 2, a33]
END; -- FillSample9
FillSample16:
PROC [s:
REF Brick, a: Matrix] ~
BEGIN
Set:
PROC [i, j:
INTEGER, val:
REAL] ~
BEGIN
ImagerSample.Put [map: s.sampleMap, index: [i, j], value: InlineRound [255*val]];
END;
s^ ← [maxSample: 255, sampleMap: ImagerSample.NewSampleMap [box: [max:[4, 4]], bitsPerSample: 8], phase: 0];
FOR i: [1 .. 4]
IN [1 .. 4]
DO
FOR j: [1 .. 4] IN [1 .. 4] DO a[i][j] ← a[i][j] / 17.0 ENDLOOP
ENDLOOP;
Set [0, 0, a[1][1]]; Set [0, 1, a[1][2]]; Set [0, 2, a[1][3]]; Set [0, 3, a[1][4]];
Set [1, 0, a[2][1]]; Set [1, 1, a[2][2]]; Set [1, 2, a[2][3]]; Set [1, 3, a[2][4]];
Set [2, 0, a[3][1]]; Set [2, 1, a[3][2]]; Set [2, 2, a[3][3]]; Set [2, 3, a[3][4]];
Set [3, 0, a[4][1]]; Set [3, 1, a[4][2]]; Set [3, 2, a[4][3]]; Set [3, 3, a[4][4]]
END; -- FillSample16
FillSample [brickK, 0.6, 0.4, 0.2, 0.8];
FillSample [brickC, 0.2, 0.8, 0.6, 0.4];
FillSample [brickM, 0.6, 0.4, 0.2, 0.8];
FillSample [brickY, 0.42, 0.15, 0.7, 0.3]; -- delicate !
FillSample9 [brickC, 0.4, 0.5, 0.6, 0.1, 0.3, 0.2, 0.7, 0.8, 0.9];
FillSample9 [brickM, 0.6, 0.1, 0.7, 0.5, 0.3, 0.8, 0.4, 0.2, 0.9];
FillSample9 [brickK, 0.1, 0.6, 0.4, 0.7, 0.2, 0.9, 0.5, 0.8, 0.3];
FillSample9 [brickY, 0.5, 0.8, 0.3, 0.9, 0.2, 0.6, 0.1, 0.7, 0.4];
FillSample16 [brickC, [[8.0, 6.0, 7.0, 5.0], [1.0, 3.0, 2.0, 4.0], [16.0, 14.0, 15.0, 13.0], [9.0, 11.0, 10.0, 12.0]]];
FillSample16 [brickM, [[8.0, 1.0, 9.0, 16.0], [6.0, 3.0, 11.0, 14.0], [7.0, 2.0, 10.0, 15.0], [5.0, 4.0, 12.0, 13.0]]];
FillSample16 [brickY, [[8.0, 9.0, 11.0, 4.0], [10.0, 7.0, 3.0, 13.0], [12.0, 2.0, 6.0, 15.0], [1.0, 14.0, 16.0, 5.0]]];
FillSample16 [brickK, [[1.0, 13.0, 15.0, 5.0], [11.0, 2.0, 6.0, 16.0], [9.0, 7.0, 3.0, 14.0], [8.0, 10.0, 12.0, 4.0]]]
END; -- InitBricks