Extends OBJ_Collection
CollectionsAngle options object that extends OBJ_Collection
options object (without parent).
The Collections Angle is a convient and powerful angle FigureElementCollection that can draw one or several arcs of an angle annotation, a label, arrows, and the corner of an angle. It also includes some methods to make it convient to use dynamically.
There are two ways to define an angle. With a position, startAngle and
angle, or with three points. The angle can then be annotated with a curve
and a label on either side of the corner using the direction property.
The first way to define an angle is with position, startAngle and
angle. position is the location of the vertex of the corner.
Two lines join to make a corner, from which an angle annotation can be
superimposed. The first line is defined with startAngle and the second
line defined by angle relative to the first line. angle can either be
positive or negative to define the second line.
The second way to define an angle is with three points p1, p2 and p3.
p2 is the vertex position of the corner. Line21 is first line of the
corner and Line23 is the second.
An angle can be annotated with a curve (or many multiple curves) and a
label. direction defines which side of the corner the annotations will
be drawn. direction can either be positive or negative (1 or -1).
A positive direction will place the annotations:
startAngle and angleA negative direction will place the annotations on the other side of the corner.
A curve with multiple lines and/or arrows can be defined with curve.
A label that can be the real angle in degrees or radians, text or an
equation can be defined with label.
The annotations will be placed at some radius from the corner vertex.
offset can be used to draw the line some offset away from the line
definition where a positive offset is on the side of the line that the line
rotates toward when rotating in the positive direction.
Pulsing this collection normally would pulse the scale of everything.
If it often desirable to pulse only parts of the angle in special ways.
Therefore this collection provides a method pulseAngle to allow this.
This options object can define the default values for pulseAngle if desired.
rotation where the angle should start
size of the angle
alternate way to define startAngle with p2 and p3
alternate way to define position of the angle vertex
with p2 and p3
alternate way to define size of angle with p2 and
p3
side of the corner the angle annotations reside
options for a curve annotation
options for arrow annotations
options for drawing a corner
options for label annotations
default pulseAngle options
FigureElementCollection representing an angle.



