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.
Files changed (159) hide show
  1. package/figureone.min.js +1 -1
  2. package/index.js +79167 -0
  3. package/package.json +15 -1
  4. package/types/index.d.ts +132 -0
  5. package/types/js/figure/Animation/Animation.d.ts +36 -0
  6. package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
  7. package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
  8. package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
  9. package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
  10. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
  11. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
  12. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
  13. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
  14. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
  15. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
  16. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
  17. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
  18. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
  19. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
  20. package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
  21. package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
  22. package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
  23. package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
  24. package/types/js/figure/DrawContext2D.d.ts +9 -0
  25. package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
  26. package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
  27. package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
  28. package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
  29. package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
  30. package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
  31. package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
  32. package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
  33. package/types/js/figure/Element.d.ts +1212 -0
  34. package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
  35. package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
  36. package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
  37. package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
  38. package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
  39. package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
  40. package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
  41. package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
  42. package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
  43. package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
  44. package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
  45. package/types/js/figure/Equation/Equation.d.ts +984 -0
  46. package/types/js/figure/Equation/EquationForm.d.ts +139 -0
  47. package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
  48. package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
  49. package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
  50. package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
  51. package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
  52. package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
  53. package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
  54. package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
  55. package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
  56. package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
  57. package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
  58. package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
  59. package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
  60. package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
  61. package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
  62. package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
  63. package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
  64. package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
  65. package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
  66. package/types/js/figure/Figure.d.ts +711 -0
  67. package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
  68. package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
  69. package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
  70. package/types/js/figure/FigureCollections/Button.d.ts +195 -0
  71. package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
  72. package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
  73. package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
  74. package/types/js/figure/FigureCollections/Line.d.ts +587 -0
  75. package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
  76. package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
  77. package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
  78. package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
  79. package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
  80. package/types/js/figure/FigureCollections/Text.d.ts +307 -0
  81. package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
  82. package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
  83. package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
  84. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
  85. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
  86. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
  87. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
  88. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
  89. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
  90. package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
  91. package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
  92. package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
  93. package/types/js/figure/FontManager.d.ts +113 -0
  94. package/types/js/figure/Gesture.d.ts +39 -0
  95. package/types/js/figure/Recorder/Recorder.d.ts +291 -0
  96. package/types/js/figure/Recorder/parseState.d.ts +3 -0
  97. package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
  98. package/types/js/figure/Recorder/state.d.ts +7 -0
  99. package/types/js/figure/SlideNavigator.d.ts +606 -0
  100. package/types/js/figure/TimeKeeper.d.ts +174 -0
  101. package/types/js/figure/geometries/arc.d.ts +18 -0
  102. package/types/js/figure/geometries/arrow.d.ts +215 -0
  103. package/types/js/figure/geometries/buffer.d.ts +4 -0
  104. package/types/js/figure/geometries/copy/copy.d.ts +178 -0
  105. package/types/js/figure/geometries/ellipse.d.ts +17 -0
  106. package/types/js/figure/geometries/line.d.ts +13 -0
  107. package/types/js/figure/geometries/lines/corners.d.ts +7 -0
  108. package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
  109. package/types/js/figure/geometries/lines/lines.d.ts +31 -0
  110. package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
  111. package/types/js/figure/geometries/rectangle.d.ts +19 -0
  112. package/types/js/figure/geometries/triangle.d.ts +27 -0
  113. package/types/js/figure/webgl/Atlas.d.ts +42 -0
  114. package/types/js/figure/webgl/shaders.d.ts +143 -0
  115. package/types/js/figure/webgl/target.d.ts +9 -0
  116. package/types/js/figure/webgl/webgl.d.ts +54 -0
  117. package/types/js/tools/FunctionMap.d.ts +69 -0
  118. package/types/js/tools/color.d.ts +11 -0
  119. package/types/js/tools/colorNames.d.ts +2 -0
  120. package/types/js/tools/d2/polygon.d.ts +60 -0
  121. package/types/js/tools/d2/triangles.d.ts +0 -0
  122. package/types/js/tools/d3/cone.d.ts +57 -0
  123. package/types/js/tools/d3/cube.d.ts +26 -0
  124. package/types/js/tools/d3/cylinder.d.ts +45 -0
  125. package/types/js/tools/d3/line3.d.ts +55 -0
  126. package/types/js/tools/d3/prism.d.ts +49 -0
  127. package/types/js/tools/d3/revolve.d.ts +87 -0
  128. package/types/js/tools/d3/sphere.d.ts +33 -0
  129. package/types/js/tools/d3/surface.d.ts +47 -0
  130. package/types/js/tools/g2.d.ts +242 -0
  131. package/types/js/tools/geometry/Bounds.d.ts +446 -0
  132. package/types/js/tools/geometry/Line.d.ts +314 -0
  133. package/types/js/tools/geometry/Path.d.ts +67 -0
  134. package/types/js/tools/geometry/Plane.d.ts +201 -0
  135. package/types/js/tools/geometry/Point.d.ts +359 -0
  136. package/types/js/tools/geometry/Rect.d.ts +115 -0
  137. package/types/js/tools/geometry/Transform.d.ts +623 -0
  138. package/types/js/tools/geometry/angle.d.ts +105 -0
  139. package/types/js/tools/geometry/common.d.ts +9 -0
  140. package/types/js/tools/geometry/coordinates.d.ts +30 -0
  141. package/types/js/tools/geometry/deceleration.d.ts +13 -0
  142. package/types/js/tools/geometry/polygon.d.ts +4 -0
  143. package/types/js/tools/geometry/quaternion.d.ts +15 -0
  144. package/types/js/tools/geometry/scene.d.ts +282 -0
  145. package/types/js/tools/geometry/tools.d.ts +8 -0
  146. package/types/js/tools/geometry/types.d.ts +2 -0
  147. package/types/js/tools/getCssColors.d.ts +1 -0
  148. package/types/js/tools/getCssVariables.d.ts +4 -0
  149. package/types/js/tools/getImageData.d.ts +1 -0
  150. package/types/js/tools/getScssColors.d.ts +2 -0
  151. package/types/js/tools/htmlGenerator.d.ts +85 -0
  152. package/types/js/tools/m2.d.ts +24 -0
  153. package/types/js/tools/m3.d.ts +71 -0
  154. package/types/js/tools/math.d.ts +112 -0
  155. package/types/js/tools/morph.d.ts +651 -0
  156. package/types/js/tools/styleSheets.d.ts +3 -0
  157. package/types/js/tools/tools.d.ts +281 -0
  158. package/types/js/tools/types.d.ts +305 -0
  159. package/figureone.worker.js +0 -1
