RTTest.Mesa
Copyright Ó 1990, 1992 by Xerox Corporation. All rights reserved.
Last tweaked by Mike Spreitzer on March 25, 1992 12:46 pm PST
Michael Plass, September 14, 1989 3:49:47 pm PDT
DIRECTORY Commander, CommanderOps, Convert, Imager, ImagerBitmapContext, ImagerFont, ImagerSample, IO, Process, Rope, ViewerPrivate;
RTTest:
CEDAR
PROGRAM
IMPORTS Commander, CommanderOps, Convert, Imager, ImagerBitmapContext, ImagerFont, ImagerSample, IO, Process, ViewerPrivate
=
BEGIN
font: Imager.Font ~ ImagerFont.FindScaled["xerox/xc1-2-2/modern", 20];
colors:
ARRAY
BOOL
OF
RECORD [bg, fg: Imager.Color] ~ [
[Imager.black, Imager.white],
[Imager.white, Imager.black]];
phase: BOOL ¬ FALSE;
Test:
PROC [bSize, sSize, n:
NAT]
RETURNS [bytesPerImage, total:
INT] ~ {
sm: ImagerSample.RasterSampleMap ~ ImagerSample.NewSampleMap[box: [[0, 0], [bSize, bSize]]];
sc: Imager.Context ~ ViewerPrivate.CreateContext[main];
bc: Imager.Context ~ ImagerBitmapContext.Create[deviceSpaceSize: [bSize, bSize], scanMode: [slow: down, fast: right], surfaceUnitsPerInch: [1, 1], pixelUnits: TRUE, fontCacheName: $Bitmap];
e: ImagerFont.Extents ~ ImagerFont.RopeBoundingBox[font, "XXXX"];
pos: Imager.VEC ~ [x: (bSize+e.leftExtent-e.rightExtent)/2, y: (bSize+e.descent-e.ascent)/2];
ImagerBitmapContext.SetBitmap[bc, sm];
bc.SetFont[font];
sc.ClipRectangleI[0, 0, sSize, sSize];
FOR i:
NAT
IN [0 .. n]
DO
bc.SetColor[colors[phase].bg];
bc.MaskRectangle[[0, 0, bSize, bSize]];
bc.SetColor[colors[phase].fg];
bc.SetXY[pos];
bc.ShowRope[IO.PutFR1["%04g", [integer[i]] ]];
sc.DrawBitmap[bitmap: sm, referencePoint: [bSize/2, bSize/2], scanMode: [down, right], position: [sSize/2, sSize/2]];
Process.CheckForAbort[]; phase ¬ NOT phase;
ENDLOOP;
bytesPerImage ¬ ImagerSample.WordsForMap[[bSize, bSize]]*BYTES[WORD];
total ¬ n*bytesPerImage;
RETURN};
Cmd: Commander.CommandProc ~ {
argv: CommanderOps.ArgumentVector ~ CommanderOps.Parse[cmd];
bSize: NAT ~ Convert.IntFromRope[argv[1]];
sSize: NAT ~ Convert.IntFromRope[argv[2]];
n: NAT ~ Convert.IntFromRope[argv[3]];
bytesPerImage, total: INT;
[bytesPerImage, total] ¬ Test[bSize, sSize, n];
cmd.out.PutF["bytesPerImage=%g, total=%g.\n", [integer[bytesPerImage]], [integer[total]] ];
RETURN};
Commander.Register["RTTest", Cmd, "bSize, sSize, n: NAT"];
END.