Classes
- Angle
- Arc
- ArcControl
- Bezier
- Color
- Composite
- Control
- Controller
- Exception
- Fill
- P5Drawer
- Point
- Ray
- RayControl
- Segment
- Shape
- Stroke
- StyleContainer
- Text
Members
(static, constant) build :string
Build of the class. Intended for debugging purpouses.
Contains a commit-count and short-hash of the repository when the build was done.
E.g. 904-011be8f
.
(static, constant) TAU :number
Tau, equal to Math.PI * 2
.
(static, constant) utils :utils
Container of utility functions. See utils
for the available
members.
Also available through Rac#utils
.
(static, constant) version :string
Version of the class. Same as the version used for the npm package.
E.g. 1.2.0
.
controller
Controller of the instance. This objecs handles all of the controls
and pointer events related to this instance of Rac
.
drawer :object
Drawer of the instance. This object handles the drawing for all
drawable object created using this
.
equalityThreshold :number
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 tox ± equalityThreshold
x
is equal tox ± 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.
textFormatDefaults :object
Defaults for the optional properties of
Text.Format
.
When a Text
is draw which
format.font
or
format.size
is set to null
, the
values set here are used instead.
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
font |
string
|
<nullable> |
null | Default font, used when drawing a |
size |
number
|
15 | Default size, used when drawing a |
unitaryEqualityThreshold :number
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/1000 of the turn of an arc of radius 500
and length of 1: 1/(500*6.28)/1000
utils :utils
Container of utility functions. See utils
for the available
members.
Also available through Rac.utils
.
Methods
(static) setupDrawableProtoFunctions(drawableClass)
Adds to drawableClass.prototype
all the functions contained in
Rac.drawableProtoFunctions
. These are the functions shared by all
drawable objects, for example draw()
and debug()
.
Parameters:
Name | Type | Description |
---|---|---|
drawableClass |
class
|
Class to setup with drawable functions |
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 |
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
|
The x coordinate for the arc center |
||
y |
number
|
The y coordinate for the arc center |
||
start |
Rac.Angle
|
number
|
The start of the arc |
||
end |
Rac.Angle
|
number
|
<optional> |
null |
The end of the arc; when
ommited or set to |
clockwise |
boolean
|
<optional> |
true |
The orientation of the arc |
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}
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
|
The x coordinate |
y |
number
|
The y coordinate |
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)
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
|
The x coordinate location for the drawn text |
y |
number
|
The y coordinate location for the drawn text |
string |
string
|
The string to draw |
format |
Rac.Text.Format
|
The format for the drawn text |
TextFormat()
Alias of rac.Text.Format
.
To display in documentation along the rest of utility instance functions.
unitaryEquals(a, b) → {boolean}
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 |