Skip to main content
Version: 4.1

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.

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub