figureone 0.15.10 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/figureone.min.js +1 -1
- package/index.js +79167 -0
- package/package.json +15 -1
- package/types/index.d.ts +132 -0
- package/types/js/figure/Animation/Animation.d.ts +36 -0
- package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
- package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
- package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
- package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
- package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
- package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
- package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
- package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
- package/types/js/figure/DrawContext2D.d.ts +9 -0
- package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
- package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
- package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
- package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
- package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
- package/types/js/figure/Element.d.ts +1212 -0
- package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
- package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
- package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
- package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
- package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
- package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
- package/types/js/figure/Equation/Equation.d.ts +984 -0
- package/types/js/figure/Equation/EquationForm.d.ts +139 -0
- package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
- package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
- package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
- package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
- package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
- package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
- package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
- package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
- package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
- package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
- package/types/js/figure/Figure.d.ts +711 -0
- package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
- package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
- package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
- package/types/js/figure/FigureCollections/Button.d.ts +195 -0
- package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
- package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
- package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
- package/types/js/figure/FigureCollections/Line.d.ts +587 -0
- package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
- package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
- package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
- package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
- package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
- package/types/js/figure/FigureCollections/Text.d.ts +307 -0
- package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
- package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
- package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
- package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
- package/types/js/figure/FontManager.d.ts +113 -0
- package/types/js/figure/Gesture.d.ts +39 -0
- package/types/js/figure/Recorder/Recorder.d.ts +291 -0
- package/types/js/figure/Recorder/parseState.d.ts +3 -0
- package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
- package/types/js/figure/Recorder/state.d.ts +7 -0
- package/types/js/figure/SlideNavigator.d.ts +606 -0
- package/types/js/figure/TimeKeeper.d.ts +174 -0
- package/types/js/figure/geometries/arc.d.ts +18 -0
- package/types/js/figure/geometries/arrow.d.ts +215 -0
- package/types/js/figure/geometries/buffer.d.ts +4 -0
- package/types/js/figure/geometries/copy/copy.d.ts +178 -0
- package/types/js/figure/geometries/ellipse.d.ts +17 -0
- package/types/js/figure/geometries/line.d.ts +13 -0
- package/types/js/figure/geometries/lines/corners.d.ts +7 -0
- package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
- package/types/js/figure/geometries/lines/lines.d.ts +31 -0
- package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
- package/types/js/figure/geometries/rectangle.d.ts +19 -0
- package/types/js/figure/geometries/triangle.d.ts +27 -0
- package/types/js/figure/webgl/Atlas.d.ts +42 -0
- package/types/js/figure/webgl/shaders.d.ts +143 -0
- package/types/js/figure/webgl/target.d.ts +9 -0
- package/types/js/figure/webgl/webgl.d.ts +54 -0
- package/types/js/tools/FunctionMap.d.ts +69 -0
- package/types/js/tools/color.d.ts +11 -0
- package/types/js/tools/colorNames.d.ts +2 -0
- package/types/js/tools/d2/polygon.d.ts +60 -0
- package/types/js/tools/d2/triangles.d.ts +0 -0
- package/types/js/tools/d3/cone.d.ts +57 -0
- package/types/js/tools/d3/cube.d.ts +26 -0
- package/types/js/tools/d3/cylinder.d.ts +45 -0
- package/types/js/tools/d3/line3.d.ts +55 -0
- package/types/js/tools/d3/prism.d.ts +49 -0
- package/types/js/tools/d3/revolve.d.ts +87 -0
- package/types/js/tools/d3/sphere.d.ts +33 -0
- package/types/js/tools/d3/surface.d.ts +47 -0
- package/types/js/tools/g2.d.ts +242 -0
- package/types/js/tools/geometry/Bounds.d.ts +446 -0
- package/types/js/tools/geometry/Line.d.ts +314 -0
- package/types/js/tools/geometry/Path.d.ts +67 -0
- package/types/js/tools/geometry/Plane.d.ts +201 -0
- package/types/js/tools/geometry/Point.d.ts +359 -0
- package/types/js/tools/geometry/Rect.d.ts +115 -0
- package/types/js/tools/geometry/Transform.d.ts +623 -0
- package/types/js/tools/geometry/angle.d.ts +105 -0
- package/types/js/tools/geometry/common.d.ts +9 -0
- package/types/js/tools/geometry/coordinates.d.ts +30 -0
- package/types/js/tools/geometry/deceleration.d.ts +13 -0
- package/types/js/tools/geometry/polygon.d.ts +4 -0
- package/types/js/tools/geometry/quaternion.d.ts +15 -0
- package/types/js/tools/geometry/scene.d.ts +282 -0
- package/types/js/tools/geometry/tools.d.ts +8 -0
- package/types/js/tools/geometry/types.d.ts +2 -0
- package/types/js/tools/getCssColors.d.ts +1 -0
- package/types/js/tools/getCssVariables.d.ts +4 -0
- package/types/js/tools/getImageData.d.ts +1 -0
- package/types/js/tools/getScssColors.d.ts +2 -0
- package/types/js/tools/htmlGenerator.d.ts +85 -0
- package/types/js/tools/m2.d.ts +24 -0
- package/types/js/tools/m3.d.ts +71 -0
- package/types/js/tools/math.d.ts +112 -0
- package/types/js/tools/morph.d.ts +651 -0
- package/types/js/tools/styleSheets.d.ts +3 -0
- package/types/js/tools/tools.d.ts +281 -0
- package/types/js/tools/types.d.ts +305 -0
- package/figureone.worker.js +0 -1
|
@@ -0,0 +1,1212 @@
|
|
|
1
|
+
import { Transform, Point, Rect, Plane } from '../tools/g2';
|
|
2
|
+
import Scene from '../tools/geometry/scene';
|
|
3
|
+
import type { OBJ_Scene } from '../tools/geometry/scene';
|
|
4
|
+
import type { TypeParsablePoint, TypeParsableTransform, TypeBorder, TypeParsableBuffer, TypeParsableBounds, TypeParsablePlane } from '../tools/g2';
|
|
5
|
+
import { Recorder } from './Recorder/Recorder';
|
|
6
|
+
import * as m3 from '../tools/m3';
|
|
7
|
+
import type { Type3DMatrix } from '../tools/m3';
|
|
8
|
+
import DrawingObject from './DrawingObjects/DrawingObject';
|
|
9
|
+
import { NotificationManager } from '../tools/tools';
|
|
10
|
+
import TimeKeeper from './TimeKeeper';
|
|
11
|
+
import type { TypeWhen } from './TimeKeeper';
|
|
12
|
+
import type { OBJ_SpaceTransforms, OBJ_FigureForElement } from './Figure';
|
|
13
|
+
import * as animations from './Animation/Animation';
|
|
14
|
+
import WebGLInstance from './webgl/webgl';
|
|
15
|
+
import { FunctionMap } from '../tools/FunctionMap';
|
|
16
|
+
import type { TypeColor, TypeCoordinateSpace } from '../tools/types';
|
|
17
|
+
import type { OBJ_Touch } from './FigurePrimitives/FigurePrimitiveTypes';
|
|
18
|
+
import type FigureCollections from './FigureCollections/FigureCollections';
|
|
19
|
+
import Atlas from './webgl/Atlas';
|
|
20
|
+
/**
|
|
21
|
+
* Add element Object
|
|
22
|
+
* @interface
|
|
23
|
+
* @group Misc Figure Element
|
|
24
|
+
*/
|
|
25
|
+
export type OBJ_AddElement = {
|
|
26
|
+
path?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
make?: string;
|
|
29
|
+
options?: Record<string, any>;
|
|
30
|
+
elements?: Array<OBJ_AddElement | FigureElement>;
|
|
31
|
+
mods?: {};
|
|
32
|
+
scenario?: string;
|
|
33
|
+
position?: TypeParsablePoint;
|
|
34
|
+
transform?: TypeParsableTransform;
|
|
35
|
+
color?: TypeColor;
|
|
36
|
+
touch?: boolean | OBJ_Touch;
|
|
37
|
+
move?: boolean | OBJ_ElementMove;
|
|
38
|
+
dimColor?: TypeColor;
|
|
39
|
+
defaultColor?: TypeColor;
|
|
40
|
+
scenarios?: OBJ_Scenarios;
|
|
41
|
+
scene?: Scene | OBJ_Scene;
|
|
42
|
+
touchScale?: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Transform, color and visbility scenario definition
|
|
46
|
+
*
|
|
47
|
+
* `translation` will overwirte `position`, and `translation, `position`,
|
|
48
|
+
* rotation` and `scale` overwrite the first equivalent transforms in
|
|
49
|
+
* `transform`
|
|
50
|
+
*
|
|
51
|
+
* @property {TypeParsablePoint} position
|
|
52
|
+
* @property {TypeParsablePoint} translation
|
|
53
|
+
* @property {TypeParsablePoint | number} scale
|
|
54
|
+
* @property {number} rotation
|
|
55
|
+
* @property {TypeParsableTransform} transform
|
|
56
|
+
* @property {Array<number>} color
|
|
57
|
+
* @property {boolean} isShown
|
|
58
|
+
* @interface
|
|
59
|
+
* @group Misc Shapes
|
|
60
|
+
*/
|
|
61
|
+
export type OBJ_Scenario = {
|
|
62
|
+
position?: TypeParsablePoint;
|
|
63
|
+
translation?: TypeParsablePoint;
|
|
64
|
+
rotation?: number;
|
|
65
|
+
scale?: TypeParsablePoint | number;
|
|
66
|
+
transform?: TypeParsableTransform;
|
|
67
|
+
color?: TypeColor;
|
|
68
|
+
isShown?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Path to a {@link FigureElement} within a {@link FigureElementCollection}.
|
|
72
|
+
*
|
|
73
|
+
* `string | {[name: string]: TypeElementPath } | `{@link FigureElement}` | Array<TypeElementPath>}`
|
|
74
|
+
*
|
|
75
|
+
* Consider a collection with the below heirachy. The collection has two
|
|
76
|
+
* children `diagram` and `description` of which `diagram` is another
|
|
77
|
+
* collection:
|
|
78
|
+
* - diagram
|
|
79
|
+
* - lineA
|
|
80
|
+
* - lineB
|
|
81
|
+
* - lines
|
|
82
|
+
* - lineC
|
|
83
|
+
* - lineD
|
|
84
|
+
* - description
|
|
85
|
+
*
|
|
86
|
+
* The ways to define lineC, lineD and description are:
|
|
87
|
+
*
|
|
88
|
+
* - `['description', 'diagram.lines.lineC', 'diagram.lines.lineD']`
|
|
89
|
+
* - `['description', { diagram: ['lines.lineC', 'lines.lineD'] }]`
|
|
90
|
+
* - `['description', { 'diagram.lines': ['lineC', 'lineD'] }]`
|
|
91
|
+
* @group Misc Figure Element
|
|
92
|
+
*/
|
|
93
|
+
export type TypeElementPath = string | {
|
|
94
|
+
[name: string]: TypeElementPath;
|
|
95
|
+
} | FigureElement | Array<TypeElementPath>;
|
|
96
|
+
/**
|
|
97
|
+
* Pulse options object
|
|
98
|
+
*
|
|
99
|
+
* 
|
|
100
|
+
*
|
|
101
|
+
* Pulsing can be useful to highlight a figure element to a user, without
|
|
102
|
+
* changing its underlying properties.
|
|
103
|
+
*
|
|
104
|
+
* When an element is pulsed, it will be scaled, translated or rotated from
|
|
105
|
+
* a start value (1 for scale, 0 for rotation and translation),
|
|
106
|
+
* to a maximum value (`scale`, `translate` or `rotate`),
|
|
107
|
+
* to a `min` value, and then back to the `start` value. An element can
|
|
108
|
+
* be pulsed through this cycle `frequency` times per second, over some
|
|
109
|
+
* `duration`.
|
|
110
|
+
*
|
|
111
|
+
* The pulse does not change the {@link FigureElement}.transform property, and
|
|
112
|
+
* only changes the draw transform.
|
|
113
|
+
*
|
|
114
|
+
* By default, a scale or rotation pulse will scale or rotate around the the
|
|
115
|
+
* center of the rectangle encompassing the border of the element. `centerOn`
|
|
116
|
+
* can be used to define a different {@link FigureElement} or point to center
|
|
117
|
+
* on. If centering on a {@link FigureElement}, `xAlign` and `yAlign` can be
|
|
118
|
+
* used to center on a point aligned within it. For instance, `xAlign: 'left'`
|
|
119
|
+
* will center on a point on the left edte of the {@link FigureElement}.
|
|
120
|
+
*
|
|
121
|
+
* The pulse can also draw multiple copies of the element with pulse transforms
|
|
122
|
+
* distributed between the `min` and maximum pulse values. This is particularly
|
|
123
|
+
* useful for shapes with outlines that have a regular spacing from a center
|
|
124
|
+
* point (such as regular polygons) as it will look like the thickness of the
|
|
125
|
+
* outlines are becomming thicker.
|
|
126
|
+
*
|
|
127
|
+
* @property {number} [duration] pulse duration in seconds (`1`)
|
|
128
|
+
* @property {number} [frequency] pulse frequency in Hz - a frequency of zero
|
|
129
|
+
* will set the frequency so just one cycle will be performed in the duration
|
|
130
|
+
* (`0`)
|
|
131
|
+
* @property {number} [scale] maximum scale value to pulse to (`1.5`)
|
|
132
|
+
* @property {number} [rotation] maximum rotation value to pulse to
|
|
133
|
+
* @property {number} [translation] maximum translation displacment value to
|
|
134
|
+
* pulse to (`1.5`)
|
|
135
|
+
* @property {number} [angle] translation angle (`0`)
|
|
136
|
+
* @property {number} [min] minimum value to pulse to
|
|
137
|
+
* @property {null | FigureElement | TypeParsablePoint | string | 'this'} [centerOn] center
|
|
138
|
+
* of scale or rotation pulse. `null` is point [0, 0], `string` or
|
|
139
|
+
* `FigureElement` are elements to centerOn, and `'this'` is the calling
|
|
140
|
+
* element (`'this'`)
|
|
141
|
+
* will be the default `centerOn`.
|
|
142
|
+
* @property {'left' | 'center' | 'right' | 'location' | number} [xAlign]
|
|
143
|
+
* if `centerOn` is a {@link FigureElement} then this property can be used to
|
|
144
|
+
* horizontally align the pulse center with the element. `'location'` is the
|
|
145
|
+
* (0, 0) draw space coordinate of the element. `number` defines the percent
|
|
146
|
+
* width from the left of the element (`'center'`)
|
|
147
|
+
* @property {'bottom' | 'middle' | 'top' | 'location' | number} [yAlign]
|
|
148
|
+
* if `centerOn` is a {@link FigureElement} then this property can be used to
|
|
149
|
+
* vertically align the pulse center with the element. `'location'` is the
|
|
150
|
+
* (0, 0) draw space coordinate of the element. `number` defines the percent
|
|
151
|
+
* width from the left of the element (`'center'`)
|
|
152
|
+
* @property {'figure' | 'gl' | 'local' | 'draw' | 'pixel'} [space]
|
|
153
|
+
* if `centerOn` is a point, use this to define the space the point is in
|
|
154
|
+
* (`'figure'`)
|
|
155
|
+
* @property {number} [num] the number of draw copies of the pulse to make (`1`)
|
|
156
|
+
* @property {null | string | function(): void} [done] callback when pulse is
|
|
157
|
+
* finished. If `string` then the element's {@link FunctionMap} `fnMap` will be
|
|
158
|
+
* used (`null`)
|
|
159
|
+
* @property {TypeWhen} [when] when to start the pulse (`'syncNow'`)
|
|
160
|
+
* @property {'sinusoid' | 'triangle'} [progression] function that defines
|
|
161
|
+
* how the scale should progress over time (`sinusoid`)
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* // For all examples below, use this to add an element to the figure
|
|
165
|
+
* const p = figure.add({
|
|
166
|
+
* make: 'polygon',
|
|
167
|
+
* radius: 0.3,
|
|
168
|
+
* line: { width: 0.05, },
|
|
169
|
+
* });
|
|
170
|
+
*
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* // Scale pulse
|
|
174
|
+
* p.pulse({
|
|
175
|
+
* duration: 1,
|
|
176
|
+
* scale: 1.3
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* // Rotation pulse
|
|
181
|
+
* p.pulse({
|
|
182
|
+
* duration: 1,
|
|
183
|
+
* rotation: 0.15,
|
|
184
|
+
* frequency: 4,
|
|
185
|
+
* });
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* // Translation pulse
|
|
189
|
+
* p.pulse({
|
|
190
|
+
* duration: 1,
|
|
191
|
+
* translation: 0.02,
|
|
192
|
+
* min: -0.02,
|
|
193
|
+
* frequency: 4,
|
|
194
|
+
* });
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* // Thick pulse
|
|
198
|
+
* p.pulse({
|
|
199
|
+
* duration: 1,
|
|
200
|
+
* scale: 1.1,
|
|
201
|
+
* min: 0.9,
|
|
202
|
+
* num: 7,
|
|
203
|
+
* });
|
|
204
|
+
* @interface
|
|
205
|
+
* @group Misc Animation
|
|
206
|
+
*/
|
|
207
|
+
export type OBJ_Pulse = {
|
|
208
|
+
duration?: number;
|
|
209
|
+
frequency?: number;
|
|
210
|
+
scale?: number;
|
|
211
|
+
rotation?: number;
|
|
212
|
+
translation?: number;
|
|
213
|
+
angle?: number;
|
|
214
|
+
min?: number;
|
|
215
|
+
centerOn?: null | FigureElement | TypeParsablePoint | string | 'this';
|
|
216
|
+
x?: 'left' | 'center' | 'right' | 'origin' | number;
|
|
217
|
+
y?: 'bottom' | 'middle' | 'top' | 'origin' | number;
|
|
218
|
+
space?: 'figure' | 'gl' | 'local' | 'draw';
|
|
219
|
+
num?: number;
|
|
220
|
+
when?: TypeWhen;
|
|
221
|
+
done?: string | ((...args: any[]) => void) | null;
|
|
222
|
+
progression?: string | ((n: number) => number);
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Figure element move freely parameters
|
|
226
|
+
*
|
|
227
|
+
* If a figure element is released from moving with some velocity
|
|
228
|
+
* then these parameters will define how it continues to move freely
|
|
229
|
+
*
|
|
230
|
+
* @property {TypeTransformValue} zeroVelocityThreshold used to overcome
|
|
231
|
+
* limitations of floating point numbers not reaching 0
|
|
232
|
+
* @property {TypeTransformValue} deceleration amount to decelerate in local
|
|
233
|
+
* space units per second squared
|
|
234
|
+
* @property {TypeTransformValue} bounceLoss 0.5 results in 50% velocity loss
|
|
235
|
+
* if bouncing of boundary
|
|
236
|
+
* @property {?(string | ((boolean) => void))} callback called each frame of
|
|
237
|
+
* free movement
|
|
238
|
+
* @interface
|
|
239
|
+
* @group Interactivity
|
|
240
|
+
*/
|
|
241
|
+
type OBJ_ElementMoveFreely = {
|
|
242
|
+
zeroVelocityThreshold: number;
|
|
243
|
+
deceleration: number;
|
|
244
|
+
bounceLoss: number;
|
|
245
|
+
callback: string | ((b: boolean) => void) | null;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Figure element move parameters
|
|
249
|
+
* @property {type: 'rotation' | 'translation' | 'position' | 'scale' | 'scaleX' | 'scaleY' | 'scaleZ'} type
|
|
250
|
+
* @property {TypeParsableBounds} bounds rectangle to
|
|
251
|
+
* limit movement within
|
|
252
|
+
* @property {Plane} plane movement plane
|
|
253
|
+
* @property {TypeTransformValue} maxVelocity maximum velocity allowed (5)
|
|
254
|
+
* @property {OBJ_ElementMoveFreely} freely free movement parameters - use
|
|
255
|
+
* false for disabling free movement after touch up
|
|
256
|
+
* @property {FigureElement | null | string} element
|
|
257
|
+
* @interface
|
|
258
|
+
* @group Interactivity
|
|
259
|
+
*/
|
|
260
|
+
export type OBJ_ElementMove = {
|
|
261
|
+
type?: 'rotation' | 'translation' | 'position' | 'scale' | 'scaleX' | 'scaleY' | 'scaleZ';
|
|
262
|
+
bounds?: TypeParsableBounds;
|
|
263
|
+
plane?: Plane;
|
|
264
|
+
maxVelocity?: number | TypeParsablePoint;
|
|
265
|
+
freely?: OBJ_ElementMoveFreely | false;
|
|
266
|
+
element?: FigureElement | null | string;
|
|
267
|
+
};
|
|
268
|
+
type OBJ_ElementMoveFixed = {
|
|
269
|
+
type: 'rotation' | 'translation' | 'position' | 'scale' | 'scaleX' | 'scaleY' | 'scaleZ';
|
|
270
|
+
bounds: TypeParsableBounds;
|
|
271
|
+
plane: Plane;
|
|
272
|
+
maxVelocity: number | TypeParsablePoint;
|
|
273
|
+
freely: OBJ_ElementMoveFreely | false;
|
|
274
|
+
element: FigureElement | null | string;
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* All scenarios set to element.
|
|
278
|
+
*
|
|
279
|
+
* Scenarios are preset transforms, color and visibility settings that can be
|
|
280
|
+
* easily animated to.
|
|
281
|
+
*
|
|
282
|
+
* This is an object where the keys are scenario names and values are
|
|
283
|
+
* {@link OBJ_Scenario} objects defining the scenario.
|
|
284
|
+
*
|
|
285
|
+
* @property {OBJ_Scenario} _scenarioName where scenarioName can be any
|
|
286
|
+
* string that names the scenario
|
|
287
|
+
* @interface
|
|
288
|
+
* @group Misc Figure Element
|
|
289
|
+
*/
|
|
290
|
+
export type OBJ_Scenarios = {
|
|
291
|
+
[_scenarioName: string]: OBJ_Scenario;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Element movement state
|
|
295
|
+
* @group Misc Figure Element
|
|
296
|
+
*/
|
|
297
|
+
type ElementMovementState = {
|
|
298
|
+
previousTime: number | null;
|
|
299
|
+
velocity: Point | number;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Element pulse state
|
|
303
|
+
* @group Misc Figure Element
|
|
304
|
+
*/
|
|
305
|
+
type ElementPulseState = {
|
|
306
|
+
startTime: number | null;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Element state
|
|
310
|
+
* @group Misc Figure Element
|
|
311
|
+
*/
|
|
312
|
+
type ElementState = {
|
|
313
|
+
isBeingMoved: boolean;
|
|
314
|
+
isMovingFreely: boolean;
|
|
315
|
+
isChanging: boolean;
|
|
316
|
+
movement: ElementMovementState;
|
|
317
|
+
isPulsing: boolean;
|
|
318
|
+
pulse: ElementPulseState;
|
|
319
|
+
preparingToStop: boolean;
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* setTransform event.
|
|
323
|
+
*
|
|
324
|
+
* Fired whenever the transform is changed.
|
|
325
|
+
*
|
|
326
|
+
* @event FigureElement#setTransform
|
|
327
|
+
* @type {[Transform]}
|
|
328
|
+
*/
|
|
329
|
+
/**
|
|
330
|
+
* Figure Element base class
|
|
331
|
+
*
|
|
332
|
+
* The set of properties and methods shared by all figure elements
|
|
333
|
+
*
|
|
334
|
+
* A figure element has several color related properties. Color is
|
|
335
|
+
* defined as an RGBA array with values between 0 and 1. The alpha
|
|
336
|
+
* channel defines the transparency or opacity of the color where
|
|
337
|
+
* 1 is fully opaque and 0 is fully transparent.
|
|
338
|
+
*
|
|
339
|
+
* The `color` property stores the element's current color, while the
|
|
340
|
+
* `defaultColor` property stores the element's color when not dimmed or
|
|
341
|
+
* dissolving. Color should only be set using the `setColor` method.
|
|
342
|
+
*
|
|
343
|
+
* An element can be "dimmed" or "undimmed". For instance,
|
|
344
|
+
* a red element might turn grey when dimmed. The property
|
|
345
|
+
* `dimColor` stores the desired color to dim to and should be set with
|
|
346
|
+
* `setDimColor()`
|
|
347
|
+
*
|
|
348
|
+
* An element can be dissolved in or out with animation. Dissolving
|
|
349
|
+
* an element out transitions its opacity from its current value to 0.
|
|
350
|
+
* The `opacity` property is used when dissolving. The opacity is multiplied by
|
|
351
|
+
* the alpha channel of `color` to net a final opacity. Opacity should not be
|
|
352
|
+
* set directly as it will be overwritten by dissolve animations.
|
|
353
|
+
*
|
|
354
|
+
* Notifications - The notification manager property `notifications` will
|
|
355
|
+
* publish the following events:
|
|
356
|
+
* - `beforeSetTransform`: published just before the `transform` property is
|
|
357
|
+
* changed
|
|
358
|
+
* - `setTransform`: published whenever the `transform` property is changed
|
|
359
|
+
* - `startBeingMoved`: published when the element starts being moved by touch
|
|
360
|
+
* - `stopBeingMoved`: published when the element stops being moved by touch
|
|
361
|
+
* - `startMovingFreely`
|
|
362
|
+
* - `stopMovingFreely`
|
|
363
|
+
* - `show`: published when element is shown
|
|
364
|
+
* - `hide`: published when element is hidden
|
|
365
|
+
* - `visibility`: published when element element is shown or hidden
|
|
366
|
+
* - `onClick`: published when element is clicked on
|
|
367
|
+
* - `color`: published whenever color is set
|
|
368
|
+
* - `beforeDraw`
|
|
369
|
+
* - `afterDraw`
|
|
370
|
+
* - `setState`: state of element has been set
|
|
371
|
+
*
|
|
372
|
+
* @class
|
|
373
|
+
* @property {string} name reference name of element
|
|
374
|
+
* @property {boolean} isShown if `false` then element will not be processed on
|
|
375
|
+
* next draw
|
|
376
|
+
* @property {Transform} transform transform to apply element
|
|
377
|
+
* @property {Transform} lastDrawTransform transform last used for drawing -
|
|
378
|
+
* includes cascade or all parent transforms
|
|
379
|
+
* @property {FigureElement | null} parent parent figure element - `null` if
|
|
380
|
+
* at top level of figure
|
|
381
|
+
* @property {boolean} isTouchable must be `true` to move or execute `onClick`
|
|
382
|
+
* @property {boolean} isMovable must be `true` to move
|
|
383
|
+
* @property {string | () => void} onClick callback if touched or clicked
|
|
384
|
+
* @property {[number, number, number, number]} color element's current
|
|
385
|
+
* color defined as red, green, blue, alpha with range 0 to 1
|
|
386
|
+
* @property {[number, number, number, number]} dimColor color to use when
|
|
387
|
+
* dimming element
|
|
388
|
+
* @property {[number, number, number, number]} defaultColor color to go to
|
|
389
|
+
* when undimming element
|
|
390
|
+
* @property {number} opacity number between 0 and 1 that is multiplied with
|
|
391
|
+
* `color` alpha channel to get final opacity
|
|
392
|
+
* @property {OBJ_ElementMove} move movement parameters
|
|
393
|
+
* @property {OBJ_Scenarios} scenarios scenario presets
|
|
394
|
+
* @property {ElementState} state current state of element
|
|
395
|
+
* @property {AnimationManager} animations element animation manager
|
|
396
|
+
* @property {NotificationManager} notifications notification manager for
|
|
397
|
+
* element
|
|
398
|
+
* @property {FunctionMap} fnMap function map for use with {@link Recorder}
|
|
399
|
+
* @property {Object} customState put any custom state information that needs
|
|
400
|
+
* to be captured with recorder here - only stringify-able values can go in this
|
|
401
|
+
* object like strings, numbers, booleans and nested arrays or objects
|
|
402
|
+
* containing these. Functions should not be put in here - use string
|
|
403
|
+
* identifiers to `fnMap` if functions are needed.
|
|
404
|
+
* @group Figure Elements
|
|
405
|
+
*/
|
|
406
|
+
declare class FigureElement {
|
|
407
|
+
transform: Transform;
|
|
408
|
+
pulseTransforms: Array<Transform>;
|
|
409
|
+
frozenPulseTransforms: Array<Transform>;
|
|
410
|
+
copyTransforms: Array<Transform>;
|
|
411
|
+
drawTransforms: Array<Transform>;
|
|
412
|
+
lastDrawPulseTransform: Transform;
|
|
413
|
+
parentTransform: Array<Transform>;
|
|
414
|
+
lastDrawOpacity: number;
|
|
415
|
+
parent: FigureElement | null;
|
|
416
|
+
isShown: boolean;
|
|
417
|
+
name: string;
|
|
418
|
+
isMovable: boolean;
|
|
419
|
+
isTouchable: boolean;
|
|
420
|
+
touchScale: Point;
|
|
421
|
+
isInteractive: boolean | null | undefined;
|
|
422
|
+
drawPriority: number;
|
|
423
|
+
cancelSetTransform: boolean;
|
|
424
|
+
onClick: string | ((arg?: any) => void) | null;
|
|
425
|
+
setTransformCallback: string | ((t: Transform) => void) | null;
|
|
426
|
+
internalSetTransformCallback: string | ((t: Transform) => void) | null;
|
|
427
|
+
beforeDrawCallback: string | ((n: number) => void) | null;
|
|
428
|
+
afterDrawCallback: string | ((n: number) => void) | null;
|
|
429
|
+
color: TypeColor;
|
|
430
|
+
defaultColor: Array<number>;
|
|
431
|
+
dimColor: Array<number>;
|
|
432
|
+
opacity: number;
|
|
433
|
+
interactiveLocation: Point;
|
|
434
|
+
figure: OBJ_FigureForElement;
|
|
435
|
+
scene: null | Scene;
|
|
436
|
+
move: OBJ_ElementMoveFixed;
|
|
437
|
+
onAdd: null | string | (() => void);
|
|
438
|
+
scenarios: OBJ_Scenarios;
|
|
439
|
+
type: 'collection' | 'primitive';
|
|
440
|
+
pulseSettings: {
|
|
441
|
+
time: number;
|
|
442
|
+
frequency: number;
|
|
443
|
+
A: number | Array<number>;
|
|
444
|
+
B: number | Array<number>;
|
|
445
|
+
C: number | Array<number>;
|
|
446
|
+
progression: string | ((a: number, b: number, c: number, d: number, e: number) => number);
|
|
447
|
+
num: number;
|
|
448
|
+
delta: TypeParsablePoint;
|
|
449
|
+
transformMethod: string | ((a: number, b?: Point) => Transform);
|
|
450
|
+
callback: string | ((arg: any) => void) | null;
|
|
451
|
+
allowFreezeOnStop: boolean;
|
|
452
|
+
type: 'scale' | 'rotation' | number;
|
|
453
|
+
};
|
|
454
|
+
pulseDefault: string | ((done?: (() => void) | null) => void) | {
|
|
455
|
+
scale: null | number | Point;
|
|
456
|
+
rotation: null | number;
|
|
457
|
+
translation: null | number | Point;
|
|
458
|
+
angle: number;
|
|
459
|
+
duration: number;
|
|
460
|
+
frequency: number;
|
|
461
|
+
num: number;
|
|
462
|
+
xAlign: 'center' | 'left' | 'right' | number;
|
|
463
|
+
yAlign: 'middle' | 'bottom' | 'top' | number;
|
|
464
|
+
centerOn: null | FigureElement | string;
|
|
465
|
+
space: TypeCoordinateSpace;
|
|
466
|
+
done: null | (() => void);
|
|
467
|
+
progression: string | ((n: number) => number);
|
|
468
|
+
when: TypeWhen;
|
|
469
|
+
};
|
|
470
|
+
figureTransforms: OBJ_SpaceTransforms;
|
|
471
|
+
state: ElementState;
|
|
472
|
+
animations: animations.AnimationManager;
|
|
473
|
+
animationFinishedCallback: string | (() => void) | null;
|
|
474
|
+
uid: string;
|
|
475
|
+
anim: Record<string, any>;
|
|
476
|
+
tieToHTML: {
|
|
477
|
+
element: string | null;
|
|
478
|
+
scale: string;
|
|
479
|
+
window: Rect;
|
|
480
|
+
updateOnResize: boolean;
|
|
481
|
+
};
|
|
482
|
+
isRenderedAsImage: boolean;
|
|
483
|
+
renderedOnNextDraw: boolean;
|
|
484
|
+
unrenderNextDraw: boolean;
|
|
485
|
+
custom: Record<string, any>;
|
|
486
|
+
_custom: Record<string, any>;
|
|
487
|
+
stateProperties: Array<string>;
|
|
488
|
+
customState: Record<string, any>;
|
|
489
|
+
fnMap: FunctionMap;
|
|
490
|
+
notifications: NotificationManager;
|
|
491
|
+
lastDrawTime: number;
|
|
492
|
+
dependantTransform: boolean;
|
|
493
|
+
recorder: Recorder;
|
|
494
|
+
timeKeeper: TimeKeeper;
|
|
495
|
+
simple: boolean;
|
|
496
|
+
uniqueColor: null | TypeColor;
|
|
497
|
+
touch: {
|
|
498
|
+
color: null | TypeColor;
|
|
499
|
+
enabled: boolean;
|
|
500
|
+
scale: TypeParsablePoint;
|
|
501
|
+
};
|
|
502
|
+
drawNumber: number;
|
|
503
|
+
moveSetTransform: boolean;
|
|
504
|
+
allowSetColor: string;
|
|
505
|
+
/**
|
|
506
|
+
* @hideconstructor
|
|
507
|
+
*/
|
|
508
|
+
constructor(transform?: Transform, parent?: FigureElement | null, name?: string, timeKeeper?: TimeKeeper);
|
|
509
|
+
animationFinished(typeOfAnimation?: 'pulse' | 'movingFreely' | 'animation'): void;
|
|
510
|
+
animateNextFrame(): void;
|
|
511
|
+
/**
|
|
512
|
+
* Associate this element with a new scene.
|
|
513
|
+
* @param {Scene | OBJ_Scene} scene
|
|
514
|
+
*/
|
|
515
|
+
setScene(scene: Scene | OBJ_Scene): void;
|
|
516
|
+
setProperties(properties: Record<string, any>, except?: Array<string> | string): void;
|
|
517
|
+
_getStateProperties(options: {
|
|
518
|
+
ignoreShown?: boolean;
|
|
519
|
+
}): string[];
|
|
520
|
+
_getStatePropertiesMin(): string[];
|
|
521
|
+
_state(options?: {
|
|
522
|
+
precision?: number;
|
|
523
|
+
ignoreShown?: boolean;
|
|
524
|
+
min?: boolean;
|
|
525
|
+
returnF1Type?: boolean;
|
|
526
|
+
}): Record<string, any>;
|
|
527
|
+
stateSet(): void;
|
|
528
|
+
setFigure(figure: OBJ_FigureForElement, notify?: boolean): void;
|
|
529
|
+
setTimeDelta(delta: number): void;
|
|
530
|
+
getIsShown(): boolean;
|
|
531
|
+
getRootElement(): FigureElement | null;
|
|
532
|
+
getScene(): Scene | null;
|
|
533
|
+
getDrawToFigureTransformDef(): Array<any>;
|
|
534
|
+
getLocalToFigureTransformDef(): any[];
|
|
535
|
+
getLocalToFigureTransform(): Transform;
|
|
536
|
+
getFigureTransform(): Transform;
|
|
537
|
+
updateHTMLElementTie(figureCanvas: HTMLElement): void;
|
|
538
|
+
setFirstTransform(parentTransform: Transform): void;
|
|
539
|
+
clearFrozenPulseTransforms(): void;
|
|
540
|
+
freezePulseTransforms(forceOverwrite?: boolean): void;
|
|
541
|
+
getFonts(): Array<any>;
|
|
542
|
+
fontUpdated(): void;
|
|
543
|
+
init(_webgl: any): void;
|
|
544
|
+
_dup(_arg?: any): any;
|
|
545
|
+
setupDraw(_now?: number, _canvasIndex?: number): void;
|
|
546
|
+
draw(_now: number, _scene: Scene, ..._args: any[]): void;
|
|
547
|
+
animateToState(state: Record<string, any>, options: Record<string, any>, independentOnly?: boolean, startTime?: number | 'now' | 'prevFrame' | 'nextFrame' | null): number;
|
|
548
|
+
dissolveInToState(state: Record<string, any>, duration?: number, startTime?: number | 'now' | 'prevFrame' | 'nextFrame' | null): number;
|
|
549
|
+
contextLost(): void;
|
|
550
|
+
isStateSame(state: Record<string, any>, mergePulseTransforms?: boolean, exceptions?: Array<string>): boolean;
|
|
551
|
+
arePulseTransformsSame(state: Record<string, any>, delta?: number): boolean;
|
|
552
|
+
getDrawTransforms(initialTransforms: Array<Transform>): Transform[];
|
|
553
|
+
getDrawTransformsMatrix(initialTransforms: Array<Type3DMatrix>): m3.Type3DMatrix[];
|
|
554
|
+
exec(execFunctionAndArgs: string | Array<any>): void;
|
|
555
|
+
getElement(_elementPath?: any): this;
|
|
556
|
+
getElements(_children?: any): Array<FigureElement>;
|
|
557
|
+
highlight(): void;
|
|
558
|
+
/**
|
|
559
|
+
* Conveniently set the first `translation` of the element's `transform`.
|
|
560
|
+
* @param {TypeParsablePoint | number} pointOrX x coordinate or full point
|
|
561
|
+
* definition
|
|
562
|
+
* @param {number} y y coordinate if `pointOrX` is just the x coordinate (`0`)
|
|
563
|
+
*/
|
|
564
|
+
setPosition(pointOrX: TypeParsablePoint | number, y?: number, z?: number): void;
|
|
565
|
+
/**
|
|
566
|
+
* Conveniently set the first `rotation` of the element's `transform`.
|
|
567
|
+
* @param {number} rotation
|
|
568
|
+
*/
|
|
569
|
+
setRotation(r: number, axis?: TypeParsablePoint | null): void;
|
|
570
|
+
/**
|
|
571
|
+
* Conveniently set the first `scale` of the element's `transform`.
|
|
572
|
+
* @param {TypeParsablePoint | number} scaleOrX horizontal scale - either
|
|
573
|
+
* define as full x-y point, or as a number. If scaleOrX is a `number` and
|
|
574
|
+
* `y` is null, then both `x` and `y` will be equally scaled
|
|
575
|
+
* @param {number | null} y y coordinate if `scaleOrX` is a `number` (`null`)
|
|
576
|
+
*/
|
|
577
|
+
setScale(scaleOrX: TypeParsablePoint | number, y?: number | null, z?: number): void;
|
|
578
|
+
/**
|
|
579
|
+
* Set transform of element. Setting through this method will ensure
|
|
580
|
+
* `setTransfrom` subscription will publish, and transform will be
|
|
581
|
+
* appropriately clipped.
|
|
582
|
+
* @param {Transform} transform
|
|
583
|
+
*/
|
|
584
|
+
setTransform(transform: Transform, publish?: boolean): void;
|
|
585
|
+
transformSet(publish?: boolean, fromMovement?: boolean): void;
|
|
586
|
+
nextMovingFreelyFrame(now: number): void;
|
|
587
|
+
clear(_canvasIndex?: number): void;
|
|
588
|
+
cleanup(): void;
|
|
589
|
+
willStartAnimating(): boolean;
|
|
590
|
+
/**
|
|
591
|
+
Set element color.
|
|
592
|
+
@param {[number, number, number, number]} color RGBA color from 0 to 1
|
|
593
|
+
@param {boolean} [setDefault] also set the default color to this color
|
|
594
|
+
*/
|
|
595
|
+
setColor(color: TypeColor, setDefault?: boolean): void;
|
|
596
|
+
/**
|
|
597
|
+
* Set element color to `dimColor`
|
|
598
|
+
*/
|
|
599
|
+
dim(): void;
|
|
600
|
+
/**
|
|
601
|
+
* Set `dimColor` property
|
|
602
|
+
*/
|
|
603
|
+
setDimColor(color: TypeColor): void;
|
|
604
|
+
/**
|
|
605
|
+
* Set element color to `defaultColor`
|
|
606
|
+
*/
|
|
607
|
+
undim(): void;
|
|
608
|
+
setOpacity(opacity: number): void;
|
|
609
|
+
getScenarioTarget(scenarioIn: string | OBJ_Scenario | null | undefined): {
|
|
610
|
+
transform?: Transform;
|
|
611
|
+
color?: TypeColor;
|
|
612
|
+
isShown?: boolean;
|
|
613
|
+
};
|
|
614
|
+
/**
|
|
615
|
+
* Set transform, color and/or visibility to a predefined scenario.
|
|
616
|
+
*
|
|
617
|
+
* @param {string | Array<string>} [scenarioName] name of the scenario to
|
|
618
|
+
* set. Use an array of names to set multiple scenarios in the array's order.
|
|
619
|
+
* @param {boolean} [onlyIfVisible] `true` to only set scenario if element is
|
|
620
|
+
* visible
|
|
621
|
+
*/
|
|
622
|
+
setScenario(scenario: string | OBJ_Scenario): void;
|
|
623
|
+
setScenarios(scenarioName: string | Array<string>, _onlyIfVisible?: boolean): void;
|
|
624
|
+
/**
|
|
625
|
+
* Save the current transform, color and/or visibility to a scenario.
|
|
626
|
+
*/
|
|
627
|
+
saveScenario(scenarioName: string, keys?: Array<string>): void;
|
|
628
|
+
getCurrentScenario(keys?: Array<string>): Record<string, any>;
|
|
629
|
+
saveScenarios(scenarioName: string, keys: Array<string>): void;
|
|
630
|
+
getAllElementsWithScenario(scenarioName: string): Array<FigureElement>;
|
|
631
|
+
getMovingFreelyEnd(): Record<string, any>;
|
|
632
|
+
getRemainingMovingFreelyTime(): any;
|
|
633
|
+
decelerate(deltaTime?: number | null): Record<string, any>;
|
|
634
|
+
/**
|
|
635
|
+
* Return figure path of element
|
|
636
|
+
* @return {string} path of element relative to figure
|
|
637
|
+
*/
|
|
638
|
+
getPath(): string;
|
|
639
|
+
getMovement(transform: Transform): number | Point | null | undefined;
|
|
640
|
+
updateTransformWithMovement(valueIn: number | Point, transform: Transform): Transform;
|
|
641
|
+
setZeroVelocity(): void;
|
|
642
|
+
startBeingMoved(): void;
|
|
643
|
+
moved(value: Point | number): void;
|
|
644
|
+
stopBeingMoved(): void;
|
|
645
|
+
calcVelocity(prevValue: number | Point, nextValue: number | Point): void;
|
|
646
|
+
startMovingFreely(callback?: string | ((b: boolean) => void) | null): void;
|
|
647
|
+
stopMovingFreely(how?: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete'): void;
|
|
648
|
+
getRemainingPulseTime(now?: number): number;
|
|
649
|
+
getPulseTransforms(now: number): Array<Transform>;
|
|
650
|
+
/**
|
|
651
|
+
* Pulse element.
|
|
652
|
+
*
|
|
653
|
+
* An element can be pulsed in scale, a rotation or a translation.
|
|
654
|
+
*
|
|
655
|
+
* The scale pulse can either be a single pulse, or a number of copies with a
|
|
656
|
+
* range of scales - which has the effect of making regular polygons thick.
|
|
657
|
+
*
|
|
658
|
+
* Either pass in a callback, or an options object defining the pulse and
|
|
659
|
+
* callback.
|
|
660
|
+
*
|
|
661
|
+
* @param {null | OBJ_Pulse | () => void} optionsOrDone
|
|
662
|
+
*/
|
|
663
|
+
pulse(optionsOrDone?: null | OBJ_Pulse | (() => void)): void;
|
|
664
|
+
startPulsing(when?: TypeWhen): void;
|
|
665
|
+
stopPulsing(how?: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete'): void;
|
|
666
|
+
stop(how?: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete', _elementOnly?: boolean): void;
|
|
667
|
+
stopAnimating(how?: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete', name?: string | null, _includeChildren?: boolean): void;
|
|
668
|
+
getRemainingAnimationTime(animationNames?: Array<string> | string): number;
|
|
669
|
+
getNextAnimationFinishTime(): any;
|
|
670
|
+
resize(figureHTMLElement?: HTMLElement | null): void;
|
|
671
|
+
/**
|
|
672
|
+
* Transform a point between 'draw', 'local', 'figure', 'gl' and 'pixel'
|
|
673
|
+
* spaces.
|
|
674
|
+
*
|
|
675
|
+
* `plane` is only needed when converting from pixel space (a 2D space) to
|
|
676
|
+
* 'figure', 'local' or 'draw' spaces (a 3D space). A ray from the pixel is
|
|
677
|
+
* drawn into the screen
|
|
678
|
+
* and the intersection with the defined `plane` is returned.
|
|
679
|
+
*
|
|
680
|
+
* 'pixel' to 'gl' is also a 2D to 3D transformation, but in this case the
|
|
681
|
+
* XY plane at z = 0 is used in gl space.
|
|
682
|
+
*
|
|
683
|
+
* @param {TypeParsablePoint} point
|
|
684
|
+
* @param {'figure' | 'gl' | 'pixel'} fromSpace space to convert point from
|
|
685
|
+
* @param {'figure' | 'gl' | 'pixel'} toSpace space to convert point to
|
|
686
|
+
* @param {TypeParsablePlane} plane figure space intersection plane for
|
|
687
|
+
* 'pixel' to 'figure' conversion
|
|
688
|
+
*/
|
|
689
|
+
transformPoint(point: TypeParsablePoint, fromSpace: 'draw' | 'local' | 'figure' | 'gl' | 'pixel', toSpace: 'draw' | 'local' | 'figure' | 'gl' | 'pixel', toSpacePlane?: TypeParsablePlane): Point;
|
|
690
|
+
getCanvas(): any;
|
|
691
|
+
/**
|
|
692
|
+
* Return a matrix that can transform from one coordinate space to another.
|
|
693
|
+
*/
|
|
694
|
+
spaceTransformMatrix(from: TypeCoordinateSpace, to: TypeCoordinateSpace, precision?: number): Type3DMatrix;
|
|
695
|
+
pixelToPlane(pixel: TypeParsablePoint, toSpace: 'figure' | 'local' | 'draw', plane: TypeParsablePlane): Point | null;
|
|
696
|
+
glToPlane(glPoint: TypeParsablePoint, toSpace?: 'figure' | 'local' | 'draw', plane?: TypeParsablePlane): Point | null;
|
|
697
|
+
pixelToGLPlane(pixelPoint: TypeParsablePoint, glSpacePlane: TypeParsablePlane): Point | null;
|
|
698
|
+
glToPlaneLegacy(glPoint: TypeParsablePoint, plane?: TypeParsablePlane): Point | null;
|
|
699
|
+
pointFromSpaceToSpace(point: TypeParsablePoint, fromSpace: TypeCoordinateSpace, toSpace: TypeCoordinateSpace): Point;
|
|
700
|
+
getBorderPoints(border?: 'border' | 'touchBorder'): TypeBorder;
|
|
701
|
+
/**
|
|
702
|
+
* Get the border or touchBorder of a FigureElementPrimitive in a defined
|
|
703
|
+
* coordinate space.
|
|
704
|
+
*
|
|
705
|
+
* @param {TypeCoordinateSpace} space (`'local`)
|
|
706
|
+
* @param {'border' | 'touchBorder'} border (`'border'`)
|
|
707
|
+
* @return {Array<Array<Point>>}
|
|
708
|
+
*/
|
|
709
|
+
getBorder(space?: TypeCoordinateSpace, border?: 'border' | 'touchBorder'): Point[][];
|
|
710
|
+
getBoundingRect(space?: TypeCoordinateSpace, border?: 'border' | 'touchBorder'): Rect;
|
|
711
|
+
getRelativeBoundingRect(space?: TypeCoordinateSpace, border?: 'border' | 'touchBorder'): Rect;
|
|
712
|
+
getCenterFigurePosition(): Point;
|
|
713
|
+
/**
|
|
714
|
+
* Return the first scale in the element's transform. Will return
|
|
715
|
+
* `[1, 1]` if element's transform doesn't have a scale.
|
|
716
|
+
*
|
|
717
|
+
* @return {Point} scale
|
|
718
|
+
*/
|
|
719
|
+
getScale(): Point;
|
|
720
|
+
/**
|
|
721
|
+
* Return the first rotation in the element's transform.
|
|
722
|
+
*
|
|
723
|
+
* @param {'0to360' | '-180to180' | ''} normalize how to normalize the
|
|
724
|
+
* returned angle where `''` returns the raw angle
|
|
725
|
+
* @return {Point} scale
|
|
726
|
+
*/
|
|
727
|
+
getRotation(normalize?: '0to360' | '-180to180' | ''): number;
|
|
728
|
+
getPositionInBounds(space?: TypeCoordinateSpace, xAlign?: 'center' | 'left' | 'right' | 'location' | number, yAlign?: 'middle' | 'top' | 'bottom' | 'location' | number, border?: any, ...args: any[]): Point;
|
|
729
|
+
/**
|
|
730
|
+
* Get position of element
|
|
731
|
+
*
|
|
732
|
+
* By default the first translation of the element's transform is returned.
|
|
733
|
+
* This is effectively the element's location in 'local' coordinates.
|
|
734
|
+
*
|
|
735
|
+
* The position of the element relative to its horizontal and vertical bounds
|
|
736
|
+
* can also be returned. Use `xAlign` to find the x coordinate of the left,
|
|
737
|
+
* center, right or percentage width from left of the element. Use `yAlign`
|
|
738
|
+
* to find the bottom, middle, top or percentage height from bottom of the
|
|
739
|
+
* element.
|
|
740
|
+
*
|
|
741
|
+
* @param {'local' | 'figure' | 'gl' | 'draw'} space the space to return
|
|
742
|
+
* the position in
|
|
743
|
+
* @param {'center' | 'left' | 'right' | 'location' | number} xAlign
|
|
744
|
+
* horizontal alignment of position. Use a `number` to define the horizontal
|
|
745
|
+
* position in percentage width from the left.
|
|
746
|
+
* @param {'middle' | 'top' | 'bottom' | 'location' | number} yAlign
|
|
747
|
+
* vertical alignment of position. Use a `number` to define the vertical
|
|
748
|
+
* position in percentage height from the bottom.
|
|
749
|
+
*/
|
|
750
|
+
getPosition(space?: TypeCoordinateSpace, xAlign?: 'center' | 'left' | 'right' | 'location' | number, yAlign?: 'middle' | 'top' | 'bottom' | 'location' | number): Point;
|
|
751
|
+
/**
|
|
752
|
+
* Set the element's position in local space such that it lines up with a
|
|
753
|
+
* figure space target.
|
|
754
|
+
*
|
|
755
|
+
* @param {TypeParsablePoint} figurePosition
|
|
756
|
+
*/
|
|
757
|
+
setFigurePosition(figurePosition: TypeParsablePoint): void;
|
|
758
|
+
setFigurePositionToElement(element: FigureElement): void;
|
|
759
|
+
/**
|
|
760
|
+
* Align element position in local space such that it is in the same position
|
|
761
|
+
* as the target element (even if that element is in a different local space)
|
|
762
|
+
*
|
|
763
|
+
* @param {FigureElement} element
|
|
764
|
+
*/
|
|
765
|
+
setPositionToElement(element: FigureElement): void;
|
|
766
|
+
getShown(): (string | this)[][];
|
|
767
|
+
getUid(uid: string): FigureElement | null;
|
|
768
|
+
/**
|
|
769
|
+
* Show element.
|
|
770
|
+
*/
|
|
771
|
+
show(): void;
|
|
772
|
+
/**
|
|
773
|
+
* `true` set this element as touchable and configures all parent elements
|
|
774
|
+
* to accept touches for their children
|
|
775
|
+
*
|
|
776
|
+
* `false` makes this element not touchable.
|
|
777
|
+
*/
|
|
778
|
+
setTouchable(setOrOptions?: OBJ_Touch | boolean): void;
|
|
779
|
+
setNotTouchable(): void;
|
|
780
|
+
/**
|
|
781
|
+
* Set move options
|
|
782
|
+
*/
|
|
783
|
+
setMove(options: boolean | OBJ_ElementMove): void;
|
|
784
|
+
/**
|
|
785
|
+
* Configure all parents to make this element touchable, and
|
|
786
|
+
* make this element touchable and movable
|
|
787
|
+
* @param {boolean} movable `true` to make movable, `false` to not
|
|
788
|
+
*/
|
|
789
|
+
setMovable(movable?: boolean): void;
|
|
790
|
+
clearRender(): void;
|
|
791
|
+
setRenderedOnNextDraw(): void;
|
|
792
|
+
unrender(): void;
|
|
793
|
+
showAll(): void;
|
|
794
|
+
/**
|
|
795
|
+
* Hide element
|
|
796
|
+
*/
|
|
797
|
+
hide(): void;
|
|
798
|
+
hideAll(): void;
|
|
799
|
+
/**
|
|
800
|
+
* Toggle hide/show of element
|
|
801
|
+
*/
|
|
802
|
+
toggleShow(): void;
|
|
803
|
+
click(glPoint?: Point): void;
|
|
804
|
+
/**
|
|
805
|
+
* Get current transform of element.
|
|
806
|
+
* @return {Transform}
|
|
807
|
+
*/
|
|
808
|
+
getTransform(): Transform;
|
|
809
|
+
/**
|
|
810
|
+
* @return {boolean} `true` if element is moving
|
|
811
|
+
*/
|
|
812
|
+
isMoving(): boolean;
|
|
813
|
+
/**
|
|
814
|
+
* @return {boolean} `true` if element is animating
|
|
815
|
+
*/
|
|
816
|
+
isAnimating(): boolean;
|
|
817
|
+
isAnyElementMoving(): boolean;
|
|
818
|
+
isBeingTouched(glLocation: Point): boolean;
|
|
819
|
+
getTouched(glLocation: Point): Array<FigureElement>;
|
|
820
|
+
getSelectionFromBorders(glLocation: Point): null | FigureElement;
|
|
821
|
+
setUniqueColor(color: null | TypeColor): void;
|
|
822
|
+
getUniqueColorElement(color: TypeColor): FigureElement | null;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Primitive figure element
|
|
826
|
+
*
|
|
827
|
+
* A primitive figure element is one that handles an object (`drawingObject`)
|
|
828
|
+
* that draws to the screen. This object may be a {@link GLObject}, a
|
|
829
|
+
* {@link TextObject} or a {@link HTMLObject}.
|
|
830
|
+
*
|
|
831
|
+
* @class
|
|
832
|
+
* @extends FigureElement
|
|
833
|
+
* @group Figure Elements
|
|
834
|
+
*/
|
|
835
|
+
declare class FigureElementPrimitive extends FigureElement {
|
|
836
|
+
drawingObject: DrawingObject;
|
|
837
|
+
pointsToDraw: number;
|
|
838
|
+
angleToDraw: number;
|
|
839
|
+
lengthToDraw: number;
|
|
840
|
+
cannotTouchHole: boolean;
|
|
841
|
+
pointsDefinition: Record<string, any>;
|
|
842
|
+
setPointsFromDefinition: (() => void) | null;
|
|
843
|
+
border: TypeParsableBuffer | TypeBorder | 'draw' | 'buffer' | 'rect' | number;
|
|
844
|
+
touchBorder: TypeParsableBuffer | TypeBorder | 'border' | number | 'rect' | 'draw' | 'buffer';
|
|
845
|
+
drawBorder: TypeBorder;
|
|
846
|
+
drawBorderBuffer: TypeBorder;
|
|
847
|
+
/**
|
|
848
|
+
* Primitive figure element.
|
|
849
|
+
*
|
|
850
|
+
* This type of element is responsible for drawing something
|
|
851
|
+
* to the screen, or managing a HTML element in the DOM
|
|
852
|
+
*
|
|
853
|
+
* @param {DrawingObject} drawingObject an object that handles drawing
|
|
854
|
+
* to the screen or manages a HTML element
|
|
855
|
+
* @param {Transform} transform initial transform to set
|
|
856
|
+
* @param {[number, number, number, number]} color color to set
|
|
857
|
+
* @param {FigureElement | null} parent parent element
|
|
858
|
+
* @param
|
|
859
|
+
*/
|
|
860
|
+
constructor(drawingObject: DrawingObject, transform?: Transform, color?: TypeColor, parent?: FigureElement | null, name?: string, timeKeeper?: TimeKeeper);
|
|
861
|
+
init(webgl: WebGLInstance): void;
|
|
862
|
+
cleanup(): void;
|
|
863
|
+
_getStateProperties(options: {
|
|
864
|
+
ignoreShown?: boolean;
|
|
865
|
+
}): string[];
|
|
866
|
+
/**
|
|
867
|
+
* Set angle to draw.
|
|
868
|
+
*
|
|
869
|
+
* Some primitive elements can be partially drawn to some angle.
|
|
870
|
+
*
|
|
871
|
+
* An angle of -1 represents the maximum angle allowed by the primitive.
|
|
872
|
+
*
|
|
873
|
+
* @param {number} angle Angle to draw
|
|
874
|
+
*/
|
|
875
|
+
setAngleToDraw(angle?: number): void;
|
|
876
|
+
contextLost(): void;
|
|
877
|
+
click(glPoint?: Point): void;
|
|
878
|
+
_dup(transform?: Transform | null): FigureElementPrimitive;
|
|
879
|
+
clear(canvasIndex?: number): void;
|
|
880
|
+
resize(figureHTMLElement?: HTMLElement | null | undefined): void;
|
|
881
|
+
setColor(color: TypeColor, setDefault?: boolean): void;
|
|
882
|
+
setOpacity(opacity: number): void;
|
|
883
|
+
show(): void;
|
|
884
|
+
hide(): void;
|
|
885
|
+
resizeHtmlObject(): void;
|
|
886
|
+
getBorderPoints(border?: 'border' | 'touchBorder'): TypeBorder;
|
|
887
|
+
setupDraw(now?: number): void;
|
|
888
|
+
draw(now: number, scene: Scene, parentTransform?: Array<Transform>, parentOpacity?: number, targetTexture?: boolean, parentIsTouchable?: boolean, parentTouchScale?: Point | null, parentUniqueColor?: TypeColor | null, drawNumber?: number | null): void;
|
|
889
|
+
setFirstTransform(parentTransform?: Transform): void;
|
|
890
|
+
increaseBorderSize(xMultiplierOrPoint?: number | Point, yMultiplier?: number | null): void;
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* {@link FigureElementCollection} options object.
|
|
894
|
+
* @property {TypeParsableTransform} [transform]
|
|
895
|
+
* @property {TypeParsablePoint} [position] if defined, will overwrite first
|
|
896
|
+
* translation of `transform`
|
|
897
|
+
* @property {TypeColor} [color] default color
|
|
898
|
+
* @property {FigureElement | null} [parent] parent of collection
|
|
899
|
+
* @property {TypeBorder | 'children' | 'rect' | number} [border]
|
|
900
|
+
* @property {TypeBorder | 'border' | number | 'rect'} [touchBorder]
|
|
901
|
+
* @interface
|
|
902
|
+
* @group Misc Shapes
|
|
903
|
+
*/
|
|
904
|
+
export type OBJ_FigureElementCollection = {
|
|
905
|
+
transform?: TypeParsableTransform;
|
|
906
|
+
position?: TypeParsablePoint;
|
|
907
|
+
color?: TypeColor;
|
|
908
|
+
parent?: FigureElement | null;
|
|
909
|
+
border?: TypeBorder | 'children' | 'rect' | number;
|
|
910
|
+
touchBorder?: TypeBorder | 'border' | number | 'rect';
|
|
911
|
+
touch?: boolean | number | TypeParsablePoint;
|
|
912
|
+
move?: boolean | OBJ_ElementMove;
|
|
913
|
+
dimColor?: TypeColor;
|
|
914
|
+
scenarios?: OBJ_Scenarios;
|
|
915
|
+
scene?: Scene;
|
|
916
|
+
};
|
|
917
|
+
/**
|
|
918
|
+
* Collection figure element
|
|
919
|
+
*
|
|
920
|
+
* A collection manages a number of children {@link FigureElements}, be they
|
|
921
|
+
* primitives or collections.
|
|
922
|
+
*
|
|
923
|
+
* A collection's transform will be passed onto all the children elements.
|
|
924
|
+
*
|
|
925
|
+
* @class
|
|
926
|
+
* @extends FigureElement
|
|
927
|
+
* @group Figure Elements
|
|
928
|
+
*/
|
|
929
|
+
declare class FigureElementCollection extends FigureElement {
|
|
930
|
+
elements: Record<string, FigureElement>;
|
|
931
|
+
drawOrder: Array<string>;
|
|
932
|
+
border: TypeParsableBuffer | TypeBorder | 'children' | 'rect' | number;
|
|
933
|
+
touchBorder: TypeParsableBuffer | TypeBorder | 'border' | 'children' | 'rect' | number;
|
|
934
|
+
eqns: Record<string, any>;
|
|
935
|
+
collections: FigureCollections;
|
|
936
|
+
hasTouchableElements: boolean;
|
|
937
|
+
childrenCanAnimate: boolean;
|
|
938
|
+
drawNumberOrder: Array<number | null>;
|
|
939
|
+
preserveChildColor: boolean;
|
|
940
|
+
textureAtlases: {
|
|
941
|
+
[textureID: string]: {
|
|
942
|
+
atlas: Atlas;
|
|
943
|
+
notif: string | null;
|
|
944
|
+
};
|
|
945
|
+
};
|
|
946
|
+
/**
|
|
947
|
+
* @param {OBJ_FigureElementCollection} options
|
|
948
|
+
*/
|
|
949
|
+
constructor(options?: OBJ_FigureElementCollection);
|
|
950
|
+
cleanup(): void;
|
|
951
|
+
cleanupChildren(): void;
|
|
952
|
+
init(webgl: WebGLInstance): void;
|
|
953
|
+
_getStateProperties(options: {
|
|
954
|
+
ignoreShown?: boolean;
|
|
955
|
+
}): string[];
|
|
956
|
+
_getStatePropertiesMin(): string[];
|
|
957
|
+
getCanvas(): any;
|
|
958
|
+
getRootElement(): FigureElement | null;
|
|
959
|
+
_dup(exceptions?: Array<string>): FigureElementCollection;
|
|
960
|
+
/**
|
|
961
|
+
* Move child elements to end of draw order - effectively moving to the start
|
|
962
|
+
* of the drawn collection. Later elements in the array will be further forward.
|
|
963
|
+
* @param {Array<string | FigureElement> | string | FigureElement} elements
|
|
964
|
+
*/
|
|
965
|
+
toFront(elementsIn: Array<string | FigureElement> | string | FigureElement): void;
|
|
966
|
+
/**
|
|
967
|
+
* Move child elements to start of draw order - effectively moving them to
|
|
968
|
+
* the back of the drawn collection. Later elements in the `elements` array
|
|
969
|
+
* will be drawn further back.
|
|
970
|
+
* @param {Array<string | FigureElement> | string | FigureElement} elements
|
|
971
|
+
*/
|
|
972
|
+
toBack(elementsIn: Array<string | FigureElement> | string | FigureElement): void;
|
|
973
|
+
isAnyElementMoving(): boolean;
|
|
974
|
+
addElementWithName(name: string, element: FigureElement, index?: number): FigureElement;
|
|
975
|
+
/**
|
|
976
|
+
* Add a figure element to this collection.
|
|
977
|
+
*
|
|
978
|
+
* If adding an array of elements, then the added elements will be returned
|
|
979
|
+
* in an array (even if only one element is added). If not adding an array,
|
|
980
|
+
* then that single element will be returned.
|
|
981
|
+
*
|
|
982
|
+
* @param {string | FigureElement | OBJ_AddElement | Array<FigureElement | OBJ_AddElement>} nameOrElementOrElementDefinition
|
|
983
|
+
reference name of element
|
|
984
|
+
* @param {FigureElement} elementToAdd element to add
|
|
985
|
+
*
|
|
986
|
+
* @return {Array<FigureElement> | FigureElement} added element, or array of
|
|
987
|
+
* added elements
|
|
988
|
+
*
|
|
989
|
+
* @example
|
|
990
|
+
* // Add name and element
|
|
991
|
+
* const collection = figure.add({ make: 'collection' });
|
|
992
|
+
* const element = figure.primitives.polygon({ radius: 1 });
|
|
993
|
+
* collection.add('name', element);
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* // Element only (name will be autogenerated)
|
|
997
|
+
* const collection = figure.add({ make: 'collection' });
|
|
998
|
+
* const element = figure.primitives.polygon({ radius: 1 });
|
|
999
|
+
* collection.add(element);
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* // Element definition (if no name is provided, then name will
|
|
1003
|
+
* // be auto generated)
|
|
1004
|
+
* const collection = figure.add({ make: 'collection' });
|
|
1005
|
+
* collection.add({
|
|
1006
|
+
* make: 'polygon',
|
|
1007
|
+
* radius: 1,
|
|
1008
|
+
* });
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* // Array of elements
|
|
1012
|
+
* const collection = figure.add({ make: 'collection' });
|
|
1013
|
+
* const polygon1 = figure.primitives.polygon({ radius: 1 });
|
|
1014
|
+
* collection.add([
|
|
1015
|
+
* polygon1,
|
|
1016
|
+
* {
|
|
1017
|
+
* make: 'polygon',
|
|
1018
|
+
* radius: 0.2,
|
|
1019
|
+
* color: [0, 0, 1, 1],
|
|
1020
|
+
* },
|
|
1021
|
+
* ]);
|
|
1022
|
+
*/
|
|
1023
|
+
add(nameOrElementOrElementDefinition: string | FigureElement | OBJ_AddElement | Array<FigureElement | OBJ_AddElement>, elementToAdd?: FigureElement | null | undefined): any;
|
|
1024
|
+
getMethod(make: string): any;
|
|
1025
|
+
setFigure(figure: OBJ_FigureForElement, notify?: boolean): void;
|
|
1026
|
+
willStartAnimating(): boolean;
|
|
1027
|
+
setupDraw(now?: number, canvasIndex?: number): void;
|
|
1028
|
+
draw(now: number, scene: Scene, parentTransform?: Array<Transform>, parentOpacity?: number, targetTexture?: boolean, parentIsTouchable?: boolean, parentTouchScale?: Point | null, parentUniqueColor?: TypeColor | null, drawNumber?: number | null): void;
|
|
1029
|
+
exec(execFunctionAndArgs: string | Array<string | Record<string, any>>, elementsToExec?: Array<string | FigureElement> | null | undefined): void;
|
|
1030
|
+
pulse(optionsOrElementsOrDone?: ((OBJ_Pulse & {
|
|
1031
|
+
elements?: Array<string | FigureElement>;
|
|
1032
|
+
}) | Array<string | FigureElement> | ((arg: any) => void)) | null | undefined, done?: ((arg: any) => void) | null | undefined): void;
|
|
1033
|
+
/**
|
|
1034
|
+
* Get element from an element path with '.' separators.
|
|
1035
|
+
*
|
|
1036
|
+
* For instance, if a collection has a child collection 'a', which
|
|
1037
|
+
* has a child primitive 'b', then the path would be: 'a.b'.
|
|
1038
|
+
*
|
|
1039
|
+
* @see <a href="#figureelementcollectiongetelement">element.getElement</a>
|
|
1040
|
+
*
|
|
1041
|
+
* @param {null | string} elementPath
|
|
1042
|
+
* @return {FigureElement | null } element at path. If `elementPath`
|
|
1043
|
+
* is `null`, then this element is returned. If `elementPath` is invalid
|
|
1044
|
+
* then `null` is returned.
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
* // Get all the elements from a figure
|
|
1048
|
+
* figure.add(
|
|
1049
|
+
* {
|
|
1050
|
+
* name: 'c',
|
|
1051
|
+
* make: 'collection',
|
|
1052
|
+
* elements: [
|
|
1053
|
+
* {
|
|
1054
|
+
* name: 'tri',
|
|
1055
|
+
* make: 'triangle',
|
|
1056
|
+
* height: 0.4,
|
|
1057
|
+
* width: 0.4,
|
|
1058
|
+
* },
|
|
1059
|
+
* {
|
|
1060
|
+
* name: 'text',
|
|
1061
|
+
* make: 'text',
|
|
1062
|
+
* text: 'triangle',
|
|
1063
|
+
* position: [0, -0.4],
|
|
1064
|
+
* xAlign: 'center',
|
|
1065
|
+
* },
|
|
1066
|
+
* ],
|
|
1067
|
+
* },
|
|
1068
|
+
* );
|
|
1069
|
+
*
|
|
1070
|
+
* const c = figure.getElement('c');
|
|
1071
|
+
* // Elements within collections can be found with dot notation
|
|
1072
|
+
* const tri = figure.getElement('c.tri');
|
|
1073
|
+
* // Or the collection can be queried directly
|
|
1074
|
+
* const text = c.getElement('text');
|
|
1075
|
+
*/
|
|
1076
|
+
getElement(elementPath?: (string | FigureElement) | null | undefined): any;
|
|
1077
|
+
/**
|
|
1078
|
+
* Returns an array of result from
|
|
1079
|
+
* [getElement](#figureelementcollectiongetelement) calls on an
|
|
1080
|
+
* array of paths.
|
|
1081
|
+
*
|
|
1082
|
+
* @param {TypeElementPath} children
|
|
1083
|
+
* @return {Array<FigureElement>} Array of
|
|
1084
|
+
* [getElement](#figureelementcollectiongetelement) results
|
|
1085
|
+
*/
|
|
1086
|
+
getElements(children: TypeElementPath): Array<FigureElement>;
|
|
1087
|
+
getShown(): any[];
|
|
1088
|
+
/**
|
|
1089
|
+
* Returns an array of result from
|
|
1090
|
+
* [getElement](#figureelementcollectiongetelement) calls on an
|
|
1091
|
+
* array of paths. Same as `getElements` but more succinct
|
|
1092
|
+
*
|
|
1093
|
+
* @param {TypeElementPath} children
|
|
1094
|
+
* @return {Array<FigureElement>} Array of
|
|
1095
|
+
* [getElement](#figureelementcollectiongetelement) results
|
|
1096
|
+
*/
|
|
1097
|
+
get(children: TypeElementPath): any;
|
|
1098
|
+
getUid(uid: string): FigureElement | null;
|
|
1099
|
+
/**
|
|
1100
|
+
* Show collection or specific elements within the collection
|
|
1101
|
+
*/
|
|
1102
|
+
show(toShow?: TypeElementPath): void;
|
|
1103
|
+
showOnly(toShow?: TypeElementPath): void;
|
|
1104
|
+
showAll(): void;
|
|
1105
|
+
/**
|
|
1106
|
+
* Hide collection or specific elements within the collection
|
|
1107
|
+
*/
|
|
1108
|
+
hide(toHide?: TypeElementPath | null): void;
|
|
1109
|
+
hideAll(): void;
|
|
1110
|
+
hideOnly(listToHide: TypeElementPath): void;
|
|
1111
|
+
resizeHtmlObject(): void;
|
|
1112
|
+
resize(figureHTMLElement?: HTMLElement | null): void;
|
|
1113
|
+
clear(canvasIndex?: number): void;
|
|
1114
|
+
setFirstTransform(parentTransform?: Transform): void;
|
|
1115
|
+
getBorderPoints(border?: 'border' | 'touchBorder', children?: Array<string | FigureElement> | null, shownOnly?: boolean): TypeBorder;
|
|
1116
|
+
/**
|
|
1117
|
+
* Get the border or touchBorder of a FigureElementCollection in a defined
|
|
1118
|
+
* coordinate space.
|
|
1119
|
+
*
|
|
1120
|
+
* @param {TypeCoordinateSpace} space (`'local`)
|
|
1121
|
+
* @param {'border' | 'touchBorder'} border (`'border'`)
|
|
1122
|
+
* @param {Array<string | FigureElement> | null} children choose specific
|
|
1123
|
+
* children only - use `null` for all children (`null`)
|
|
1124
|
+
* @param {boolean} shownOnly if `true` then only children that are shown
|
|
1125
|
+
* will be used (`true`)
|
|
1126
|
+
* @return {Array<Array<Point>>}
|
|
1127
|
+
*/
|
|
1128
|
+
getBorder(space?: TypeCoordinateSpace | Type3DMatrix, border?: 'touchBorder' | 'border', children?: Array<string | FigureElement> | null | undefined, shownOnly?: boolean): any[];
|
|
1129
|
+
getBoundingRect(space?: TypeCoordinateSpace, border?: 'touchBorder' | 'border', children?: Array<string | FigureElement> | null | undefined, shownOnly?: boolean): Rect;
|
|
1130
|
+
getRelativeBoundingRect(space?: TypeCoordinateSpace, border?: 'border' | 'touchBorder', children?: Array<string | FigureElement> | null | undefined, shownOnly?: boolean): Rect;
|
|
1131
|
+
getPositionInBounds(space?: TypeCoordinateSpace, xAlign?: 'center' | 'left' | 'right' | 'location' | number, yAlign?: 'middle' | 'top' | 'bottom' | 'location' | number, children?: Array<string | FigureElement> | null | undefined, border?: 'border' | 'touchBorder', shownOnly?: boolean): Point;
|
|
1132
|
+
setUniqueColor(color: null | TypeColor): void;
|
|
1133
|
+
getUniqueColorElement(color: TypeColor): FigureElement | null;
|
|
1134
|
+
updateHTMLElementTie(container: HTMLElement): void;
|
|
1135
|
+
getTouched(glLocation: Point): Array<FigureElement>;
|
|
1136
|
+
setHasTouchableElements(): void;
|
|
1137
|
+
getSelectionFromBorders(glLocation: Point): FigureElement | null;
|
|
1138
|
+
stop(how?: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete', elementOnly?: boolean): void;
|
|
1139
|
+
setFont(fontSize: number): void;
|
|
1140
|
+
setColor(color?: TypeColor, setDefault?: boolean): void;
|
|
1141
|
+
setDimColor(color?: TypeColor): void;
|
|
1142
|
+
undim(children?: TypeElementPath | null | undefined): void;
|
|
1143
|
+
dim(children?: TypeElementPath | null | undefined): void;
|
|
1144
|
+
highlight(elementsToHighlight?: TypeElementPath | null | undefined): void;
|
|
1145
|
+
getElementTransforms(): Record<string, any>;
|
|
1146
|
+
getElementColors(onlyShown?: boolean): Record<string, any>;
|
|
1147
|
+
setElementTransforms(elementTransforms: Record<string, any>): void;
|
|
1148
|
+
setElementColors(elementColors: Record<string, any>): void;
|
|
1149
|
+
reorder(): void;
|
|
1150
|
+
animateToTransforms(elementTransforms: Record<string, any>, time?: number, delay?: number, rotDirection?: number, callback?: (string | ((arg: any | null | undefined) => void)) | null | undefined, name?: string, easeFunction?: string | ((n: number) => number)): number;
|
|
1151
|
+
animateToColors(elementColors: Record<string, any>, time?: number, delay?: number, callback?: (string | ((arg: any | null | undefined) => void)) | null | undefined, name?: string, easeFunction?: string | ((n: number) => number)): number;
|
|
1152
|
+
/**
|
|
1153
|
+
* Get all elements within the collection that are primitives, including
|
|
1154
|
+
* any primitives that are children of this element, and any primitives that
|
|
1155
|
+
* are children of this element's children and so forth.
|
|
1156
|
+
*
|
|
1157
|
+
* @return {Array<FigureElement>}
|
|
1158
|
+
*/
|
|
1159
|
+
getAllPrimitives(): FigureElement[];
|
|
1160
|
+
/**
|
|
1161
|
+
* Get an array of all elements of in this collection, including this element,
|
|
1162
|
+
* children, children of children and so forth.
|
|
1163
|
+
*
|
|
1164
|
+
* @return {Array<FigureElement>}
|
|
1165
|
+
*/
|
|
1166
|
+
getAllElements(): FigureElement[];
|
|
1167
|
+
fontUpdated(): void;
|
|
1168
|
+
getAtlases(callback?: (() => void) | null): void;
|
|
1169
|
+
/**
|
|
1170
|
+
* Recreate all atlases associated with children of this collection.
|
|
1171
|
+
*/
|
|
1172
|
+
recreateAtlases(): void;
|
|
1173
|
+
/**
|
|
1174
|
+
* Get array of all children elements.
|
|
1175
|
+
*
|
|
1176
|
+
* @return {Array<FigureElement>}
|
|
1177
|
+
*/
|
|
1178
|
+
getChildren(): FigureElement[];
|
|
1179
|
+
getAllElementsWithScenario(scenario: string): Array<FigureElement>;
|
|
1180
|
+
getNextAnimationFinishTime(): number | null;
|
|
1181
|
+
getRemainingAnimationTime(animationNames?: Array<string> | string): number;
|
|
1182
|
+
getAllPossiblyInteractiveElements(): FigureElement[];
|
|
1183
|
+
goToStep(step: number): void;
|
|
1184
|
+
setupWebGLBuffers(newWebgl: WebGLInstance): void;
|
|
1185
|
+
changeWebGLInstance(newWebgl: WebGLInstance): any;
|
|
1186
|
+
getLoadingElements(): any[];
|
|
1187
|
+
setPointsFromDefinition(): void;
|
|
1188
|
+
setPrimitiveColors(): void;
|
|
1189
|
+
unrenderAll(): void;
|
|
1190
|
+
setScenarios(scenarioName: string | Array<string>, onlyIfVisible?: boolean): void;
|
|
1191
|
+
saveScenarios(scenarioName: string, keys: Array<string>): void;
|
|
1192
|
+
animateToState(state: Record<string, any>, options: Record<string, any>, independentOnly?: boolean, startTime?: number | 'now' | 'prevFrame' | 'nextFrame' | null | undefined): number;
|
|
1193
|
+
dissolveInToState(state: Record<string, any>, durationIn?: number, startTime?: number | 'now' | 'prevFrame' | 'nextFrame' | null | undefined): number;
|
|
1194
|
+
setTimeDelta(delta: number): void;
|
|
1195
|
+
isStateSame(state: Record<string, any>, mergePulseTransforms?: boolean, exceptions?: Array<string>): boolean;
|
|
1196
|
+
clearFrozenPulseTransforms(): void;
|
|
1197
|
+
freezePulseTransforms(forceOverwrite?: boolean): void;
|
|
1198
|
+
isAnimating(): boolean;
|
|
1199
|
+
remove(elementName: string): void;
|
|
1200
|
+
stopAnimating(how?: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete', name?: string | null, includeChildren?: boolean): void;
|
|
1201
|
+
stateSet(): void;
|
|
1202
|
+
contextLost(): void;
|
|
1203
|
+
_state(options?: {
|
|
1204
|
+
precision?: number;
|
|
1205
|
+
ignoreShown?: boolean;
|
|
1206
|
+
min?: boolean;
|
|
1207
|
+
returnF1Type?: boolean;
|
|
1208
|
+
}): Record<string, any>;
|
|
1209
|
+
align(xAlign: 'left' | 'center' | 'right' | number, yAlign: 'bottom' | 'middle' | 'top' | number): void;
|
|
1210
|
+
getFonts(): any[];
|
|
1211
|
+
}
|
|
1212
|
+
export { FigureElementPrimitive, FigureElementCollection, FigureElement, };
|