This object defines a convient and powerful angle FigureElementCollection that includes one or more curve annotations, arrows, a label annotation that can self align and some methods to make it convient to use dynamically.
See COL_Angle for the options that can be used when creating the angle.
The object contains two additional animation steps angle and pulseAngle
that animate a change in angle, and animate a pulsing of the angle
respectively. The animation steps are available in
the animation manager ( FigureElement.animations),
and in the animation builder
(animations.new
and animations.builder).
Some of the useful methods included in an collections angle are:
figure.add({
name: 'a',
make: 'collections.angle',
angle: Math.PI / 4,
label: null,
curve: {
radius: 0.5,
width: 0.01,
},
corner: {
width: 0.01,
length: 1,
},
});
const a = figure.collections.angle({
angle: Math.PI / 2,
curve: {
autoRightAngle: true,
width: 0.01,
},
corner: {
width: 0.01,
length: 1,
},
});
figure.add('a', a);
figure.add({
name: 'a',
make: 'collections.angle',
angle: Math.PI / 4 * 3,
label: {
text: {
elements: {
theta: { text: '\u03b8', color: [1, 0, 1, 1] },
},
forms: {
0: { frac: ['theta', 'vinculum', '2']},
},
},
offset: 0.05,
location: 'inside',
color: [0, 0, 1, 1],
},
curve: {
radius: 0.5,
width: 0.01,
},
arrow: 'barb',
corner: {
width: 0.01,
length: 1,
color: [0, 0.5, 0, 1],
},
});
const a = figure.collections.angle({
angle: Math.PI / 4,
curve: {
num: 3,
step: -0.03,
radius: 0.5,
width: 0.01,
},
label: {
text: 'a',
offset: 0.05,
},
});
figure.add('a', a);
figure.add({
name: 'a',
make: 'collections.angle',
angle: Math.PI / 4,
label: null,
curve: {
radius: 0.5,
width: 0.01,
},
corner: {
width: 0.01,
length: 1,
},
});
figure.elements._a.animations.new()
.angle({ start: Math.PI / 4, target: Math.PI / 4 * 3, duration: 3 })
.start();
figure.add({
name: 'a',
make: 'collections.angle',
angle: Math.PI / 4 * 3,
label: {
text: null,
location: 'outside',
orientation: 'horizontal',
offset: 0.1,
update: true,
sides: 200,
},
curve: {
radius: 0.3,
fill: true,
},
corner: {
width: 0.02,
length: 1,
color: [0.4, 0.4, 0.4, 1],
},
});
figure.elements._a.setMovable({
startArm: 'rotation',
endArm: 'angle',
movePadRadius: 0.3,
});
See OBJ_AngleAnimationStep for angle animation step options.
See OBJ_PulseAngleAnimationStep for pulse angle animation step options.
To test examples below, append them to the boilerplate.
Extends OBJ_Collection
CollectionsAxis options object that extends OBJ_Collection
options object (without parent).
A zoom axis can be used to create a number line, used as an axis in COL_Plot and/or used to plot a COL_Trace against.
An axis is a line that may have
An axis is drawn to a length. It will have values along its length
from start to stop. Ticks, grid lines and labels are all drawn
at axis value positions. All other dimensions, such as line lengths,
widths, positions, spaces and offsets are defined in draw space, or in the
same space as the length of the axis.
'x' axes are horizontal, 'y' axes are
vertical
length of the axis in draw space
line style of the axis -
false will draw no line. By default, a solid line will be drawn if not
defined.
start value of axis
stop value of axis. stop must be larger than
start
tick options. Use an Array to setup multiple sets/styles of ticks. Use a boolean value to turn ticks on or off. Use a TypeTickLocation to only set tick location property
label options. Use false to turn labels off, or a string or function as
a callback to define custom labels for a set of values. Use
TypeLabelLocation to only set the label location property.
grid options. Use an array for multiple sets of grids, and use a boolean to turn grids on and off
axis title
default font of axis
false hides the axis. Two axes are needed
to plot an CollectionsTrace on a CollectionsPlot, but if either or
both axes aren't to be drawn, then use false to hide each axis
Will select automatic values for
start, stop, and step that cover the range [min, max]
If true then start, stop and
step tick, grid and label values will be automatically calculated such that
they land on 0 and either double/half the original step (true) or ensure
the steps land on factors of 10 ('decimal'). This needs to be not false
if panning or zooming. If false, then the tick, grid and label values will
be from the start, stop and step properties.
minimum value axis can be zoomed or panned to
where null no limit
maximum value axis can be zoomed or panned to
where null no limit
axis position
custom values for labels, ticks and grid. Only works for one level of ticks and grid, and doesn't not accomodate zooming or panning.
FigureElementCollection representing an Axis.





This object defines an axis with an axis line, tick marks, labels, grid lines and a title.
See COL_Axis for the options that can be used when creating the axis.
An axis is drawn to a length. It will have values along its length
from start to stop. Ticks, grid lines and labels are all drawn
at axis value positions. All other dimensions, such as line lengths,
widths, positions, spaces and offsets are defined in draw space, or in the
same space as the length of the axis.
The object contains additional methods that convert between axis values and draw space positions, as well as a convenience method to report if a value is within an axis.
To test examples below, append them to the boilerplate.
For more examples of axis labels and axis ticks, see OBJ_AxisLabels and OBJ_AxisTicks.
figure.add({
make: 'collections.axis',
});
// An axis can have specific start and stop values
// An axis can be a y axis
const axis = figure.collections.axis({
axis: 'y',
start: -10,
stop: 10,
step: 5,
});
figure.add('axis', axis);
figure.add({
make: 'collections.axis',
step: [0.2, 0.05],
ticks: [
true,
{ length: 0.04, location: 'bottom' },
],
title: 'time (s)',
});
// and have arrows
figure.add({
make: 'collections.axis',
length: 2.5,
start: -100,
stop: 100,
step: 25,
line: {
dash: [0.01, 0.01],
arrow: 'barb',
},
ticks: { dash: [0.01, 0.01] },
title: {
font: { style: 'italic', family: 'Times New Roman' },
text: 'x',
location: 'right',
},
});
// multi-line, formatted titles
figure.add({
make: 'collections.axis',
stop: 2,
step: [0.5, 0.1],
grid: [
{ length: 1, color: [0.5, 0.5, 0.5, 1] },
{ length: 1, dash: [0.01, 0.01], color: [0.7, 0.7, 0.7, 1] },
],
title: {
font: { color: [0.4, 0.4, 0.4, 1] },
text: [
'Total Time',
{
text: 'in seconds',
font: { size: 0.1 },
lineSpace: 0.12,
},
],
},
});
COL_Axis for parameter descriptions
Extends OBJ_Collection
CollectionsButton options object that extends OBJ_Collection
options object (without parent).
button width
button height
button corner
button outline - use null to
remove the default line
button label
set colors between a touch down and touch up
FigureElementCollection representing a button.


