@hypericon/easy
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Easy

Easing functions. Initially created to apply DMX lighting transitions. Includes TypeScript types.

npm (scoped)

npm i @hypericon/easy

Example Usage

import { applyEasing, EASING_ID, EasingFnIdsVL } from '@hypericon/easy';

const from = 0;
const to = 200;
const duration = 100;
const easingFnId = EASING_ID.inOutCubic;
const easingName = EasingFnIdsVL.find(vl => vl.value === easingFnId)?.label ?? "[unknown]";

console.log(`Ease from ${from} to ${to} over ${duration} steps using ${easingName}`);

for (let t = 0; t <= duration; t++) {
  const v = applyEasing(easingFnId, duration, t, from, to);
  console.log(`t: ${t}, v: ${v}`);
}

Additionally, a function is defined to easily enable mapping values within a range using an easing function.

import { easeWithinRange, EASING_ID, EasingFnIdsVL } from '@hypericon/easy';

const rangeStart = 20;
const rangeEnd = 120;
const value = 55;
const easingFnId = EASING_ID.inOutCubic;

const mapped = easeWithinRange(easingFnId, value, rangeStart, rangeEnd);

console.log(`Map value ${value} within range ${rangeStart} to ${rangeEnd} using easing function id ${easingFnId}: ${mapped}`);

Development

# Start a `tsc` process watching the source
npm run dev

# Run tests
npm run test

# Build for publishing. Runs automatically before `npm publish`
npm run build

Readme

Keywords

none

Package Sidebar

Install

npm i @hypericon/easy

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

18.7 kB

Total Files

6

Last publish

Collaborators

  • dyenamic
  • neonfish
  • unany