Skip to content

Commit 8c19dc8

Browse files
committed
add blob generation samples to test page
1 parent 23e36ed commit 8c19dc8

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

internal/animate/testing/script.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import {length, insertAt, insertCount, rad, mod, mapPoints, forPoints} from "../
55
import {clear, drawInfo, drawClosed} from "../../render/canvas";
66
import {genBlob} from "../../gen";
77
import {rand} from "../../rand";
8+
import * as blobs2 from "../../../public/blobs";
89

910
let animationSpeed = 2;
1011
let animationStart = 0.3;
1112
let debug = true;
12-
let size = 1000;
13+
let size = 1300;
1314

1415
const canvas = document.createElement("canvas");
1516
document.body.appendChild(canvas);
@@ -169,6 +170,34 @@ const testPrepLetters = (percentage: number) => {
169170
drawClosed(ctx, debug, loopBetween(percentage, ...prepare(a, b)));
170171
};
171172

173+
const testGen = () => {
174+
const cellSideCount = 16;
175+
const cellSize = size / cellSideCount;
176+
ctx.save();
177+
ctx.strokeStyle = "#fafafa";
178+
ctx.fillStyle = "#f1f1f1";
179+
for (let i = 0; i < cellSideCount; i++) {
180+
for (let j = 0; j < cellSideCount; j++) {
181+
ctx.strokeRect(i * cellSize, j * cellSize, cellSize, cellSize);
182+
ctx.fill(
183+
blobs2.canvas(
184+
{
185+
extraPoints: j,
186+
randomness: i,
187+
seed: i + j - i * j,
188+
size: cellSize,
189+
},
190+
{
191+
offsetX: i * cellSize,
192+
offsetY: j * cellSize,
193+
},
194+
),
195+
);
196+
}
197+
}
198+
ctx.restore();
199+
};
200+
172201
const blob = (seed: string, count: number, scale: number, offset: Coord): Point[] => {
173202
const rgen = rand(seed);
174203
const points = genBlob(count, () => 0.3 + 0.2 * rgen());
@@ -197,6 +226,7 @@ const loopBetween = (percentage: number, a: Point[], b: Point[]): Point[] => {
197226
const renderFrame = () => {
198227
clear(ctx);
199228

229+
testGen();
200230
drawInfo(ctx, 0, "percentage", percentage);
201231
testSplitAt(percentage);
202232
testSplitBy();

0 commit comments

Comments
 (0)