speice.io/blog/2024-11-15-playing-with-fire/2-transforms/blend.ts

14 lines
411 B
TypeScript
Raw Normal View History

2024-11-29 19:25:29 -05:00
// hidden-start
import { Variation } from "../src/variation"
// hidden-end
export function blend(x: number, y: number, variations: [number, Variation][]): [number, number] {
let [finalX, finalY] = [0, 0];
for (const [weight, variation] of variations) {
const [varX, varY] = variation(x, y);
finalX += weight * varX;
finalY += weight * varY;
}
return [finalX, finalY];
}