mirror of
https://github.com/bspeice/speice.io
synced 2025-07-29 03:25:03 -04:00
More writing for the main posts
This commit is contained in:
@ -5,14 +5,15 @@ export type VariationBlend = [number, Variation][];
|
||||
export function blend(
|
||||
x: number,
|
||||
y: number,
|
||||
variations: VariationBlend): [number, number] {
|
||||
let [finalX, finalY] = [0, 0];
|
||||
variations: VariationBlend
|
||||
): [number, number] {
|
||||
let [outX, outY] = [0, 0];
|
||||
|
||||
for (const [weight, variation] of variations) {
|
||||
const [varX, varY] = variation(x, y);
|
||||
finalX += weight * varX;
|
||||
finalY += weight * varY;
|
||||
outX += weight * varX;
|
||||
outY += weight * varY;
|
||||
}
|
||||
|
||||
return [finalX, finalY];
|
||||
return [outX, outY];
|
||||
}
|
@ -2,14 +2,11 @@ import { camera, histIndex } from "./camera"
|
||||
|
||||
export function plotBinary(x: number, y: number, image: ImageData) {
|
||||
const [pixelX, pixelY] = camera(x, y, image.width);
|
||||
if (
|
||||
pixelX < 0 || pixelX >= image.width || pixelY < 0 || pixelY > image.height
|
||||
) {
|
||||
const pixelIndex = histIndex(pixelX, pixelY, image.width, 4);
|
||||
if (pixelIndex < 0 || pixelIndex > image.data.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pixelIndex = histIndex(pixelX, pixelY, image.width, 4);
|
||||
|
||||
image.data[pixelIndex] = 0;
|
||||
image.data[pixelIndex + 1] = 0;
|
||||
image.data[pixelIndex + 2] = 0;
|
||||
|
Reference in New Issue
Block a user