A button can be simple, or it can change state with each press.
Notifications - The notification manager property notifications will
publish the following events:
touch: button is pressed - the current state index is passed to the
subscriberSee COL_Button for setup options.
To test examples below, append them to the boilerplate
figure.add({
make: 'collections.button',
label: 'Start',
});
figure.add({
make: 'collections.button',
label: 'Start',
colorFill: [0.8, 0.8, 0.8, 1],
line: null,
});
const button = figure.add({
make: 'collections.button',
states: ['Slow', 'Medium', 'Fast'],
width: 0.7,
height: 0.3,
touchBorder: 0.1,
});
button.notifications.add('touch', (index) => {
console.log(index);
});
Extends OBJ_Collection
CollectionsLine options object that extends OBJ_Collection
options object (without parent).
The Collections Line is a convient and powerful line FigureElementCollection that includes the line, arrows, a label annotation and some methods to make it convient to use dynamically.
A line can either be defined by its two end points (p1, p2), or a
point (p1), length and angle.
offset can be used to draw the line some offset away from the line
definition where a positive offset is on the side of the line that the line
rotates toward when rotating in the positive direction. This is especially
useful for creating lines that show dimensions of shapes.
The line also has a control point which is positioned on the line with the
align property. The control point is the line's center of rotation, and
fixes the point from which the line changes length. This is also the point
where the line collection position will be if getPosition is called on the
element.
For instance, setting the control point at align: 'start' will mean that
if the line can rotate, it will rotate around p1, and if the length is
changed, then p1 will remain fixed while p2 changes.
width sets the width of the line. Setting the width to 0 will hide the
line itself, but if arrows or a label are defined they will still be
displayed.
Use the label property to define and position a label relative to the line.
The label can be any string, equation or the actual length of the line and
be oriented relative to the line or always be horizontal.
Use the arrow and dash properties to define arrows and the line style.
Pulsing this collection normally would pulse both the length and width of
the line. If it often desirable to pulse a line without changing its length,
and so this collection provides a method pulseWidth to allow this. This
options object can define the default values for pulseWidth if desired.
Default pulse values can then be specified with the pulse property.
First point of line
Will override length/angle definition
line angle
line length
line offset
rotation center of line
line width
label annotation
line arrow
make the line dashed
default options for pulseWidth pulse
default options for normal pulse
line move options
FigureElementCollection representing a line.



