@siroko/math

0.0.4 • Public • Published

maths.js

Build Status stable

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

NPM

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.

Package Sidebar

Install

npm i @siroko/math

Weekly Downloads

6

Version

0.0.4

License

MIT

Unpacked Size

4.94 kB

Total Files

6

Last publish

Collaborators

  • siroko