rotate-positions
v1.0.1
Published
Rotate positions in 2D space
Downloads
4
Readme
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.