This object defines a convient and powerful line FigureElementCollection that includes a solid or dashed line, arrows, a label annotation that can self align with line orientation, and some methods to make it convient to use dynamically.
See COL_Line for the options that can be used when creating the line.
The object contains a two additional animation steps. length
animates changing the line length, and pulseWidth animates the
pulseWidth method. The animation steps are available in
the animation manager ( FigureElement.animations),
and in the animation builder
(animations.new
and animations.builder).
Some of the useful methods included in an collections line are:
length animation
stepfigure.add({
name: 'l',
make: 'collections.line',
p1: [-1, 0],
p2: [1, 0],
arrow: 'triangle',
label: {
text: 'length',
offset: 0.04,
},
});
figure.elements._l.pulseWidth({ duration: 2 });
figure.add({
name: 'l',
make: 'collections.line',
p1: [-1, 0],
p2: [-0.5, 0],
align: 'start',
arrow: { end: { head: 'barb', scale: 2 } },
label: {
text: null,
offset: 0.03,
precision: 2,
location: 'start'
},
});
const l = figure.elements._l;
l.animations.new()
.length({ start: 0.5, target: 2, duration: 2 })
.start();
const l = figure.collections.line({
p1: [0, 0],
p2: [1.4, 0],
align: 'start',
label: {
text: { // label text is an equation
elements: {
twopi: '2\u03C0',
},
forms: {
base: ['twopi', ' ', { frac: ['a', 'vinculum', 'b'] } ]
},
},
offset: 0.03,
orientation: 'horizontal', // keep label horizontal
location: 'top', // keep label on top of line
},
dash: [0.08, 0.02, 0.02, 0.02],
});
figure.add('l', l);
l.setMovable({ type: 'centerTranslateEndRotation'})
l.setAutoUpdate();
See OBJ_LengthAnimationStep for angle animation step options.
See OBJ_PulseWidthAnimationStep for pulse angle animation step options.
To test examples below, append them to the boilerplate.
Extends OBJ_Collection
CollectionsPlot options object that extends OBJ_Collection
options object (without parent).
A plot is a collection of axes and traces, and may include a title, legend and bounding frame.
Use width, height and position to define the size of the plot area
(area where the traces are drawn) and where it is in the figure.
width of the plot area
height of the plot area
customize the x axis, or use false
to hide it
customize the y axis, or use false
to hide it
add axes additional to x and y
turn on and off the grid - use the grid options in x axis, y axis or axes for finer customization
plot title can be simply a
string or fully customized with OBJ_PlotTitle
Use array if plotting more than one trace. Use COL_Trace to customize the trace.
true to turn the legend on,
or use COL_PlotLegend to customize it's location and layout
frame around the
plot can be turned on with true, can be a simple color fill using
Array<number> as a color, or can be fully customized with OBJ_PlotFrame
plot area can be a
color fill with TypeColor as a color, or be fully customized with
COL_Rectangle
Default font for plot
Default color
Position of the plot
options for interactive zooming
options for interactive panning
value where the default x and y
axes should cross. If defined, each axis.position will be overridden. If
the cross point is outside of the plot area, then the axes will be drawn on
the border of the plot area.
if true
then axes with a cross point
will be drawn such that the labels stay within the plot area. So, if the
labels are on the left side of a y axis, and the cross point is out of the
plot area to the left, then instead of the axis being drawn on the left edge
of the plot area, it will be drawn within the plot area such that its labels
are within the plot area (false).
if true sets the grid for an axes to expand
accross the entire plot area. Set to false if only a partial length grid
is needed
defines default values for tick, label, axis locations and cross points.
defines defaul colors. 'dark'
theme is better on light backgrounds while 'light' theme is better on dark
backgrounds
the gesture area is the plot area by default. Use this property to extend the gesture area beyond the plot area. This is useful for the user to zoom in on areas on the edge of the plot area.
FigureElementCollection representing a plot including axes, traces, labels and titles.







