rotate-positions
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Rotate positions in 2D space. Has many overloads and you can curry it if you want.

const { rotate } = require("rotate-positions")
let newPosition;
 
// width, height, angle, x, y
newPosition = rotate(200, 100, 90, 0, 0)
// returns [ x, y ]
 
// ..., { x, y }
newPosition = rotate(200, 100, 90, {x: 0, y: 0})
// returns { x, y }
 
// ..., [ x, y ]
newPosition = rotate(200, 100, 90, [ 0, 0 ])
// returns [ x, y ]
 
// You can call it if a list with the types above if you want.
 
newPosition = rotate(200, 100, 90, [
    [ 0, 0 ],
    [ 200, 100 ]
])
// returns [ [ x, y ], ... ]
 
// Currying is fine too.
 
curried = rotate(200, 100, 90)
newPosition = curried(0, 0)
 
// All overloads work while curried.

Readme

Keywords

none

Package Sidebar

Install

npm i rotate-positions

Weekly Downloads

1

Version

1.0.1

License

WTFPL

Unpacked Size

7.42 kB

Total Files

7

Last publish

Collaborators

  • nixxquality