lifehash
Version:
TypeScript/JavaScript implementation of LifeHash, a visual hash algorithm
16 lines (15 loc) • 466 B
JavaScript
export const lerp_to = (toA, toB, t) => {
return t * (toB - toA) + toA;
};
export const lerp_from = (fromA, fromB, t) => {
return (fromA - t) / (fromA - fromB);
};
export const lerp = (fromA, fromB, toC, toD, t) => {
return lerp_to(toC, toD, lerp_from(fromA, fromB, t));
};
export const clamped = (n) => {
return Math.max(Math.min(n, 1), 0);
};
export const modulo = (dividend, divisor) => {
return ((dividend % divisor) + divisor) % divisor;
};