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 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
RayControl
Segment
Shape
Stroke
StyleContainer
Text

Members

(static) build :string

# | source: Rac.js, line 263

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 277

Tau, equal to Math.PI * 2.

Tau Manifesto.

(static) utils :object

# | source: Rac.js, line 249

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

(static) version :string

# | source: Rac.js, line 252

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 116

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 95

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

Angle(turn) → {Rac.Angle}

Convenience function that creates a new Angle setup with this.

The function also contains additional methods and properties listed in instance.Angle.

See:
Parameters:
Name Type Description
turn number

The turn value of the angle, in the range [O,1)

Arc(x, y, start, endopt, clockwiseopt) → {Rac.Arc}

Convenience function that creates a new Arc setup with this.

The function also contains additional methods and properties listed in instance.Arc.

See:
Parameters:
Name Type Attributes Default Description
x number
y number
start Rac.Angle | number
end Rac.Angle | number <optional>
null
clockwise boolean <optional>
true

Bezier(startX, startY, startAnchorX, startAnchorY, endAnchorX, endAnchorY, endX, endY) → {Rac.Bezier}

Convenience function that creates a new Bezier setup with this.

The function also contains additional methods and properties listed in instance.Bezier.

See:
Parameters:
Name Type Description
startX number
startY number
startAnchorX number
startAnchorY number
endAnchorX number
endAnchorY number
endX number
endY number

Color(r, g, b, aopt) → {Rac.Color}

Convenience function that creates a new Color setup with this.

The function also contains additional methods and properties listed in instance.Color.

See:
Parameters:
Name Type Attributes Description
r number
g number
b number
a number <optional>

equals(a, b) → {boolean}

# | source: Rac.js, line 143

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

Fill(coloropt) → {Rac.Fill}

Convenience function that creates a new Fill setup with this.

The function also contains additional methods and properties listed in instance.Fill.

See:
Parameters:
Name Type Attributes Description
color Rac.Color <optional>

Point(x, y) → {Rac.Point}

Convenience function that creates a new Point setup with this.

The function also contains additional methods and properties listed in instance.Point.

See:
Parameters:
Name Type Description
x number
y number

Ray(x, y, angle) → {Rac.Ray}

Convenience function that creates a new Ray setup with this.

The function also contains additional methods and properties listed in instance.Ray.

See:
Parameters:
Name Type Description
x number
y number
angle Rac.Angle | number

Segment(x, y, angle, length) → {Rac.Segment}

Convenience function that creates a new Segment setup with this.

The function also contains additional methods and properties listed in instance.Segment.

See:
Parameters:
Name Type Description
x number
y number
angle Rac.Angle | number
length number

setupDrawer(p5Instance)

# | source: Rac.js, line 129

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

Stroke(weightnullable, colornullable) → {Rac.Stroke}

Convenience function that creates a new Stroke setup with this.

The function also contains additional methods and properties listed in instance.Stroke.

See:
Parameters:
Name Type Attributes Description
weight number <nullable>
color Rac.Color <nullable>

Style(strokenullable, fillnullable) → {Rac.Style}

Convenience function that creates a new Style setup with this.

The function also contains additional methods and properties listed in instance.Style.

See:
  • instance.Style
Parameters:
Name Type Attributes Description
stroke Rac.Stroke <nullable>
fill Rac.Fill <nullable>

Text(x, y, string, format) → {Rac.Text}

Convenience function that creates a new Text setup with this.

The function also contains additional methods and properties listed in instance.Text.

See:
Parameters:
Name Type Description
x number
y number
string string
format Rac.Text.Format

unitaryEquals(a, b) → {boolean}

# | source: Rac.js, line 159

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