coords
Transform coordinates.
example
gl_to_pixel.js
var coords = ;var tr = ;var pos = ;consoledirpos;
output:
[ 0.15143929912390486, -0.23205342237061766 ]
flip.js
To flip the coordinates, just put the bigger number first:
var coords = ;var tr = ;var pos = ;consoledirpos;
output:
[ -0.15143929912390486, -0.23205342237061766 ]
pixel_to_gl.js
var coords = ;var tr = ;var pos = ;consoledirpos;
output:
[ 460, 230 ]
methods
var coords = require('coords')
var tr = coords(from, to)
Return a coordinate transform function tr
mapping coordinates specified in
from
to coordinates specified in to
.
Each 2-element array x
in from
and to
represents a coordinate transform on
a dimension in the range x[0]
to x[1]
, inclusive.
Any element x
in from
or to
that is not an array will be treated as the
array [ 0, x - 1 ]
.
tr(pos)
Transform the coordinate array pos
given the from
and to
specified earlier
in coords(from, to)
.
tr(x, y, ...)
Shorthand for tr([ x, y, ... ])
.
install
With npm do:
npm install coords
test
With npm do:
npm test
license
MIT/X11