0.1.1 • Published 8 years ago

@hanamura/circulate v0.1.1

Weekly downloads
59
License
MIT
Repository
github
Last release
8 years ago

circulate Build Status

Circulate a number into given range.

Installation

npm install @hanamura/circulate --save

Usage

circulate(number, start, end)

Returns normalized number between start (inclusive) and end (exclusive).

Example

Keeping angles between 0 and 360 degrees (or -180 and 180 degrees):

var circulate = require('@hanamura/circulate');

circulate(0, 0, 360);
// -> 0

circulate(180, 0, 360);
// -> 180

circulate(360, 0, 360);
// -> 0

circulate(450, 0, 360);
// -> 90

circulate(-90, 0, 360);
// -> 270

circulate(-3690, 0, 360);
// -> 270

circulate(450, -180, 180);
// -> 90

circulate(-270, -180, 180);
// -> 90

License

MIT

0.1.1

8 years ago

0.1.0

9 years ago