This object provides convient and customizable plot functionality.
At its simplist, just the points of the trace to be plotted need to be passed in to get a plot with automatically generated axes, tick marks, labels and grid lines.
Additional options can be used to finely customize each of these, as well as add and customize plot and axis titles, a legend, and a frame around the entire plot.
Plots can also be interactive, with both zoom and pan functionality from mouse, mouse wheel, touch and pinch gestures.
figure.add({
make: 'collections.plot',
trace: pow(),
});
// Some traces are customized beyond the default color to include dashes and
// markers
figure.add({
make: 'collections.plot',
width: 2, // Plot width in figure
height: 2, // Plot height in figure
y: { start: 0, stop: 50 }, // Customize y axis limits
trace: [
{ points: pow(1.5), name: 'Power 1.5' }, // Trace names are for legend
{ // Trace with only markers
points: pow(2, 0, 10, 0.5),
name: 'Power 2',
markers: { sides: 4, radius: 0.03 },
},
{ // Trace with markers and
points: pow(3, 0, 10, 0.5), // dashed line
name: 'Power 3',
markers: { radius: 0.03, sides: 10, line: { width: 0.005 } },
line: { dash: [0.04, 0.01] },
},
],
legend: true,
});
figure.add({
make: 'collections.plot',
y: {
start: -50,
stop: 50,
step: [25, 5],
grid: [
true,
{ width: 0.005, dash: [0.01, 0.01], color: [1, 0.7, 0.7, 1] },
],
title: 'velocity (m/s)',
},
x: {
start: -5,
stop: 5,
step: [2.5, 0.5, 0.1],
grid: [
true,
{ width: 0.005, dash: [0.01, 0.01], color: [1, 0.7, 0.7, 1] },
],
title: 'time (s)',
},
trace: pow(3, -10, 10),
title: 'Velocity over Time',
});
// Use plot frame and plot area
// Title has a subtitle
figure.add({
make: 'collections.plot',
trace: pow(3),
x: { show: false },
y: { show: false },
plotArea: [0.93, 0.93, 0.93, 1],
frame: {
line: { width: 0.005, color: [0.5, 0.5, 0.5, 1] },
corner: { radius: 0.1, sides: 10 },
space: 0.15,
},
title: {
text: [
'Velocity over Time',
{ text: 'For object A', lineSpace: 0.13, font: { size: 0.08 } },
],
offset: [0, 0],
},
});
figure.add({
make: 'collections.plot',
trace: pow(2),
y: {
title: {
text: 'velocity (m/s)',
rotation: 0,
xAlign: 'right',
},
},
x: { title: 'time (s)' },
axes: [
{
axis: 'y',
start: 0,
stop: 900,
step: 300,
color: [1, 0, 0, 1],
location: 'right',
title: {
offset: [0.6, 0.1],
text: 'displacment (m)',
rotation: 0,
},
},
],
position: [-1, -1],
});
// Automatic layout doesn't support this, but axes, ticks, labels and titles
// can all be customized to create it.
figure.add({
make: 'collections.plot',
trace: pow(3, -10, 10),
font: { size: 0.1 },
styleTheme: 'numberLine',
x: {
title: {
text: 'x',
font: { style: 'italic', family: 'Times New Roman', size: 0.15 },
},
},
y: {
step: 500,
title: {
text: 'y',
font: { style: 'italic', family: 'Times New Roman', size: 0.15 },
},
},
grid: false,
});
// Create the points for the plot
const points = Array(3000).fill(0).map(() => {
const x = Math.random() * 8 - 4;
const y = Math.random() / Math.sqrt(2 * Math.PI) * Math.exp(-0.5 * x ** 2);
return [x, y];
});
// Make a zoomable and pannable plot
const plot = figure.add({
make: 'collections.plot',
trace: { points, markers: { sides: 6, radius: 0.01 } },
zoom: { axis: 'xy', min: 0.5, max: 16 },
pan: true,
});
// Initialize by zooming in by a magnification factor of 10
plot.zoomValue([1.8333, 0.06672], 10);
See COL_Axis, OBJ_AxisLabels, OBJ_AxisTicks, COL_Trace and COL_PlotLegend for more examples of customizing specific parts of the plot.
To test examples below, append them to the boilerplate.
All examples below also use this power function to generate the traces:
const pow = (pow = 2, start = 0, stop = 10, step = 0.05) => {
const xValues = Fig.range(start, stop, step);
return xValues.map(x => new Fig.Point(x, x ** pow));
}
Extends OBJ_Collection
CollectionsPolyline options object that extends
OBJ_Polyline and OBJ_Collection
options object (without parent).
The Collections Polyline is a convient and powerful polyline FigureElementCollection that includes the polyline, angle annotations, side label and arrow annotations, and movable pads on each polyline point for the user to adjust dynamically.
The polyline itself is defined with an OBJ_Polyline options Object.
Angle and side annotations can be defined as COL_Angle and COL_Line, and movable pads defined with ( OBJ_Polygon & OBJ_PolylinePad).
Angles, sides and pads can all be defined either as an options object or an array of options objects. If an array, then each element in the array will correspond with a pad on the polyline. If there are less elements in the array than pads on the polyline, then the elements will recycle from the start.
Using object definitions allows for a definition of all angles, sides and pads. To customize for specific side, angle or pad indexes use = OBJ_PolylineCustomization.
false will hide the polyline's line
angle annotations - leave undefined for no angle annotations
side annotations - leave undefined for no side annotations
move pad - leave undefined for no move pads
if defined, whenever points are updated the shape will be checked to ensure consistency with displayed labels of angles and sides.
default font to use for labels
FigureElementCollection representing a polyline.