@@ -0,0 +1,711 @@
1
+ import WebGLInstance from './webgl/webgl';
2
+ import { Point, Transform } from '../tools/g2';
3
+ import Scene from '../tools/geometry/scene';
4
+ import type { OBJ_Scene } from '../tools/geometry/scene';
5
+ import type { TypeParsableRect, TypeParsablePoint } from '../tools/g2';
6
+ import type { Type3DMatrix } from '../tools/m3';
7
+ import { FunctionMap } from '../tools/FunctionMap';
8
+ import { NotificationManager } from '../tools/tools';
9
+ import { FigureElementCollection, FigureElement } from './Element';
10
+ import type { OBJ_AddElement, TypeElementPath } from './Element';
11
+ import TimeKeeper from './TimeKeeper';
12
+ import { Recorder } from './Recorder/Recorder';
13
+ import Gesture from './Gesture';
14
+ import type { TypeParsablePlane } from '../tools/geometry/Plane';
15
+ import DrawContext2D from './DrawContext2D';
16
+ import FigurePrimitives from './FigurePrimitives/FigurePrimitives';
17
+ import type { OBJ_Polyline } from './FigurePrimitives/FigurePrimitiveTypes2D';
18
+ import FigureCollections from './FigureCollections/FigureCollections';
19
+ import AnimationManager from './Animation/AnimationManager';
20
+ import type { OBJ_ScenarioVelocity } from './Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep';
21
+ import type { TypeColor, OBJ_Font } from '../tools/types';
22
+ import type { COL_SlideNavigator } from './FigureCollections/SlideNavigator';
23
+ import type FigureElementPrimitiveGesture from './FigurePrimitives/FigureElementPrimitiveGesture';
24
+ import FontManager from './FontManager';
25
+ import type { OBJ_FormattedText } from './FigureCollections/Text';
26
+ /**
27
+ * Space Transforms
28
+ *
29
+ * @property {Transform} glToFigure
30
+ * @property {Transform} figureToGL
31
+ * @property {Transform} pixelToFigure
32
+ * @property {Transform} figureToPixel
33
+ * @property {Transform} pixelToGL
34
+ * @property {Transform} glToPixel
35
+ * @interface
36
+ * @group Misc Shapes
37
+ */
38
+ export type OBJ_SpaceTransforms = {
39
+ glToFigure: Transform;
40
+ figureToGL: Transform;
41
+ pixelToFigure: Transform;
42
+ figureToPixel: Transform;
43
+ pixelToGL: Transform;
44
+ glToPixel: Transform;
45
+ glToPixelMatrix: Type3DMatrix;
46
+ figureToGLMatrix: Type3DMatrix;
47
+ figureToPixelMatrix: Type3DMatrix;
48
+ };
49
+ export type OBJ_FigureLimits = {
50
+ x: {
51
+ min: number;
52
+ max: number;
53
+ };
54
+ y: {
55
+ min: number;
56
+ max: number;
57
+ };
58
+ z: {
59
+ min: number;
60
+ max: number;
61
+ };
62
+ };
63
+ export type OBJ_FigureForElement = {
64
+ animateNextFrame: (draw?: boolean | null, fromWhere?: string | null) => void;
65
+ animationFinished: () => void;
66
+ recorder: Recorder;
67
+ timeKeeper: TimeKeeper;
68
+ notifications: NotificationManager;
69
+ pixelToGL: (p: Point) => Point;
70
+ preventDefault: () => void;
71
+ };
72
+ /**
73
+ * Figure options object
74
+ * @property {string} [htmlId] HTML `div` tag `id` to tie figure to (`"figureOneContainer"`)
75
+ * @property {OBJ_Scene | TypeParsableRect} [scene] define 2D or 3D scene. 3D
76
+ * can be orthographic or perspective projection, and include camera position
77
+ * and lighting definition. A 2D scene can be defined using `left`, `right`,
78
+ * `bottom` and `top`, or the short hand rectangle definition.
79
+ * @property {TypeColor} [color] default shape color (`[0, 0, 0, 1]`)
80
+ * @property {OBJ_Font} [font] default shape font (`{ family: 'Helvetica,
81
+ * size: 0.2, style: 'normal', weight: 'normal' }`)
82
+ * @property {number} [lineWidth] default shape line width
83
+ * @property {number} [length] default shape primary dimension
84
+ * @property {TypeColor} [backgroundColor] background color for the figure.
85
+ * Use [r, g, b, 1] for opaque and [0, 0, 0, 0] for transparent.
86
+ * @interface
87
+ * @group Figure
88
+ */
89
+ export type OBJ_Figure = {
90
+ htmlId?: string;
91
+ scene?: OBJ_Scene | TypeParsableRect;
92
+ color?: TypeColor;
93
+ font?: OBJ_Font;
94
+ lineWidth?: number;
95
+ length?: number;
96
+ backgroundColor?: number;
97
+ };
98
+ /**
99
+ * Primary Figure class.
100
+ *
101
+ * A figure will attach a WebGL canvas and 2D canvas
102
+ * to the html `div` element with id `"figureOneContainer"`.
103
+ *
104
+ * The figure creates and manages all drawing elements, renders the drawing
105
+ * elements on a browser's animation frames and listens for guestures from the
106
+ * user.
107
+ *
108
+ * The figure also has a recorder, allowing it to record and playback states,
109
+ * and gestures.
110
+ *
111
+ * To attach to a different `div`, use the `htmlId` property in the class
112
+ * constructor.
113
+ *
114
+ * If a figure is paused, then all drawing element animations will
115
+ * also be paused.
116
+ *
117
+ * `Figure` has a number of convenience methods for creating drawing elements
118
+ * and useful transforms for converting between the different spaces (e.g.
119
+ * pixel, GL, figure).
120
+ *
121
+ * Notifications - The notification manager property `notifications` will
122
+ * publish the following events:
123
+ * - `beforeDraw`: published before a frame is drawn
124
+ * - `afterDraw`: published after a frame is drawn
125
+ * - `resize`: published after a resize event, but before frame drawing
126
+ *
127
+ * @class
128
+ * @param {OBJ_Figure} options
129
+ * @property {FigurePrimitives} primitives create figure primitives such
130
+ * as shapes, lines and grids
131
+ * @property {FigureCollections} collections create figure collections such
132
+ * as advanced lines, shapes, equations and plots
133
+ * @property {NotificationManager} notifications notification manager for
134
+ * element
135
+ * @property {FontManager} fonts watches and reports on font availability
136
+ *
137
+ * @example
138
+ * // Simple html and javascript example to create a figure, and add a
139
+ * // hexagon.
140
+ * //
141
+ * // For additional examples, see https://github.com/airladon/FigureOne
142
+ * //
143
+ * // Two files `index.html` and `index.js` in the same directory
144
+ *
145
+ * // index.html
146
+ * <!doctype html>
147
+ * <html>
148
+ * <body>
149
+ * <div id="figureOneContainer" style="width: 800px; height: 800px; background-color: white;">
150
+ * </div>
151
+ * <script type="text/javascript" src='https://cdn.jsdelivr.net/npm figureone@0.15.10/figureone.min.js'></script>
152
+ * <script type="text/javascript" src='./index.js'></script>
153
+ * </body>
154
+ * </html>
155
+ *
156
+ * // index.js
157
+ * const figure = new Fig.Figure({ scene: [-1, -1, 1, 1 ]});
158
+ * figure.add(
159
+ * {
160
+ * name: 'p',
161
+ * make: 'polygon',
162
+ * radius: 0.5,
163
+ * sides: 6,
164
+ * },
165
+ * );
166
+ *
167
+ * @example
168
+ * // Alternately, an element can be added programatically
169
+ * // index.js
170
+ * const figure = new Fig.Figure({ scene: [-1, -1, 1, 1 ]});
171
+ * const hex = figure.shapes.polygon({
172
+ * radius: 0.5,
173
+ * sides: 6,
174
+ * });
175
+ * figure.add('hexagon', hex);
176
+ * @group Figure
177
+ */
178
+ declare class Figure {
179
+ htmlId: string;
180
+ canvasLow: HTMLCanvasElement;
181
+ canvasOffscreen: HTMLCanvasElement;
182
+ textCanvasLow: HTMLCanvasElement;
183
+ textCanvasOffscreen: HTMLCanvasElement;
184
+ container: HTMLElement;
185
+ draw2DLow: DrawContext2D;
186
+ draw2DOffscreen: DrawContext2D;
187
+ htmlCanvas: HTMLElement;
188
+ webglLow: WebGLInstance;
189
+ webglOffscreen: WebGLInstance;
190
+ gestureCanvas: HTMLElement;
191
+ elements: FigureElementCollection;
192
+ timeKeeper: TimeKeeper;
193
+ recorder: Recorder;
194
+ gesture: Gesture;
195
+ beingMovedElement: null | FigureElement;
196
+ beingTouchedElement: null | FigureElement | FigureElementPrimitiveGesture;
197
+ previousCursorPoint: Point;
198
+ originalScalePoint: Point | null;
199
+ stateTime: DOMHighResTimeStamp;
200
+ shapes: FigurePrimitives;
201
+ shapesLow: any;
202
+ primitives: FigurePrimitives;
203
+ collections: FigureCollections;
204
+ collectionsLow: FigureCollections;
205
+ backgroundColor: Array<number>;
206
+ fontScale: number;
207
+ lastDrawTime: number;
208
+ drawQueued: boolean;
209
+ waitForFrames: number;
210
+ scrolled: boolean;
211
+ scrollingFast: boolean;
212
+ scrollTimeoutId: any;
213
+ drawTimeoutId: any;
214
+ oldScroll: number;
215
+ fromWhere: string;
216
+ oldWidth: number;
217
+ drawAnimationFrames: number;
218
+ defaultColor: Array<number>;
219
+ defaultDimColor: Array<number>;
220
+ defaultFont: OBJ_Font;
221
+ defaultLineWidth: number;
222
+ defaultLength: number;
223
+ animationFinishedCallback: string | (() => void) | null | undefined;
224
+ gesturePreventDefault: 'prevent' | 'allow' | 'ifTouched';
225
+ isTouchDevice: boolean;
226
+ fnMap: FunctionMap;
227
+ moveBuffer: Array<[Point, Point]>;
228
+ isPaused: boolean;
229
+ pauseTime: number;
230
+ cursorShown: boolean;
231
+ cursorElementName: string;
232
+ slideNavigatorElementName: string;
233
+ isTouchDown: boolean;
234
+ setStateCallback: string | (() => void) | null | undefined;
235
+ notifications: NotificationManager;
236
+ mockPreviousTouchPoint: Point;
237
+ shortcuts: Record<string, any>;
238
+ nextDrawTimer: number | null;
239
+ nextDrawTimerStart: number;
240
+ nextDrawTimerDuration: number;
241
+ focused: boolean;
242
+ frameRate: {
243
+ information: null | Array<string | OBJ_FormattedText>;
244
+ history: Array<Array<number>>;
245
+ num: number;
246
+ };
247
+ pixelSpace: {
248
+ x: {
249
+ min: number;
250
+ span: number;
251
+ };
252
+ y: {
253
+ min: number;
254
+ span: number;
255
+ };
256
+ };
257
+ defaultPrevented: boolean;
258
+ mousePixelPosition: null | Point;
259
+ lostContextMessage: HTMLElement;
260
+ scene: Scene;
261
+ fonts: FontManager;
262
+ animations: AnimationManager;
263
+ state: {
264
+ pause: 'paused' | 'preparingToPause' | 'preparingToUnpause' | 'unpaused';
265
+ preparingToStop: boolean;
266
+ preparingToSetState: boolean;
267
+ };
268
+ ext: any;
269
+ constructor(options?: OBJ_Figure);
270
+ fontsLoaded(): void;
271
+ /**
272
+ * Add a {@link CollectionsSlideNavigator} that controls the root collection of this figure.
273
+ *
274
+ * @return {CollectionsSlideNavigator}
275
+ */
276
+ addSlideNavigator(options: COL_SlideNavigator): any;
277
+ /**
278
+ * Get the {@link CollectionsSlideNavigator} for the figure (will only return
279
+ * if the navigator was added with `figure.addSlideNavigator`).
280
+ *
281
+ * @return {CollectionsSlideNavigator}
282
+ */
283
+ getSlideNavigator(): any;
284
+ /**
285
+ * Add cursor for recording interactive videos. Cursor will be hidden when
286
+ * first added.
287
+ * @return {FigureElement} cursor element
288
+ */
289
+ addCursor(options: Record<string, any>): any;
290
+ /**
291
+ * Get cursor element.
292
+ @return {FigureElement} cursor element
293
+ */
294
+ getCursor(): any;
295
+ bindRecorder(): void;
296
+ setDefaultLineWidth(userInputLineWidth: number | null): void;
297
+ setDefaultLength(userInputLength: number | null): void;
298
+ scrollEvent(): void;
299
+ enableScrolling(): void;
300
+ disableScrolling(): void;
301
+ init(webgl: WebGLInstance): void;
302
+ getState(options: {
303
+ precision?: number;
304
+ ignoreShown?: boolean;
305
+ min?: boolean;
306
+ }): Record<string, any>;
307
+ setState(stateIn: Record<string, any>, optionsIn?: {
308
+ how: 'animate' | 'dissolve' | 'instant';
309
+ duration?: number | {
310
+ dissovlveOut?: number | null | undefined;
311
+ dissovlveIn?: number | null | undefined;
312
+ delay?: number | null | undefined;
313
+ };
314
+ velocity?: OBJ_ScenarioVelocity;
315
+ maxDuration?: number;
316
+ zeroDurationThreshold?: boolean;
317
+ allDurationsSame?: boolean;
318
+ } | 'dissolve' | 'animate' | 'instant'): void;
319
+ animateToState(state: Record<string, any>, optionsIn: Record<string, any> | undefined, done: string | (() => void) | null | undefined, startTime?: number | 'now' | 'prevFrame' | 'nextFrame' | null | undefined): void;
320
+ dissolveToState(optionsIn: {
321
+ state: Record<string, any>;
322
+ dissolveOutDuration: number;
323
+ dissolveInDuration: number;
324
+ delay: number;
325
+ done: string | (() => void) | null | undefined;
326
+ startTime: number | 'now' | 'prev' | 'next' | null | undefined;
327
+ }): void;
328
+ dissolveInToState(optionsIn: {
329
+ state: Record<string, any>;
330
+ duration: number;
331
+ done: string | (() => void) | null | undefined;
332
+ startTime: number | 'now' | 'prev' | 'next' | null | undefined;
333
+ }): void;
334
+ /**
335
+ * Add a figure element to the root collection of the figure.
336
+ *
337
+ * If adding an array of elements, then the added elements will be returned
338
+ * in an array (even if only one element is added). If not adding an array,
339
+ * then that single element will be returned.
340
+ *
341
+ * @param {string | FigureElement | OBJ_AddElement | Array<FigureElement | OBJ_AddElement>} nameOrElementOrElementDefinition
342
+ reference name of element
343
+ * @param {FigureElement} elementToAdd element to add
344
+ *
345
+ * @return {Array<FigureElement> | FigureElement} added element, or array of
346
+ * added elements
347
+ *
348
+ * @example
349
+ * // Add name and element
350
+ * const element = figure.primitives.polygon({ radius: 1 });
351
+ * figure.add('name', element);
352
+ *
353
+ * @example
354
+ * // Element only (name will be autogenerated)
355
+ * const element = figure.primitives.polygon({ radius: 1 });
356
+ * figure.add(element);
357
+ *
358
+ * @example
359
+ * // Element definition (if no name is provided, then name will
360
+ * // be auto generated)
361
+ * figure.add({
362
+ * make: 'polygon',
363
+ * radius: 1,
364
+ * });
365
+ *
366
+ * @example
367
+ * // Array of elements
368
+ * const element = figure.primitives.polygon({ radius: 1 });
369
+ * figure.add([
370
+ * element,
371
+ * {
372
+ * make: 'polygon',
373
+ * radius: 0.2,
374
+ * color: [0, 0, 1, 1],
375
+ * },
376
+ * ]);
377
+ */
378
+ add(nameOrElementOrElementDefinition: string | FigureElement | OBJ_AddElement | Array<FigureElement | OBJ_AddElement>, elementToAdd?: FigureElement | null | undefined): any;
379
+ /**
380
+ * Get element from an element path with '.' separators.
381
+ *
382
+ * For instance, if a collection has a child collection 'a', which
383
+ * has a child primitive 'b', then the path would be: 'a.b'.
384
+ *
385
+ * @see <a href="#figureelementcollectiongetelement">element.getElement</a>
386
+ *
387
+ * @param {null | string} elementPath
388
+ * @return {FigureElement | null } element at path. If `elementPath`
389
+ * is `null`, then the figure's base collection is returned. If `elementPath`
390
+ * is invalid then `null` is returned.
391
+ *
392
+ * @example
393
+ * // Get all the elements from a figure
394
+ * figure.add(
395
+ * {
396
+ * name: 'c',
397
+ * make: 'collection',
398
+ * elements: [
399
+ * {
400
+ * name: 'tri',
401
+ * make: 'triangle',
402
+ * height: 0.4,
403
+ * width: 0.4,
404
+ * },
405
+ * {
406
+ * name: 'text',
407
+ * make: 'text',
408
+ * text: 'triangle',
409
+ * position: [0, -0.4],
410
+ * xAlign: 'center',
411
+ * },
412
+ * ],
413
+ * },
414
+ * );
415
+ *
416
+ * const c = figure.getElement('c');
417
+ * // Elements within collections can be found with dot notation
418
+ * const tri = figure.getElement('c.tri');
419
+ * // Or the collection can be queried directly
420
+ * const text = c.getElement('text');
421
+ */
422
+ getElement(elementName: string): any;
423
+ /**
424
+ * Returns an array of result from
425
+ * [getElement](#figureelementcollectiongetelement) calls on an
426
+ * array of paths.
427
+ *
428
+ * @param {TypeElementPath} children
429
+ * @return {Array<FigureElement>} Array of
430
+ * [getElement](#figureelementcollectiongetelement) results
431
+ */
432
+ getElements(children: TypeElementPath): FigureElement[];
433
+ /**
434
+ * Returns an array of result from
435
+ * [getElement](#figureelementcollectiongetelement) calls on an
436
+ * array of paths. Same as `getElements` but more succinct
437
+ *
438
+ * @param {TypeElementPath} children
439
+ * @return {Array<FigureElement>} Array of
440
+ * [getElement](#figureelementcollectiongetelement) results
441
+ */
442
+ get(children: TypeElementPath): any;
443
+ getShapes(): FigurePrimitives;
444
+ getObjects(): FigureCollections;
445
+ sizeHtmlText(): void;
446
+ loseContext(): void;
447
+ contextLost(event: WebGLContextEvent): void;
448
+ contextRestored(): void;
449
+ restoreContext(): void;
450
+ destroy(): void;
451
+ /**
452
+ * Recreate all automatically generated atlases.
453
+ *
454
+ * This would be typically used after loading custom fonts.
455
+ */
456
+ recreateAtlases(): void;
457
+ recreateAtlas(atlasID: string): void;
458
+ getAtlases(): {
459
+ [atlasId: string]: import("./webgl/Atlas").default;
460
+ };
461
+ /**
462
+ * Return matrix that can convert between 'pixel', 'figure' and 'gl' spaces.
463
+ *
464
+ * These matrices would be generally used to transform points between spaces.
465
+ * `transformPoint` can be used to do this for individual points, but if
466
+ * converting many points, then generating the transform matrix once and
467
+ * applying it to each point can be more efficient.
468
+ *
469
+ * Depending on the type of figure scene, not all space combinations are
470
+ * possible.
471
+ *
472
+ * For 2D scenes, all combinations are possible.
473
+ *
474
+ * For 3D scenes:
475
+ * - 'pixel' to 'gl' will transform a point in pixel space to a point on the
476
+ * XY plane at Z = 0 in GL space.
477
+ * - 'pixel' to 'figure' is not valid. Use `transformPoint` instead where a
478
+ * plane can be defined to intersect with.
479
+ * - Conversions between 'gl' and 'figure' are only valid for 'orthographic'
480
+ * projections. For perspective projections, the transform matrix is not
481
+ * general and depends coordinates of the point to be transformed. Use
482
+ * `transformPoint` for each point to be transformed.
483
+ */
484
+ spaceTransformMatrix(from: 'figure' | 'gl' | 'pixel', to: 'figure' | 'gl' | 'pixel'): Type3DMatrix;
485
+ /**
486
+ * Transform a point between 'figure', 'gl' and 'pixel' spaces.
487
+ *
488
+ * `plane` is only needed when converting from pixel space (a 2D space) to
489
+ * 'figure' space or 'gl' space (a 3D space). A ray from the pixel is drawn
490
+ * into the screen and the intersection with the defined `plane` is returned.
491
+ *
492
+ * @param {TypeParsablePoint} point
493
+ * @param {'figure' | 'gl' | 'pixel'} fromSpace space to convert point from
494
+ * @param {'figure' | 'gl' | 'pixel'} toSpace space to convert point to
495
+ * @param {TypeParsablePlane} plane figure space intersection plane for
496
+ * 'pixel' to 'figure' conversion (default: xy plane at z = 0)
497
+ */
498
+ transformPoint(point: TypeParsablePoint, fromSpace: 'figure' | 'gl' | 'pixel', toSpace: 'figure' | 'gl' | 'pixel', plane?: TypeParsablePlane): Point;
499
+ initialize(): void;
500
+ initElements(): void;
501
+ setElements(collection: FigureElementCollection): void;
502
+ /**
503
+ * Get remaining animation durations of running animations
504
+ */
505
+ getRemainingAnimationTime(nowIn?: number): number | null;
506
+ setAnimationFinishedCallback(callback: string | (() => void) | null | undefined): void;
507
+ animationFinished(): void;
508
+ setFirstTransform(): void;
509
+ renderAllElementsToTiedCanvases(force?: boolean): void;
510
+ renderElementToTiedCanvas(elementName: string): void;
511
+ renderToCanvas(htmlCanvasElementOrId?: string): void;
512
+ unrenderAll(): void;
513
+ resize(skipHTMLTie?: boolean): void;
514
+ getPixelSpace(): void;
515
+ pixelToGL(pixelPoint: Point): Point;
516
+ updateHTMLElementTie(): void;
517
+ /**
518
+ * Show specific elements within the figure
519
+ */
520
+ show(toShow?: TypeElementPath): void;
521
+ /**
522
+ * Hide specific elements within the figure
523
+ */
524
+ hide(toShow?: TypeElementPath): void;
525
+ /**
526
+ * Show specific elements within a figure, while hiding all others
527
+ */
528
+ showOnly(toShow?: TypeElementPath): void;
529
+ /**
530
+ * Set scenarios of all elements with scenarioName defined
531
+ */
532
+ setScenarios(scenarioName: string, onlyIfVisible?: boolean): void;
533
+ toggleCursor(): void;
534
+ showCursor(show: 'up' | 'down' | 'hide', position?: Point | null | undefined): void;
535
+ isCursorShown(): any;
536
+ mousePosition(pixelPoint: Point): void;
537
+ preventDefault(): void;
538
+ wheelHandler(deltaX: number, deltaY: number, deltaMode: 0x00 | 0x01 | 0x02): boolean;
539
+ startPinchZoom(touch1ClientPos: Point, touch2ClientPos: Point): void;
540
+ pinchZoom(touch1ClientPos: Point, touch2ClientPos: Point): void;
541
+ endPinchZoom(): void;
542
+ touchDownHandlerClient(clientPoint: Point, eventFromPlayback?: boolean): boolean;
543
+ touchDownHandler(glPoint: Point, eventFromPlayback?: boolean, autoEvent?: boolean): boolean;
544
+ selectElement(element: string | FigureElement, glPoint: Point, autoEvent?: boolean): void;
545
+ flushMoveBuffer(): void;
546
+ touchUpHandler(autoEvent?: boolean, fromGesture?: boolean): void;
547
+ setCursor(p: Point, animateNextFrame?: boolean): void;
548
+ setCursorGLPoint(p: Point, animateNextFrame?: boolean): void;
549
+ touchFreeHandler(clientPoint: Point): void;
550
+ rotateElement(element: FigureElement, previousGLPoint: Point, currentGLPoint: Point): void;
551
+ translateElement(element: FigureElement, previousGLPoint: Point, currentGLPoint: Point): void;
552
+ scaleElement(element: FigureElement, previousGLPoint: Point, currentGLPoint: Point, type?: 'x' | 'y' | 'z' | ''): void;
553
+ touchMoveHandlerClient(previousClientPoint: Point, currentClientPoint: Point): boolean;
554
+ touchMoveHandler(previousGLPoint: Point, currentGLPoint: Point, fromAutoEvent?: boolean): boolean;
555
+ /**
556
+ * Stop all animations, movement and pulses in figure.
557
+ */
558
+ stop(how?: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete'): void;
559
+ getScene(): Scene;
560
+ setupAnimations(): void;
561
+ createFigureElements(): void;
562
+ setElementsToCollection(collection: FigureElementCollection): void;
563
+ clearContext(canvasIndex?: number): void;
564
+ setupForSelectionDraw(canvasIndex?: number): void;
565
+ getSelectionFromPixel(xPixel: number, yPixel: number, debug?: boolean): FigureElement | null;
566
+ /**
567
+ * Debug - 3D Shapes
568
+ *
569
+ * Show touchable 3D shapes in figure. This will only last for one animation
570
+ * frame, so it will not work if an animation is ongoing.
571
+ *
572
+ * Note, the shown borders will be for the instant this method is called
573
+ * only. If animation is ongoing, the shown borders will not move with the
574
+ * animation. To update the borders, call this method again.
575
+ */
576
+ showTouchable(): void;
577
+ /**
578
+ * Debug - 2D Shapes
579
+ *
580
+ * Show the touchBorders of selected elements in the figure or all
581
+ * elements in the figure.
582
+ *
583
+ * Note, the shown borders will be for the instant this method is called
584
+ * only. If animation is ongoing, the shown borders will not move with the
585
+ * animation. To update the borders, call this method again.
586
+ *
587
+ * @param {TypeElementPath | null | 'touchable'} element use `null` for all
588
+ * elements, `touchable` for all touchable elements or define specific
589
+ * elements to show (`'touchable'`)
590
+ * @param {Array<TypeColor>} colors array of colors to cycle through for each
591
+ * shape ([blue, cyan, purple, green, red, yellow, black])
592
+ */
593
+ showTouchBorders(element?: TypeElementPath | null | 'touchable', colors?: Array<TypeColor>): void;
594
+ /**
595
+ * Debug - 2D Shapes
596
+ *
597
+ * Show the borders or touchBorders of selected elements in the figure or all
598
+ * elements in the figure.
599
+ *
600
+ * @param {'border' | 'touchBorder'} border (`'border'`)
601
+ * @param {TypeElementPath | null | 'touchable'} element use `null` for all
602
+ * elements, `touchable` for all touchable elements or define specific
603
+ * elements to show (`null`)
604
+ * @param {Array<TypeColor>} colors array of colors to cycle through for each
605
+ * shape ([blue, cyan, purple, green, red, yellow, black])
606
+ */
607
+ showBorders(border?: 'border' | 'touchBorder', element?: TypeElementPath | null | 'touchable', colors?: Array<TypeColor>): void;
608
+ getSelectionFromDraw(glPoint: Point): FigureElement | null;
609
+ drawNow(time?: number): void;
610
+ pause(): void;
611
+ unpause(): void;
612
+ touchDown(figurePosition: TypeParsablePoint, eventFromPlayback?: boolean, autoEvent?: boolean): void;
613
+ touchUp(autoEvent?: boolean): void;
614
+ touchMove(figurePosition: TypeParsablePoint, autoEvent?: boolean): void;
615
+ clearDrawTimeout(): void;
616
+ draw(nowIn: number, canvasIndex?: number): void;
617
+ centerDrawingLens(fromTimeOut?: boolean): void;
618
+ setDrawTimeout(timerDurationIn?: number): void;
619
+ focusLost(): void;
620
+ focusGained(): void;
621
+ setupDraw(time?: number): void;
622
+ /**
623
+ * Force figure to draw on next available animation frame.
624
+ */
625
+ animateNextFrame(draw?: boolean, fromWhere?: string): void;
626
+ /**
627
+ * Check if any element in the figure is animating.
628
+ * @return {boolean}
629
+ */
630
+ isAnimating(): boolean;
631
+ clientToPixel(clientLocation: Point): Point;
632
+ clientsToPixel(clientLocations: Array<Point>): Array<Point>;
633
+ pixelToClient(pixelLocation: Point): Point;
634
+ debugShowTouchBorders(elements: TypeElementPath, lineOptions?: OBJ_Polyline, startIndex?: number): void;
635
+ /**
636
+ * Sets manual frames.
637
+ *
638
+ * Normally, when a browser is ready to refresh the screen it will call
639
+ * FigureOne to do a draw. The time between frames is not fixed and depends on
640
+ * a number of factors. This is the most performant way to handle drawing.
641
+ *
642
+ * However, when debugging it can be useful to manually trigger a draw frame
643
+ * with a defined delta time from the last frame.
644
+ *
645
+ * This method turns on manual frames. Use `frame` to trigger a draw.
646
+ */
647
+ setManualFrames(): void;
648
+ /**
649
+ * End manual frames. Reverts drawing to when browser reqeusts it.
650
+ */
651
+ endManualFrames(): void;
652
+ /**
653
+ * Manually trigger a draw frame with a specified time step (in seconds) from
654
+ * the last draw frame. Can only be used when `setManualFrames()` has been
655
+ * called.
656
+ *
657
+ * @param {number} timeStep in seconds
658
+ */
659
+ frame(timeStep: number): void;
660
+ /**
661
+ * Add a frame rate annotation to the figure.
662
+ *
663
+ * Each time the browser requests FigureOne to paint the screen, FigureOne
664
+ * performs two main tasks:
665
+ * - setup the figure for a draw (setupDraw) - all visible figure elements
666
+ * are iterated through and if they are animating or moving then their next
667
+ * animation or movement frame is calculated
668
+ * - draw the figure elements (draw)
669
+ *
670
+ * Frame rate is determined by FigureOne's total frame processing time
671
+ * (setupDraw time + draw time), and how frequently a browser requests
672
+ * FigureOne to draw a frame.
673
+ *
674
+ * The frame rate will not be faster than the browser wants, but it can be
675
+ * slower if the total frame processing time is too long.
676
+ *
677
+ * The frame rate and time durations are reported as both an average, and
678
+ * worst case (max). The averaging is done over `numFrames` number of frames.
679
+ *
680
+ * The screen output is then:
681
+ * - Ave: F fsp, T ms (S, D)
682
+ * - Max: F fsp, T ms (S, D)
683
+ *
684
+ * Where:
685
+ * - F: Frames per second
686
+ * - T: Total frame processing time
687
+ * - S: setupDraw processing time
688
+ * - D: draw processing time
689
+ *
690
+ * Note: FigureOne only requests animation frame notifications from the
691
+ * browser when an element is animating or moving. If everything is still,
692
+ * then the frame rate will be 0.
693
+ */
694
+ addFrameRate(numFrames?: number, options?: OBJ_FormattedText): any;
695
+ addZoomPanControl(options: {
696
+ zoom?: {
697
+ min?: number | null;
698
+ max?: number | null;
699
+ sensitivity?: number;
700
+ };
701
+ pan?: {
702
+ bounds?: {
703
+ left?: number | null;
704
+ bottom?: number | null;
705
+ right?: number | null;
706
+ top?: number | null;
707
+ };
708
+ };
709
+ }): void;
710
+ }
711
+ export default Figure;