g (Geometry)
Together with Vectorizer, Geometry is another lightweight library built-in to JointJS. This library implements many useful geometry operations. The geometry library does not have any dependencies and can be used standalone. Please see the download page that contains both the development and minified versions of this library.
Functionsβ
normalizeAngle()β
g.normalizeAngle(angle)
Convert the angle
to the range [0, 360]
.
random()β
g.random(min, max)
Return a random integer between min
and max
, inclusive.
g.random(max)
Return a random integer between 0
and max
, inclusive.
g.random()
Return 0
or 1
, chosen randomly.
snapToGrid()β
g.snapToGrid(val, gridSize)
Snap the value val
to a grid of size gridSize
.
toDeg()β
g.toDeg(rad)
Convert radians rad
to degrees.
toRad()β
g.toRad(deg, over360)
Convert degrees deg
to radians. If over360
is true
, do not modulate on 360 degrees.