-- Moving edges with fast triangles
-- Bill Gosper, September 17, 1979 6:11 PM
DIRECTORY
TriArith:FROM "TriArith",
AltoDisplay:FROM "AltoDisplay",
BitBltDefs:FROM "BitBltDefs",
InlineDefs:FROM "InlineDefs",
KeyDefs:FROM "KeyDefs";
--PressDefs:FROM "PressDefs";
Triangles: PROGRAM
IMPORTS TriArith, InlineDefs =
BEGINOPEN TriArith, AltoDisplay, InlineDefs, KeyDefs;
fudge: INTEGER ← 32;
halfPi: LONG CARDINAL = 3373259426;
screenRad: CARDINAL = CSQRT[LONG[midX]*midX + LONG[midY]*midY];
ScreenVec: TYPE = RECORD[x, y: INTEGER];
maxArms: CARDINAL = 22;
CardArray: TYPE = ARRAY[0..maxArms] OF CARDINAL;
--LIArray: TYPE = ARRAY[0..maxArms] OF LONG INTEGER;
xtOctB: ARRAY [1 .. 8] OF CARDINAL ← [1005B, 133B, 307B, 343B, 1134B, 33B, 221B, 207B];
--xtOctA: ARRAY [1 .. 8] OF CARDINAL ← [1, 169, 0, 142, 0, 130, 69, 149];
xtOctA: ARRAY [1 .. 8] OF CARDINAL ← [232B, 266B, 77B, 266B, 239, 313B, 140B, 313B];--239B dawk
xtOctC: ARRAY [1 .. 8] OF CARDINAL ← [345B, 0, 42B, 65B, 407B, 117B, 55B, 310B];--239B dawk
--xtOctA: ARRAY [1 .. 8] OF CARDINAL ← [123, 169, 0, 142, 146, 130, 68, 149];
xtOct: DESCRIPTOR FOR ARRAY [1 .. 8] OF CARDINAL ← DESCRIPTOR[xtOctA];
--dawk, arraynames extraneous
xsOctA: ARRAY [1 .. 8] OF INTEGER ← [-2, -1, 0, 1, 2, 1, 0, -1];
xsOct: DESCRIPTOR FOR ARRAY [1 .. 8] OF INTEGER ← DESCRIPTOR[xsOctA];
ytOctB: ARRAY [1 .. 8] OF CARDINAL ← [1336B, 500B, 50B, 174B, 1244B, 604B, 104B, 646B];
ytOctC: ARRAY [1 .. 8] OF CARDINAL ← [116B, 6, 363B, 34B, 430B, 341B, 245B, 1267B];
--ytOctA: ARRAY [1 .. 8] OF CARDINAL ← [123, 288, 69, 200, 124, 288, 288, 202];
--ytOctA: ARRAY [1 .. 8] OF CARDINAL ← [3, 288, 69, 200, 0, 288, 288, 202];
ytOctA: ARRAY [1 .. 8] OF CARDINAL ← [340B, 541B, 211B, 541B, 440B, 163B, 164B, 163B];
ytOct: DESCRIPTOR FOR ARRAY [1 .. 8] OF CARDINAL ← DESCRIPTOR[ytOctA];
ysOctA: ARRAY [1 .. 8] OF INTEGER ← [-2, -1, 0, 1, 2, 1, 0, -1];
ysOct: DESCRIPTOR FOR ARRAY [1 .. 8] OF INTEGER ← DESCRIPTOR[ysOctA];
odds: ARRAY[0 .. maxArms] OF INTEGER ← [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21,
23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45];
--sddo: ARRAY[0 .. maxArms] OF INTEGER ← [45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1];
zeroes: ARRAY[0 .. maxArms] OF INTEGER ← [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
ones: ARRAY[0 .. maxArms] OF INTEGER ← [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
altOnes: ARRAY[0 .. maxArms] OF INTEGER ← [1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1];
ppmm: ARRAY[0 .. maxArms] OF INTEGER ← [1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1];
--fibs: ARRAY[0 .. maxArms] OF INTEGER ← [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657];
RealSquare: PROCEDURE[scale, speed: INTEGER, arms: CARDINAL] =
BEGINArbRot[DESCRIPTOR[zeroes], DESCRIPTOR[ones], DESCRIPTOR[ppmm], DESCRIPTOR[odds], DESCRIPTOR[odds], DESCRIPTOR[ppmm], scale, speed, arms] END;
ArbRot: PROCEDURE[xnd, xdd, ynd, ydd, nd, dd: DESCRIPTOR FOR ARRAY OF INTEGER,
scale, speed: INTEGER ← 99, len: CARDINAL ← maxArms] =
BEGINx1, y1, x2, y2, eps: ARRAY [0..maxArms) OF LONG INTEGER;
elb: ARRAY[0 .. maxArms] OF ScreenPt;
cx: LONGNUMBER ← [num[hibits: c[midX], lobits: 0]];
cy: LONGNUMBER ← [num[hibits: c[midY], lobits: 0]];
i: CARDINAL;
len ← MIN[len, LENGTH[xnd], LENGTH[ynd], LENGTH[nd], LENGTH[xdd], LENGTH[ydd], LENGTH[dd]];
FOR i IN [0 .. len) DO BEGIN
x: LONG INTEGER ← LFracDiv[ILongMult[xnd[i], scale], xdd[i]];
y: LONG INTEGER ← LFracDiv[ILongMult[ynd[i], scale], ydd[i]];
r2: LONG INTEGER;
sin: LONG INTEGER ← SIN[LFracDiv[ILongMult[nd[i], speed], dd[i]]];
sind: LONG INTEGER ← SIN[2*LFracDiv[ILongMult[nd[i], speed], dd[i]]];
-- sind: LONG INTEGER ← 2*LFracMul[sin, CSQRT[longOne - LLFracMul[sin, sin]]];
eps[i] ← 4*LLFracMul[sin, sin];
x1[i] ← x;
y2[i] ← y;
x ← fudge*x; y ← fudge*y;
r2 ← LL4Mul[x, x] + LL4Mul[y, y];
y1[i] ← LFracDiv[LLFracMul[r2, eps[i]] - LLFracMul[y, y],
HighHalf[(fudge+fudge)*(LLFracMul[x, eps[i]] + 2*LLFracMul[y, sind])]];
x2[i] ← LFracDiv[LLFracMul[eps[i],
LLFracMul[r2, eps[i]] - LLFracMul[x, x]],
HighHalf[(fudge+fudge)*(LLFracMul[y, eps[i]] + 2*LLFracMul[x, sind])]];
elb[i] ← [HighHalf[cx.li], HighHalf[cy.li]];
cx.li ← cx.li + x1[i]; cy.li ← cy.li + y2[i]; END; ENDLOOP;
elb[len] ← [HighHalf[cx.li], HighHalf[cy.li]];
WHILE Mouse.buttons # Yellow OR stepping DO
cx ← [num[hibits: c[midX], lobits: 0]];
cy ← [num[hibits: c[midY], lobits: 0]];
FOR i IN [0 .. len) DO BEGIN
oe: ScreenPt;
x1[i] ← x1[i] - LLFracMul[eps[i], y1[i]];
y1[i] ← y1[i] + x1[i];
x2[i] ← x2[i] - LLFracMul[eps[i], y2[i]];
y2[i] ← y2[i] + x2[i];
DrawTri[elb[i], elb[i+1], oe ← [HighHalf[cx.li], HighHalf[cy.li]]];
DrawTri[elb[i] ← oe, elb[i+1], [HighHalf[cx.li ← cx.li + x1[i]], HighHalf[cy.li ← cy.li + y2[i]]]];
END; ENDLOOP;
elb[len] ← [HighHalf[cx.li], HighHalf[cy.li]];
ENDLOOP;
END;
--Circle Algorithm
--xn+1 ← xn - e yn
--yn+1 ← yn + d xn+1
--==
--xn = rx cos(a + n D)
--yn = ry sin(b + n D)
--with
--rx2 e
-- =
--ry2 d
--b - a = D/2
--cos D = 1 - d e/2
--or
-- D sqrt(d e)
--sin =
-- 2 2
-- e y02 - e d x0 y0 + d x02
--d rx2 = = e ry2
-- (1 - d e/4)
--To start a "perfect" circle of radius r = sqrt(x2 + y2) thru (x, y),
--run two of the above, (xn, yn) and (Xn, Yn), with
--x0 = x
-- 2 d (r2 e d/4 - y2)
--y0 =
-- e d x + 2 y sin D
-- 2 e (r2 e d/4 - x2)
--X0 =
-- e d y + 2 x sin D
--Y0 = y
--and display (xn, Yn). Choosing
--d = 1, e = 4 sin2 D/2 = 2 (1 - cos D)
--then costs only two multiplies per iteration.
PolyJous: PROCEDURE[xt, yt: DESCRIPTOR FOR ARRAY [1 .. 8] OF CARDINAL,
xs, ys: DESCRIPTOR FOR ARRAY [1 .. 8] OF INTEGER, amp: ScreenPt] =
--dawk! if minindex # 0 then can’t take variable length arrays!
BEGINOPEN KeyDefs;
ztA, wtA: ARRAY [1..8] OF CARDINAL;
zt: DESCRIPTOR FOR ARRAY [1..8] OF CARDINAL = DESCRIPTOR[ztA];
wt: DESCRIPTOR FOR ARRAY [1..8] OF CARDINAL = DESCRIPTOR[wtA];
t: INTEGER ← 0;
dt: INTEGER;
len: ScreenPt ← [MIN[LENGTH[xs], LENGTH[xt]],
MIN[LENGTH[ys], LENGTH[yt]]];
lcm: LONG INTEGER;
pt, pp: ScreenPt;
ix, iy: CARDINAL ← 0;
[] ← PolyFixUp[xt, yt, zt, wt, xs, ys, amp, len];
[pt, lcm] ← PolyFixUp[zt, wt, zt, wt, xs, ys, amp, len];
amp ← pt;
WHILE lcm > 0 AND (Mouse.buttons # Yellow OR stepping) DO
UNTIL t > 0 DO IF (ix ← ix + 1) > len.x THEN ix ← 1;
dt ← MIN[-t, zt[ix]];
DrawTri[amp, pt, pp ← [pt.x + dt*xs[ix], pt.y + dt*ys[iy]]];
pt ← pp;
t ← t + zt[ix];
lcm ← lcm - dt;
ENDLOOP;
UNTIL t < 0 DO IF (iy ← iy + 1) > len.y THEN iy ← 1;
dt ← MIN[t, wt[iy]];
DrawTri[amp, pt, pp ← [pt.x + dt*xs[ix], pt.y + dt*ys[iy]]];
pt ← pp;
t ← t - wt[iy];
lcm ← lcm - dt;
ENDLOOP;
ENDLOOP;
InitDisplay;
WHILE Mouse.buttons = Yellow DO ENDLOOP
END;
--ICLongMult[INTEGER[<card+card>],...] ~~dawk
--FOR i.x IN [1 .. LENGTH[xt]) DO~~dawk
PolyFixUp: PROCEDURE[xt, yt, zt, wt: DESCRIPTOR FOR ARRAY [1 .. 8] OF CARDINAL,
xs, ys: DESCRIPTOR FOR ARRAY [1 .. 8] OF INTEGER, amp, len: ScreenPt]
RETURNS[pnt: ScreenPt, lcm: LONG CARDINAL] =
BEGINix, iy: CARDINAL;
one, mone: ScreenPt;
period, pt, max, min: ScreenVec ← [0, 0];
FOR ix IN [1 .. len.x] DO
max.x ← MAX[max.x, pt.x ← pt.x + xt[ix]*xs[ix]];
min.x ← MIN[min.x, pt.x];
SELECT xs[ix] FROM 1 => one.x ← ix; -1 => mone.x ← ix; ENDCASE;
ENDLOOP; --dawk, FOR i.x IN ...
FOR iy IN [1 .. len.y] DO
max.y ← MAX[max.y, pt.y ← pt.y + yt[iy]*ys[iy]];
min.y ← MIN[min.y, pt.y];
SELECT ys[iy] FROM 1 => one.y ← iy; -1 => mone.y ← iy; ENDCASE;
ENDLOOP;
pt ← [0, 0];
FOR ix IN [1 .. len.x] DO
pt.x ← pt.x + xs[ix]*(zt[ix] ← LongDiv[LongMult[xt[ix], amp.x], max.x - min.x]);
period.x ← period.x + zt[ix];
ENDLOOP;
FOR iy IN [1 .. len.y] DO
pt.y ← pt.y + ys[iy]*(wt[iy] ← LongDiv[LongMult[yt[iy], amp.y], max.y - min.y]);
period.y ← period.y + wt[iy];
ENDLOOP;
IF pt.x > 0 THEN IF mone.x > 0 THEN zt[mone.x] ← zt[mone.x] + pt.x
ELSE RETURN[[0, 0], 0]
ELSE IF one.x > 0 THEN zt[one.x] ← zt[one.x] - pt.x
ELSE RETURN[[0, 0], 0];
IF pt.y > 0 THEN IF mone.y > 0 THEN wt[mone.y] ← wt[mone.y] + pt.y
ELSE RETURN[[0, 0], 0]
ELSE IF one.y > 0 THEN wt[one.y] ← wt[one.y] - pt.y
ELSE RETURN[[0, 0], 0];
RETURN[[midX -
DIV[ICLongMult[max.x + min.x, amp.x], 2*(max.x-min.x)].quo,
midY -
DIV[ICLongMult[max.y + min.y, amp.y], 2*(max.y-min.y)].quo],
IF (lcm ← LCM[period.x ← period.x + ABS[pt.x], period.y ← period.y + ABS[pt.y]]) = LongMult[period.x, period.y] THEN lcm ELSE 0];
END;
Bilious: PROCEDURE[v1, v2, v3: ScreenVec, xy: ScreenPt] =
BEGINOPEN KeyDefs;
length: TYPE = [0 .. 3);
my: CARDINAL ← fullY - xy.y;
v: ARRAY length OF ScreenVec ← [v1, v2, v3];
--o, p: ARRAY length OF ScreenPt ← ALL[[0, my]];
o, p: ARRAY length OF ScreenPt ←
[[0,fullY],[0,fullY],[0,fullY]];--dawk
--o, p: ARRAY length OF ScreenPt ←
--[[Randm1[xy.x], my + Randm1[xy.y]],
-- [Randm1[xy.x], my + Randm1[xy.y]],
-- [Randm1[xy.x], my + Randm1[xy.y]]];~~dawk
i: length;--dawk
DOFOR i IN length DO IF CARDINAL[p[i].x ← p[i].x + v[i].x] >= xy.x THEN BEGIN v[i].x ← -v[i].x;
p[i].x ← IF INTEGER[p[i].x] < 0 THEN -p[i].x ELSE 2*xy.x -p[i].x END;
SELECT INTEGER[p[i].y ← p[i].y + v[i].y] FROM
< INTEGER[my] => BEGIN v[i].y ← - v[i].y;--dawk
p[i].y ← 2*my - p[i].y END;
>= INTEGER[fullY] => BEGIN v[i].y ← - v[i].y;
p[i].y ← 2*fullY - p[i].y END;
ENDCASE; ENDLOOP;
DrawTri[p[0], p[1], p[2]];
IF p = o OR (Mouse.buttons = Yellow AND NOT stepping) THEN EXIT;
ENDLOOP;
WHILE Mouse.buttons = Yellow DO ENDLOOP
END;
LooCLongMult: PROCEDURE[x: INTEGER, y: CARDINAL] RETURNS[LONG INTEGER] =
BEGIN RETURN[ICLongMult[x, y]] END;--dawk
--Rondo: PROCEDURE[r, e: INTEGER] =
--BEGIN OPEN KeyDefs;
--xx, yy: LONG INTEGER;
--~~xe: LONG INTEGER ← ICLongMult[2*r,
--~~ CSQRT[LOOPHOLE[LONGNUMBER[num[hibits: i[e], lobits: 0]],
--~~ LONG INTEGER] - ILongMult[e, e]]];~~dawk
--xe: LONG INTEGER ← LooCLongMult[2*r,
-- CSQRT[LOOPHOLE[LONGNUMBER[num[hibits: i[e], lobits: 0]],
-- LONG INTEGER] - ILongMult[e, e]]];
--ye: LONG INTEGER ← 0;
--xd: LONG INTEGER ← LOOPHOLE[LONGNUMBER[num[hibits: i[r], lobits: 0]]];
--yd: LONG INTEGER ←
-- LOOPHOLE[LONGNUMBER[num[hibits: i[r], lobits: 0]], LONG INTEGER]/2;
--WHILE Mouse.buttons # Yellow OR stepping DO
--xe ← xe - LFracMul[ye, e];
--yy ← ye + xe;
--xx ← xd - LFracMul[yd, e];
--yd ← yd + xx;
--DrawTri[[midX, midY],
--[midX + HighHalf[xd], midY + HighHalf[ye]],
--[midX + HighHalf[xx], midY + HighHalf[yy]]];
--xd ← xx; ye ← yy; ENDLOOP;
--UNTIL Mouse.buttons = None DO
--yd ← yd - xx;
--xx ← xd + LFracMul[yd, e];
--yy ← ye - xe;
--xe ← xe + LFracMul[yy, e];
--DrawTri[[midX, midY],
--[midX + HighHalf[xd], midY + HighHalf[ye]],
--[midX + HighHalf[xx], midY + HighHalf[yy]]];
--xd ← xx; ye ← yy; ENDLOOP;
--END;
LeaseAJew: PROCEDURE[rx, ry, e, d: INTEGER, m, n: CARDINAL] =
BEGINxx1, yy1, xx2, yy2: LONG INTEGER;
xe1: LONG INTEGER ← LooCLongMult[2*ry,
CSQRT[LOOPHOLE[LONGNUMBER[num[hibits: i[e], lobits: 0]],
LONG INTEGER] - ILongMult[e, e]]];
xe2: LONG INTEGER ← LooCLongMult[2*ry,
CSQRT[LOOPHOLE[LONGNUMBER[num[hibits: i[e], lobits: 0]],
LONG INTEGER] - ILongMult[e, e]]];
ye1, ye2: LONG INTEGER ← 0;
xd1: LONG INTEGER ← LOOPHOLE[LONGNUMBER[num[hibits: i[rx], lobits: 0]]];
xd2: LONG INTEGER ← LOOPHOLE[LONGNUMBER[num[hibits: i[rx], lobits: 0]]];
yd1: LONG INTEGER ←
LOOPHOLE[LONGNUMBER[num[hibits: i[rx], lobits: 0]], LONG INTEGER]/2;
yd2: LONG INTEGER ←
LOOPHOLE[LONGNUMBER[num[hibits: i[rx], lobits: 0]], LONG INTEGER]/2;
i: INTEGER ← n;
THROUGH [1 .. n] DO
THROUGH BOOLEAN DO
xe1 ← xe1 - LFracMul[ye1, e];
yy1 ← ye1 + xe1;
xx1 ← xd1 - LFracMul[yd1, d];
yd1 ← yd1 + xx1;
DrawTri[[midX, midY],
[midX + HighHalf[xd1], midY + HighHalf[ye1]],
[midX + HighHalf[xx1], midY + HighHalf[yy1]]];
xd1 ← xx1; ye1 ← yy1; ENDLOOP;
xe2 ← xe2 - LFracMul[ye2, e];
yy2 ← ye2 + xe2;
xx2 ← xd2 - LFracMul[yd2, d];
yd2 ← yd2 + xx2;
DrawTri[[midX, midY],
[midX + HighHalf[xd2], midY + HighHalf[ye2]],
[midX + HighHalf[xx2], midY + HighHalf[yy2]]];
xd2 ← xx2; ye2 ← yy2; ENDLOOP;
THROUGH [1 .. m] DO
[] ← Randm1[1];
IF INTEGER[randum1] < 0 THEN BEGIN
i ← i + 1;
xe1 ← xe1 - LFracMul[ye1, e];
yy1 ← ye1 + xe1;
xx1 ← xd1 - LFracMul[yd1, d];
yd1 ← yd1 + xx1;
DrawTri[[midX, midY],
[midX + HighHalf[xd1], midY + HighHalf[ye1]],
[midX + HighHalf[xx1], midY + HighHalf[yy1]]];
xd1 ← xx1; ye1 ← yy1; END ELSE BEGIN
i ← i - 1;
xe2 ← xe2 - LFracMul[ye2, e];
yy2 ← ye2 + xe2;
xx2 ← xd2 - LFracMul[yd2, d];
yd2 ← yd2 + xx2;
DrawTri[[midX, midY],
[midX + HighHalf[xd2], midY + HighHalf[ye2]],
[midX + HighHalf[xx2], midY + HighHalf[yy2]]];
xd2 ← xx2; ye2 ← yy2; END; ENDLOOP;
THROUGH [1 .. -i] DO
xe1 ← xe1 - LFracMul[ye1, e];
yy1 ← ye1 + xe1;
xx1 ← xd1 - LFracMul[yd1, d];
yd1 ← yd1 + xx1;
DrawTri[[midX, midY],
[midX + HighHalf[xd1], midY + HighHalf[ye1]],
[midX + HighHalf[xx1], midY + HighHalf[yy1]]];
xd1 ← xx1; ye1 ← yy1; ENDLOOP;
THROUGH [1 .. i] DO
xe2 ← xe2 - LFracMul[ye2, e];
yy2 ← ye2 + xe2;
xx2 ← xd2 - LFracMul[yd2, d];
yd2 ← yd2 + xx2;
DrawTri[[midX, midY],
[midX + HighHalf[xd2], midY + HighHalf[ye2]],
[midX + HighHalf[xx2], midY + HighHalf[yy2]]];
xd2 ← xx2; ye2 ← yy2; ENDLOOP;
END;
--Dearo: PROCEDURE[r, dt: INTEGER] =
--BEGINOPEN KeyDefs;
--x: LONG INTEGER ← 0;
--y: LONG INTEGER ← LFracMul[longOne, r];
--xx, yy: LONG INTEGER;
--WHILE Mouse.buttons # Yellow OR stepping DO
--yy ← y + LFracMul[x, dt];
--xx ← x - LFracMul[yy, dt];
--DrawTri[[midX, midY],
--[midX + HighHalf[x], midY + HighHalf[y]],
--[midX + HighHalf[xx], midY + HighHalf[yy]]];
--x ← xx; y ← yy; ENDLOOP;
--UNTIL Mouse.buttons = None DO
--xx ← x + LFracMul[y, dt];
--yy ← y - LFracMul[xx, dt];
--DrawTri[[midX, midY],
--[midX + HighHalf[x], midY + HighHalf[y]],
--[midX + HighHalf[xx], midY + HighHalf[yy]]];
--x ← xx; y ← yy; ENDLOOP;
--END;
Cheapo: PROCEDURE[tr, td: INTEGER] =
BEGINOPEN KeyDefs;
tx: INTEGER ← 0; ty: INTEGER ← tr;
txx, tyy: INTEGER;
WHILE Mouse.buttons # Yellow OR stepping DO
tyy ← ty + FracMul[tx, td];
txx ← tx - FracMul[tyy, td];
DrawTri[[midX, midY],
[midX + tx, midY + ty],
[midX + txx, midY + tyy]];
tx ← txx; ty ← tyy; ENDLOOP;
UNTIL Mouse.buttons = None DO
txx ← tx + FracMul[ty, td];
tyy ← ty - FracMul[txx, td];
DrawTri[[midX, midY],
[midX + tx, midY + ty],
[midX + txx, midY + tyy]];
tx ← txx; ty ← tyy; ENDLOOP;
END;
--Lissa: PROCEDURE[n, d1, d2: INTEGER, w, h: CARDINAL] =
--BEGINOPEN KeyDefs;
--ay, by, y1, y2: INTEGER ← 0; x1: INTEGER ← w; x2: INTEGER ← h;
--WHILE Mouse.buttons # Yellow OR stepping DO
--ay ← y1 + FracMul[x1, d1] + FracMul[BITSHIFT[ABS[x2],n], x2];
--by ← y2 + FracMul[x2, d2] - FracMul[BITSHIFT[ABS[x1],n], x1];
--x1 ← x1 - FracMul[ay, d1];
--x2 ← x2 - FracMul[by, d2];
--DrawTri[[midX, midY], [midX + y1, midY + y2], [midX + ay, midY + by]];
--y1 ← ay; y2 ← by; ENDLOOP;
--END;
--Lyssa: PROCEDURE[d1, d2: INTEGER, w, h: CARDINAL] =
--BEGINy1, y2: INTEGER ← 0; x1: INTEGER ← w; x2: INTEGER ← h;
-- DO BEGIN
--ay: INTEGER ← y1 + FracMul[x1, d1];
--by: INTEGER ← y2 + FracMul[x2, d2];
--x1 ← x1 - FracMul[ay, d1];
--x2 ← x2 - FracMul[by, d2];
--DrawTri[[midX, midY], [midX + y1, midY + y2], [midX + ay, midY + by]];
--IF BITAND[y1, BITNOT[ay]] < 0 THEN BEGIN
--x1 ← w; y1 ← 0; END ELSE y1 ← ay;
--IF BITAND[y2, BITNOT[by]] < 0 THEN BEGIN
--x2 ← h; y2 ← 0; END ELSE y2 ← by; END; ENDLOOP;
--END;
RandTri: PROCEDURE[xSize: [1..MaxBitsPerLine), ySize: [1..MaxScanLines)] =
BEGINOPEN KeyDefs;
width: CARDINAL ← MaxBitsPerLine - xSize;
height: CARDINAL ← MaxScanLines - ySize;
i: CARDINAL;
FOR i ← 0, i + 1 WHILE Mouse.buttons # Yellow OR stepping DO BEGIN
i1: CARDINAL ← BITOR[i, 1];
InitRandom[mult: 11213, add: i1];
THROUGH [0 .. i1 MOD 512) DO BEGIN
w: CARDINAL ← Randm1[width]; h: CARDINAL ← Randm1[height];
DrawTri[[w + Randm1[xSize], h + Randm1[ySize]],
[w + Randm1[xSize], h + Randm1[ySize]],
[w + Randm1[xSize], h + Randm1[ySize]]];
END; ENDLOOP; END; ENDLOOP;
END;
--smoothA: ARRAY[-4 .. 4] OF INTEGER = [0, -1, -2, -1, 0, 1, 2, 1, 0];
--xtAmp: ARRAY [1..8] OF CARDINAL ← [444, 66, 111, 66, 444, 111, 111, 111];
--ytAmp: ARRAY [1..8] OF CARDINAL ← [66, 66, 111, 66, 222, 222, 222, 222];
xtAmp: ARRAY [1..8] OF CARDINAL ← [444, 222, 222, 222, 444, 222, 222, 222];
ytAmp: ARRAY [1..8] OF CARDINAL ← [444, 222, 222, 222, 444, 222, 222, 222];
RandBi: PROCEDURE[n: CARDINAL] =
BEGINOPEN KeyDefs;
i: CARDINAL;
dims: ScreenPt;
h: ARRAY [0 .. 7] OF ScreenPt = [[fullX, fullX],
[fullX, fullX],[fullX, fullX],
[fullX, fullX],[fullX, fullX],
[600, 800], [600, 800], [600, 720]];
InitRandom[mult: 11213, add: 5];
--randum1 ← 5427~~2131~~B;~~dawk
randum1 ← 5430B--2131B--;
--WHILE Mouse.buttons # Yellow OR stepping --DO
FOR i IN [1 .. 8] DO
--xsOctA[i] ← smoothA[xsOctA[i-1] + smoothA[Randm1[7] - 3]];
--ysOctA[i] ← smoothA[ysOctA[i-1] + smoothA[Randm1[7] - 3]];
--xtOctA[i] ← Randm1[222*(1 + ABS[xsOctA[i]]~~*xsOctA[i]~~)];
--ytOctA[i] ← Randm1[222*(1 + ABS[ysOctA[i]]~~*ysOctA[i]~~)];
xtOctA[i] ← Randm1[xtAmp[i]];
ytOctA[i] ← Randm1[ytAmp[i]]; ENDLOOP;
PolyBaz;
--dims ← h[Randm1[8]];
--Bilious[RandBinc[n, dims],
--RandBinc[n, dims],
--RandBinc[n, dims], dims];
--LeaseAJew[300, 400, Randm1[999], Randm1[999], Randm1[4444], Randm1[4444]];
ENDLOOP;
END;
RandMin: PROCEDURE[n: CARDINAL] RETURNS[CARDINAL] =
BEGIN RETURN[MIN[Randm1[n], Randm1[n]]] END;
RandBinc: PROCEDURE[n: CARDINAL, dims: ScreenPt] RETURNS[ScreenVec] =
BEGINo12: CARDINAL ← (3 - RandMin[3]) MOD 3;
--O12: CARDINAL ← (3 - RandMin[3]) MOD 3;
RETURN[[o12*(dims.x/2) - RandMin[n]/(o12 + 1),
o12*(dims.y/2) - RandMin[n]/(o12 + 1)]]
END;
--Edger: PROCEDURE[x, y: INTEGER] RETURNS[pt: ScreenPt] = ~~INLINE~~
--BEGINRETURN[IF LongMult[ABS[x], midY] > LongMult[ABS[y], midX] THEN
--ScreenPt[IF x > 0 THEN fullX ELSE 0,
--midY + DIV[ILongMult[y, midX], ABS[x]].quo] ELSE
--ScreenPt[midX + DIV[ILongMult[x, midY], ABS[y]].quo,
--IF y > 0 THEN fullY ELSE 0]]
--END;
--OTachy: PROCEDURE[a, b, radius, dt: INTEGER, arms: CARDINAL ← 8] =
--BEGINOPEN KeyDefs;
--~~mag: CARDINAL ← screenRad/radius + 1;
--sin: INTEGER ← -dt/2;
--cos: INTEGER ← CSQRT[LONG[one]*one - LongMult[ABS[sin],ABS[sin]]];
--elb: ARRAY[0 .. maxArms] OF ScreenPt ← ALL[[0, midY]];
--~~elby: CardArray ← ALL[midY];
--~~elbx: CardArray;
--i: CARDINAL;
--cx: LONGNUMBER ← [num[hibits: c[midX], lobits: 0]];
--cy: LONGNUMBER;
--rr: LONGNUMBER ← [num[hibits: i[radius], lobits: 0]];
--x: LONG INTEGER ← longOne;
--y: LONG INTEGER ← 0;
--xx, yy: LONG INTEGER;
--oe, oE, tpt: ScreenPt;
--ti: INTEGER;
--wrap: BOOLEAN ← FALSE;
--FOR i IN [0 .. arms] DO BEGIN
--elb[i].x ← cx.c;
--cx.li ← cx.li + rr.li;
--rr.li ← LICDiv[LIILongMult[rr.li, -a], b]; END; ENDLOOP;
--oe ← elb[arms];
--~~oEx ← MAX[0, MIN[fullX, mag*(INTEGER[elbx[1]] - midX) + midX]];
--~~oEy ← MAX[0, MIN[fullY, mag*(INTEGER[elby[1]] - midY) + midY]];
--oE ← Edger[elb[1].x - midX, elb[1].y - midY].pt;
--WHILE Mouse.buttons # Yellow OR stepping DO
--x ← x - LFracMul[y, dt];
--ti ← HighHalf[y];
--y ← y + LFracMul[x, dt];
--IF ~wrap AND BITAND[ti, BITNOT[HighHalf[y]]] < 0 THEN wrap ← TRUE;
--xx ← x + LFracMul[y, sin];
--yy ← LFracMul[y, cos];
--rr ← [num[hibits: i[radius], lobits: 0]];
--cx ← [num[hibits: c[midX], lobits: 0]];
--cy ← [num[hibits: c[midY], lobits: 0]];
--FOR i IN [0 .. arms) DO BEGIN
--ox: LONGNUMBER ← [num[hibits: c[elb[i].x], lobits: 0]];
--oy: LONGNUMBER ← [num[hibits: c[elb[i].y], lobits: 0]];
--DrawTri[[ox.c, oy.c], elb[i+1],
--elb[i] ← [cx.c, cy.c]];
--DrawTri[elb[i], elb[i+1],
-- [HighHalf[ox.li ← cx.li + LLFracMul[rr.li, xx]],
-- HighHalf[oy.li ← cy.li + LLFracMul[rr.li, yy]]]];
--cx ← ox; cy ← oy;
--[xx, yy] ← LongPair[(longOne/2 - LLFracMul[yy, yy]),
---LLFracMul[xx, yy]];
--[xx, yy] ← LongPair[xx+xx, yy+yy];
--rr.li ← LICDiv[LIILongMult[rr.li, -a], b]; END; ENDLOOP;
--elb[arms] ← [cx.c, cy.c];
--IF wrap THEN BEGIN
--DrawTri[oe, oE, elb[arms]];
--DrawTri[oe ← elb[arms], oE,
--~~[cx.c ← MAX[0, MIN[fullX, mag*(INTEGER[elb[1].x] - midX) + midX]],
--~~ cy.c ← MAX[0, MIN[fullY, mag*(INTEGER[elb[1].y] - midY) + midY]]
--tpt ← Edger[elb[1].x - midX, elb[1].y - midY]];
--oE ← tpt; END; ENDLOOP;
--END;
ChewGum: PROCEDURE[tr, td, a, b, radius, dt: INTEGER, arms: CARDINAL ← 8] =
BEGINOPEN KeyDefs;
tx: INTEGER ← 0; ty: INTEGER ← tr;
txx, tyy: INTEGER;
sin: INTEGER ← -dt/2;
cos: INTEGER ← CSQRT[LONG[one]*one - LongMult[ABS[sin],ABS[sin]]];
elby: CardArray ← ALL[midY];
elbx: CardArray;
i: CARDINAL;
cx: LONGNUMBER ← [num[hibits: c[midX], lobits: 0]];
cy: LONGNUMBER;
rr: LONGNUMBER ← [num[hibits: i[radius], lobits: 0]];
x: LONG INTEGER ← longOne;
y: LONG INTEGER ← 0;
xx, yy: LONG INTEGER;
ti: INTEGER;
--THROUGH [1 .. 69] DO BEGIN
--w: CARDINAL ← Randm1[fullX - 99];
--h: CARDINAL ← Randm1[fullY - 99];
--DrawTri[[w + Randm1[99], h + Randm1[99]],
--[w + Randm1[99], h + Randm1[99]],
--[w + Randm1[99], h + Randm1[99]]];
--END; ENDLOOP;
FOR i IN [0 .. arms] DO BEGIN
elbx[i] ← cx.c;
cx.li ← cx.li + rr.li;
rr.li ← LICDiv[LIILongMult[rr.li, -a], b]; END; ENDLOOP;
WHILE Mouse.buttons # Yellow OR stepping DO BEGIN
--w: CARDINAL ← Randm1[fullX - 99];
--h: CARDINAL ← Randm1[fullY - 99];
--DrawTri[[w + Randm1[99], h + Randm1[99]],
--[w + Randm1[99], h + Randm1[99]],
--[w + Randm1[99], h + Randm1[99]]];
--w ← Randm2[fullX - 99];
--h ← Randm2[fullY - 99];
--DrawTri[[w + Randm2[99], h + Randm2[99]],
--[w + Randm2[99], h + Randm2[99]],
--[w + Randm2[99], h + Randm2[99]]];
tyy ← ty + HighHalf[LONG[4*tx]*td];
txx ← tx - HighHalf[LONG[4*tyy]*td];
DrawTri[ScreenPt[midX, midY],
ScreenPt[midX + tx, midY + ty],
ScreenPt[midX + txx, midY + tyy]];
tx ← txx; ty ← tyy;
x ← x - LFracMul[y, dt];
ti ← HighHalf[y];
y ← y + LFracMul[x, dt];
IF BITAND[ti, BITNOT[HighHalf[y]]] < 0 THEN
[x, y] ← LongPair[longOne, 0];
xx ← x + LFracMul[y, sin];
yy ← LFracMul[y, cos];
rr ← [num[hibits: i[radius], lobits: 0]];
cx ← [num[hibits: c[midX], lobits: 0]];
cy ← [num[hibits: c[midY], lobits: 0]];
FOR i IN [0 .. arms) DO BEGIN
ox: LONGNUMBER ← [num[hibits: c[elbx[i]], lobits: 0]];
oy: LONGNUMBER ← [num[hibits: c[elby[i]], lobits: 0]];
IF BITAND[1, i] = 0 THEN
DrawTri[[ox.c, oy.c], [elbx[i+1], elby[i+1]],
[elbx[i]←cx.c, elby[i]←cy.c]] ELSE
DrawTri[[cx.c, cy.c], [elbx[i+1], elby[i+1]],
[HighHalf[ox.li ← cx.li + LLFracMul[rr.li, xx]],
HighHalf[oy.li ← cy.li + LLFracMul[rr.li, yy]]]];
cx ← ox; cy ← oy;
[xx, yy] ← LongPair[(longOne/2 - LLFracMul[yy, yy]),
-LLFracMul[xx, yy]];
[xx, yy] ← LongPair[xx+xx, yy+yy];
rr.li ← LICDiv[LIILongMult[rr.li, -a], b]; END; ENDLOOP;
elbx[arms] ← cx.c; elby[arms] ← cy.c; END; ENDLOOP;
END;
Tachy: PROCEDURE[a, b, radius, dt: INTEGER, arms: CARDINAL ← 8] =
BEGINOPEN KeyDefs;
sin: INTEGER ← -dt/2;
cos: INTEGER ← CSQRT[LONG[one]*one - LongMult[ABS[sin],ABS[sin]]];
elby: CardArray ← ALL[midY];
elbx: CardArray;
i: CARDINAL;
cx: LONGNUMBER ← [num[hibits: c[midX], lobits: 0]];
cy: LONGNUMBER;
rr: LONGNUMBER ← [num[hibits: i[radius], lobits: 0]];
x: LONG INTEGER ← longOne;
y: LONG INTEGER ← 0;
xx, yy: LONG INTEGER;
ti: INTEGER;
FOR i IN [0 .. arms] DO BEGIN
elbx[i] ← cx.c;
cx.li ← cx.li + rr.li;
rr.li ← LICDiv[LIILongMult[rr.li, -a], b]; END; ENDLOOP;
WHILE Mouse.buttons # Yellow OR stepping DO
x ← x - LFracMul[y, dt];
ti ← HighHalf[y];
y ← y + LFracMul[x, dt];
IF BITAND[ti, BITNOT[HighHalf[y]]] < 0 THEN
[x, y] ← LongPair[longOne, 0];
xx ← x + LFracMul[y, sin];
yy ← LFracMul[y, cos];
rr ← [num[hibits: i[radius], lobits: 0]];
cx ← [num[hibits: c[midX], lobits: 0]];
cy ← [num[hibits: c[midY], lobits: 0]];
FOR i IN [0 .. arms) DO BEGIN
ox: LONGNUMBER ← [num[hibits: c[elbx[i]], lobits: 0]];
oy: LONGNUMBER ← [num[hibits: c[elby[i]], lobits: 0]];
DrawTri[[ox.c, oy.c], [elbx[i+1], elby[i+1]],
[elbx[i]←cx.c, elby[i]←cy.c]];
DrawTri[[cx.c, cy.c], [elbx[i+1], elby[i+1]],
[HighHalf[ox.li ← cx.li + LLFracMul[rr.li, xx]],
HighHalf[oy.li ← cy.li + LLFracMul[rr.li, yy]]]];
cx ← ox; cy ← oy;
[xx, yy] ← LongPair[(longOne/2 - LLFracMul[yy, yy]),
-LLFracMul[xx, yy]];
[xx, yy] ← LongPair[xx+xx, yy+yy];
rr.li ← LICDiv[LIILongMult[rr.li, -a], b]; END; ENDLOOP;
elbx[arms] ← cx.c; elby[arms] ← cy.c; ENDLOOP;
END;
DawkInit: PROCEDURE = BEGIN InitDisplay END;
Foo: PROCEDURE =
BEGIN ChewGum[tr: 100, td: 74000B, a: 2, b: 3, radius: 234, dt: 222, arms: 4];
END;
Bar: PROCEDURE[a, b, c: CARDINAL] =
BEGINxtOctA ← ALL[a];
ytOctA[1] ← ytOctA[3] ← ytOctA[5] ← ytOctA[7] ← b;
ytOctA[2] ← ytOctA[6] ← c;
PolyJous[xs: xsOct, xt: xtOct, ys: ysOct, yt: ytOct, amp: [567, 789]];
END;
PolyBaz: PROCEDURE =
BEGIN PolyJous[xs: xsOct, xt: xtOct, ys: ysOct, yt: ytOct, amp: [fullX-9, fullY-9]] END;
Baz: PROCEDURE[a,b,c: INTEGER] =
BEGINBilious[[a,b],[c,c],[b,a], [fullX, fullX]] END;
fullX←606;fullY←808;
Init;
--Bilious[[3,8],[6,8],[6,4], [fullX, fullY]];
--Bilious[[2,6],[4,6],[4,3], [fullX, fullY]];
--Bilious[[fullX-3,fullY-8],[fullX-6,fullY-8], [fullX-6,fullY-4], [fullX, fullY]];
--PolyJous[xs: xsOct, xt: DESCRIPTOR[xtOctC], ys: ysOct, yt: DESCRIPTOR[ytOctC], amp: [fullX-9, fullY-9]];
--PolyJous[xs: xsOct, xt: DESCRIPTOR[xtOctB], ys: ysOct, yt: DESCRIPTOR[ytOctB], amp: [fullX-9, fullY-9]];
--Bilious[[fullX/2-3,fullY/2-8],[fullX/2-4, fullY/2-6],[fullX/2-6,fullY/2-3], [fullX, fullY]];
--Bilious[[fullX/2-3,fullY/2+8],[4, 6], [fullX/2-6,
--fullY/2+4], [fullX, fullY]];
--LeaseAJew[300, 400, 4000B, 3777, 3333, 3333];
--RandBi[22];
--Baz[2,1,2];
Foo;
--RandTri[xSize: fullX - 1, ySize: fullY - 1];
--Finish;
END.