This object defines a convient and powerful polyline FigureElementCollection that includes a solid or dashed, open or closed polyline, arrows, angle annotations for polyline corners, side annotations for straight lines between points and move pads at polyline points to dynamically adjust the polyline.
See COL_Polyline for the options that can be used when creating the line.
Available notifications:
'updatePoints': SUB_PolylineUpdatePointsfigure.add({
name: 'p',
make: 'collections.polyline',
points: [[1, 0], [0, 0], [0.5, 1], [1.5, 1]],
arrow: 'triangle',
angle: {
label: null,
curve: {
radius: 0.3,
},
}
});
figure.add({
name: 'p',
make: 'collections.polyline',
points: [[1, 1], [1, 0], [0, 0]],
close: true,
side: {
label: null,
},
angle: {
label: {
text: '?',
offset: 0.05,
},
curve: {
radius: 0.4,
},
show: [1],
},
});
figure.add({
name: 'p',
make: 'collections.polyline',
points: [[0, 1], [1, 1], [1, 0], [0, 0]],
close: true,
side: {
showLine: true,
offset: 0.2,
color: [0, 0, 1, 1],
arrow: 'barb',
width: 0.01,
label: null,
dash: [0.05, 0.02],
0: { label: { text: 'a' } }, // Customize side 0
},
angle: {
curve: {
autoRightAngle: true,
radius: 0.3,
},
},
});
figure.add({
name: 'p',
make: 'collections.polyline',
points: [[-0.5, 1], [1, 1], [0, 0], [1, -0.5]],
dash: [0.05, 0.02],
pad: {
radius: 0.2,
color: [1, 0, 0, 0.5], // make alpha 0 to hide pad
isMovable: true,
},
});
figure.add({
name: 'p',
make: 'collections.polyline',
points: [[-1, 1], [1, 1], [0, 0]],
close: true,
makeValid: {
shape: 'triangle',
hide: {
minAngle: Math.PI / 8,
},
},
side: {
showLine: true,
offset: 0.2,
color: [0.3, 0.6, 1, 1],
arrow: 'barb',
width: 0.01,
label: {
text: null,
},
},
angle: {
label: null,
curve: { radius: 0.25 },
},
pad: {
radius: 0.4,
color: [1, 0, 0, 0.005],
isMovable: true,
},
});
To test examples below, append them to the boilerplate.
Extends OBJ_Collection
CollectionsRectangle options object that extends OBJ_Collection
options object (without parent).
This rectangle is similar to OBJ_Rectangle, except it can accomodate both a fill and a border or line simultaneously with different colors.
rectangle width
rectangle height
horiztonal alignment of the rectangle
vertical alignment of the rectangle
lines style - leave empty if only want fill
fill color or texture
corner style of rectangle
Rectangle label
true to
make the rectangle behave like a button when clicked. TypeColor to
make fill, line and label the same color when clicked or OBJ_ButtonColor
to specify click colors for each
FigureElementCollection representing a rectangle.



