Skip to content

Commit 9f579cb

Browse files
committed
add debug toggle to demo page
1 parent 3eaf816 commit 9f579cb

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

internal/animate/testing/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</head>
1919

2020
<body>
21+
<button id="toggle">TOGGLE<br>DEBUG</button>
2122
<script src="./script.ts"></script>
2223
</body>
2324

internal/animate/testing/script.ts

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {clear, drawInfo, drawShape} from "../../render/canvas";
66
import {genBlob} from "../../blobs";
77
import {rand} from "../../rand";
88

9-
const animationSpeed = 2;
10-
const animationStart = 0.3;
11-
const debug = true;
12-
const size = 1000;
9+
let animationSpeed = 2;
10+
let animationStart = 0.3;
11+
let debug = true;
12+
let size = 1000;
1313

1414
const canvas = document.createElement("canvas");
1515
document.body.appendChild(canvas);
@@ -19,6 +19,10 @@ const temp = canvas.getContext("2d");
1919
if (temp === null) throw new Error("context is null");
2020
const ctx = temp;
2121

22+
const toggle = document.getElementById("toggle");
23+
if (toggle === null) throw new Error("no toggle");
24+
toggle.onclick = () => debug = !debug;
25+
2226
const point = (x: number, y: number, ia: number, il: number, oa: number, ol: number): Point => {
2327
return {
2428
x: x * size,
@@ -103,18 +107,37 @@ const testInterpolateBetween = (percentage: number) => {
103107
};
104108

105109
const testPrepShapesA = (percentage: number) => {
106-
const a = blob("a", 6, 0.2, {x: 0.5, y: 0.2});
107-
const b = blob("b", 10, 0.2, {x: 0.5, y: 0.2});
110+
const a = blob("a", 6, 0.15, {x: 0.45, y: 0.1});
111+
const b = blob("b", 10, 0.15, {x: 0.45, y: 0.1});
108112
drawShape(ctx, debug, interpolateBetweenLoop(percentage, ...prepShapes(a, b)));
109113
};
110114

111115
const testPrepShapesB = (percentage: number) => {
112-
const a = blob("a", 8, 0.2, {x: 0.5, y: 0.5});
116+
const a = blob("a", 8, 0.15, {x: 0.45, y: 0.25});
117+
const b: Shape = [
118+
point(0.45, 0.25, 0, 0, 0, 0),
119+
point(0.6, 0.25, 0, 0, 0, 0),
120+
point(0.6, 0.4, 0, 0, 0, 0),
121+
point(0.45, 0.4, 0, 0, 0, 0),
122+
];
123+
drawShape(ctx, debug, interpolateBetweenLoop(percentage, ...prepShapes(a, b)));
124+
};
125+
126+
const testPrepShapesC = (percentage: number) => {
127+
const a = blob("c", 8, 0.15, {x: 0.45, y: 0.45});
113128
const b: Shape = [
129+
point(0.5, 0.45, 0, 0, 0, 0),
130+
point(0.55, 0.45, 0, 0, 0, 0),
131+
point(0.55, 0.5, 0, 0, 0, 0),
132+
point(0.6, 0.5, 0, 0, 0, 0),
133+
point(0.6, 0.55, 0, 0, 0, 0),
134+
point(0.55, 0.55, 0, 0, 0, 0),
135+
point(0.55, 0.6, 0, 0, 0, 0),
136+
point(0.5, 0.6, 0, 0, 0, 0),
137+
point(0.5, 0.55, 0, 0, 0, 0),
138+
point(0.45, 0.55, 0, 0, 0, 0),
139+
point(0.45, 0.5, 0, 0, 0, 0),
114140
point(0.5, 0.5, 0, 0, 0, 0),
115-
point(0.7, 0.5, 0, 0, 0, 0),
116-
point(0.7, 0.7, 0, 0, 0, 0),
117-
point(0.5, 0.7, 0, 0, 0, 0),
118141
];
119142
drawShape(ctx, debug, interpolateBetweenLoop(percentage, ...prepShapes(a, b)));
120143
};
@@ -146,6 +169,7 @@ const blob = (seed: string, count: number, scale: number, offset: Coord): Shape
146169
testInterpolateBetween(percentage);
147170
testPrepShapesA(percentage);
148171
testPrepShapesB(percentage);
172+
testPrepShapesC(percentage);
149173

150174
percentage += animationSpeed / 1000;
151175
percentage = mod(percentage, 1);

0 commit comments

Comments
 (0)