Rac

Root class of RAC. All drawable, style, control, and drawer classes are contained in this class.

An instance must be created with new Rac() in order to build drawable, style, and other objects.

To perform drawing operations, a drawer must be setup with Rac#setupDrawer. Currently the only available implementation is P5Drawer.

Constructor

new Rac()

# | source: Rac.js, line 20

Creates a new instance of Rac. The new instance has no drawer setup.

Classes

Angle
Arc
ArcControl
Bezier
Color
Composite
Control
Controller
Exception
Fill
P5Drawer
Point
Ray
Segment
SegmentControl
Shape
Stroke
Style
Text

Members

(static) build :string

# | source: Rac.js, line 193

Build of the class. Intended for debugging purpouses.

Contains a commit-count and short-hash of the repository when the build was done.

(static) TAU :number

# | source: Rac.js, line 207

Tau, equal to Math.PI * 2.

Tau Manifesto.

(static) utils :object

# | source: Rac.js, line 179

Container of utility functions. See utils for the available members.

(static) version :string

# | source: Rac.js, line 182

Version of the class. Same as the version used for the npm package.

build :string

# | source: Rac.js, line 38

Build of the instance, same as Rac.build.

controller

# | source: Rac.js, line 97

Controller of the instance. This objecs handles all of the controls and pointer events related to this instance of Rac.

drawer :object

# | source: Rac.js, line 91

Drawer of the instance. This object handles the drawing of all drawable object using this instance of Rac.

equalityThreshold :number

# | source: Rac.js, line 68

Value used to determine equality between two numeric values. Used for values that tend to be integers, like screen coordinates. Used by Rac#equals.

When checking for equality x is equal to non-inclusive (x-equalityThreshold, x+equalityThreshold):

  • x is not equal to x ± equalityThreshold
  • x is equal to x ± equalityThreshold/2

Due to floating point precision some opertation like intersections can return odd or oscilating values. This threshold is used to snap values too close to a limit, as to prevent oscilating efects in user interaction.

Default value is based on 1/1000 of a point.

unitaryEqualityThreshold :number

# | source: Rac.js, line 84

Value used to determine equality between two unitary numeric values. Used for values that tend to exist in the [0, 1] range, like Rac.Angle#turn. Used by Rac#unitaryEquals.

Equality logic is the same as Rac#equalityThreshold.

Default value is based on 1/000 of the turn of an arc of radius 500 and length of 1: 1/(500*6.28)/1000

version :string

# | source: Rac.js, line 27

Version of the instance, same as Rac.version.

Methods

equals(a, b) → {boolean}

# | source: Rac.js, line 140

Returns true if the absolute distance between a and b is under Rac#equalityThreshold.

Parameters:
Name Type Description
a number

First number to compare

b number

Second number to compare

setupDrawer(p5Instance)

# | source: Rac.js, line 126

Sets the drawer for the instance. Currently only a p5.js instance is supported.

The drawer will also populate some classes with prototype functions relevant to the drawer. For p5.js this include apply functions for colors and style object, and vertex functions for drawable objects.

Parameters:
Name Type Description
p5Instance P5

unitaryEquals(a, b) → {boolean}

# | source: Rac.js, line 156

Returns true if the absolute distance between a and b is under Rac#unitaryEqualityThreshold.

Parameters:
Name Type Description
a number

First number to compare

b number

Second number to compare