This object defines a rectangle FigureElementCollection that may include:
Surrounding another element can be executed through either the surround method or the OBJ_SurroundAnimationStep found in the in the animation manager ( FigureElement.animations), and in the animation builder (animations.new and animations.builder).
Button behavior means the button will temporarily change a different color when it is clicked. By default, the button will become a little more transparent, but colors for the fill, label and border can also be specified.
figure.add({
name: 'rect',
make: 'collections.rectangle',
width: 2,
height: 1,
});
const rect = figure.collections.rectangle({
width: 2,
height: 1,
line: {
width: 0.02,
widthIs: 'outside',
dash: [0.1, 0.02],
},
corner: {
radius: 0.2,
sides: 10,
},
fill: [0.7, 0.7, 1, 1],
});
figure.add('rect', rect);
figure.add([
{
name: 'rect',
make: 'collections.rectangle',
color: [0.3, 0.3, 1, 1],
line: { width: 0.01 },
},
{
name: 'eqn',
make: 'equation',
forms: { 0: [{ frac: ['a', 'vinculum', 'b'] }, ' ', 'c'] },
position: [1, 0],
scale: 1.5,
}
]);
const rect = figure.getElement('rect');
const eqn = figure.getElement('eqn');
rect.surround(eqn._a, 0.03);
rect.animations.new()
.pulse({ delay: 1, scale: 1.5 })
.surround({ target: eqn._b, space: 0.03, duration: 1 })
.pulse({ delay: 1, scale: 1.5 })
.surround({ target: eqn._c, space: 0.03, duration: 1 })
.pulse({ delay: 1, scale: 1.5 })
.start();
figure.add([
{
name: 'rect',
make: 'collections.rectangle',
width: 0.5,
height: 0.3,
color: [0.3, 0.3, 0.3, 1],
label: 'Save',
corner: { radius: 0.05, sides: 10 },
fill: [0.9, 0.9, 0.9, 1],
button: {
fill: [0.95, 0.95, 0.95, 1],
},
mods: {
isTouchable: true,
onClick: () => console.log('clicked'),
},
},
]);
See COL_Rectangle for setup options.
See OBJ_SurroundAnimationStep for surround animation step options.
To test examples below, append them to the boilerplate.
Extends OBJ_Collection
CollectionsSlider options object that extends OBJ_Collection
options object (without parent).
slider width
slider height
height of slider bar bar
number of sides in curves
marker style
selects default colors for a light or dark switch
slider off color
slider on color (bar color from 0 to slider value
border around circle
border around bar
FigureElementCollection representing a slider control.


Notifications - The notification manager property notifications will
publish the following events:
changed: slider value is changed - slider position in percent is passed
as parameter to callback.See COL_Slider for setup options.
To test examples below, append them to the boilerplate
const slider = figure.add({
make: 'collections.slider',
barHeight: 0.02,
height: 0.1,
width: 1,
color: [0.5, 0.5, 0.5, 1],
touchBorder: 0.2,
});
slider.notifications.add('changed', (position) => {
console.log(position)
});
figure.add({
make: 'collections.slider',
barHeight: 0.1,
colorOn: [1, 0, 0, 1],
width: 1,
touchBorder: 0.2,
marker: 'none',
});
const slider = figure.add({
make: 'collections.slider',
barHeight: 0.02,
height: 0.1,
width: 1,
marker: 'rectangle',
colorOff: [1, 0, 0, 1],
colorOn: [0, 0.8, 0, 1],
color: [0, 0, 0, 1],
});
Extends OBJ_Collection
CollectionsToggle options object that extends OBJ_Collection
options object (without parent).
toggle width
toggle height
height of toggle bar showing on or off
number of sides in curves
selects default colors for a light or dark switch
toggle off color
toggle on color
border around circle
border around bar
FigureElementCollection representing a toggle switch.

The toggle switch can be turned on or off.
Notifications - The notification manager property notifications will
publish the following events:
toggle: switch is changed - true will be passed if the switch is
changed to on, and false will be passed if the switch is changed to offon: switch is changed to onoff: switch is changed to offSee COL_Toggle for setup options.
To test examples below, append them to the boilerplate
const toggle = figure.add({
make: 'collections.toggle',
label: {
text: 'Control',
location: 'bottom',
scale: 0.6,
},
});
toggle.notifications.add('toggle', (state) => {
state ? console.log('on') : console.log('off');
});
FigureElementCollection options object.

A collection is a group of other FigureElements that will all inherit the parent collections transform.
if defined, will overwrite first
translation of transform
default color
parent of collection
defines border of collection. Use children to use the borders of
the children. Use 'rect' for the bounding rectangle of the borders
of the children. Use TypeParsableBuffer for the bounding rectangle of the
borders of the children with some buffer. Use TypeParsableBorder for
a custom border.
defines the touch border of the collection. Use 'border' to use the same
as the border of the collection. Use children to use the touch borders of
the children. Use 'rect' for the bounding rectangle of the touch borders
of the children. Use TypeParsableBuffer for the bounding rectangle of the
touch borders of the children with some buffer. Use TypeParsableBorder for
a custom touch border.
figure.add(
{
name: 'c',
make: 'collection',
elements: [ // add two elements to the collection
{
name: 'hex',
make: 'polygon',
sides: 6,
radius: 0.5,
},
{
name: 'text',
make: 'text',
text: 'hexagon',
position: [0, -0.8],
xAlign: 'center',
font: { size: 0.3 },
},
],
},
);
// When a collection rotates, then so does all its elements
figure.getElement('c').animations.new()
.rotation({ target: Math.PI * 1.999, direction: 1, duration: 5 })
.start();
figure.collections// and `figure.primitives`.
const c = figure.collections.collection();
const hex = figure.primitives.polygon({
sides: 6,
radius: 0.5,
});
const text = figure.primitives.text({
text: 'hexagon',
position: [0, -0.8],
xAlign: 'center',
font: { size: 0.3 },
});
c.add('hex', hex);
c.add('text', text);
figure.add('c', c);
// When a collection rotates, then so does all its elements
c.animations.new()
.delay(1)
.rotation({ target: Math.PI * 1.999, direction: 1, duration: 5 })
.start();
position of the angle vertex