RandomDemo.mesa
Copyright © 1984, 1986 by Xerox Corporation. All rights reserved.
Created by: Jacobi, September 19, 1984 10:03:05 am PDT
Last Edited by: Christian Jacobi, August 12, 1986 12:28:44 pm PDT
DIRECTORY
Terminal USING [Virtual],
Imager USING [Context];
RandomDemo: CEDAR DEFINITIONS =
BEGIN
-- all registered procedures are supposed to be friendly: they must
--  be short, test the "stop" flag, or call utility procs from this module
--  not fork processes which modify context after procedure is finished
--  not change vt
Register: PROC [
proc: PROC,      --registered proc; see restrictions
clearProc: BOOLFALSE, --whether proc fills or clears the screen
b1: REAL ← 0.90,    --fill wants a clear first, clear wants a fill first
b2: REAL ← 0.10,    --??
weight: REAL ← 1,   --weight for random selection
time: INT ← -1    --in milliseconds, hint only
];
--all utility procedures might abort on time out for the demo
stop: READONLY BOOL;
context: Imager.Context;  --(bw) pixel units
vt: Terminal.Virtual;  --consider read only
screenW: READONLY NAT; --pixels width
screenH: READONLY NAT; --pixels height
screenw: READONLY NAT; --pixels width-1
screenh: READONLY NAT; --pixels height-1
Clear: PROC[];
--clears the screen
Pause: PROC[milliSeconds: INT];
--very limited range only
Rand: PROC[max: CARDINAL] RETURNS [CARDINAL];
--poor quality random number
RandChar: PROC [] RETURNS [CHAR];
--dependent of mode random or not at all
SetRandCharMode: PROC [];
--set mode for RandChar
Mode: TYPE = {set, xor, clr}←set;
DrawDot: PROC [x, y: INTEGER, mode: Mode←set];
--x, y must be visible
--in device coordinates (0, 0 ist top left)
DrawLine: PUBLIC PROC [x1, y1, x2, y2: INTEGER, mode: Mode←set];
--the two endpoints must be visible
--in device coordinates (0, 0 ist top left)
END.