Finish a first draft

This commit is contained in:
2024-12-14 16:55:54 -05:00
parent 9b1a3895d0
commit a05acf6748
8 changed files with 184 additions and 55 deletions

View File

@ -13,7 +13,9 @@ export type Props = ChaosGameFinalProps & {
export function* chaosGameHistogram({width, height, transforms, final, paint}: Props) {
let iterations = quality * width * height;
// highlight-start
const histogram = Array<number>(width * height).fill(0);
// highlight-end
let [x, y] = [randomBiUnit(), randomBiUnit()];
@ -23,6 +25,7 @@ export function* chaosGameHistogram({width, height, transforms, final, paint}: P
const [finalX, finalY] = final(x, y);
if (i > 20) {
// highlight-start
const [pixelX, pixelY] = camera(finalX, finalY, width);
const hIndex = histIndex(pixelX, pixelY, width, 1);
@ -31,6 +34,7 @@ export function* chaosGameHistogram({width, height, transforms, final, paint}: P
}
histogram[hIndex] += 1;
// highlight-end
}
if (i % step === 0)