mirror of
https://github.com/bspeice/speice.io
synced 2024-12-23 00:58:09 -05:00
14 lines
411 B
TypeScript
14 lines
411 B
TypeScript
|
// 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];
|
||
|
}
|