<> <> <> <> 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: BOOL _ FALSE, --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.