Miss any of our Open RFC calls?Watch the recordings here! »

@siroko/math

0.0.3 • 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.

Install

npm i @siroko/math

DownloadsWeekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

4.26 kB

Total Files

6

Last publish

Collaborators

  • avatar