@siroko/math
v0.0.4
Published
This is a toolkit for my common used math functions.
Downloads
3
Maintainers
Readme
maths.js
Creating a home made Math library with the most common functions Im using on my daily creative coding sessions.
import * as math from "@siroko/math";
Alternatively you can import only the functions you need
import {lerp, map} from "@siroko/math";
Usage
import * as math from "@siroko/math";
// Linear interpolation between 2 values
const interpolated = math.lerp(0, 5, 0.5);
console.log(interpolated); // Will output 2.5
// Linear interpolation between 2 hexadecimal colors
const outColor = math.lerpHex("#000000", "#FFFFFF", 1);
console.log(outColor); // Will output "#FFFFFF"
// Map a value based on 2 numeric domains
const mapped = math.map(0, 1, -10, 10, 0.5);
console.log(mapped); // Will output 0
License
MIT, see LICENSE.md for details.