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,984 @@
1
+ import { Point, Transform } from '../../tools/g2';
2
+ import { FigureElementPrimitive, FigureElementCollection, FigureElement } from '../Element';
3
+ import { FigureFont } from '../DrawingObjects/TextObject/TextObject';
4
+ import type { ElementInterface } from './Elements/Element';
5
+ import EquationForm from './EquationForm';
6
+ import type { TypeHAlign, TypeVAlign } from './EquationForm';
7
+ import EquationSymbols from './EquationSymbols';
8
+ import { EquationFunctions } from './EquationFunctions';
9
+ import type { TypeEquationPhrase } from './EquationFunctions';
10
+ import type { TypeColor, OBJ_Font } from '../../tools/types';
11
+ import type { TypeParsablePoint, TypeBorder, TypeParsableBuffer } from '../../tools/g2';
12
+ import type { OBJ_TriggerAnimationStep } from '../Animation/Animation';
13
+ import { AnimationManager, TriggerAnimationStep } from '../Animation/Animation';
14
+ import type { EQN_VinculumSymbol, EQN_BoxSymbol, EQN_ArrowSymbol, EQN_SumSymbol, EQN_ProdSymbol, EQN_IntegralSymbol, EQN_StrikeSymbol, EQN_BracketSymbol, EQN_AngleBracketSymbol, EQN_BraceSymbol, EQN_BarSymbol, EQN_SquareBracketSymbol, EQN_RadicalSymbol, EQN_LineSymbol } from './EquationSymbols';
15
+ import type { OBJ_FigureForElement } from '../Figure';
16
+ import type { TypeText } from '../FigurePrimitives/FigurePrimitiveTypes';
17
+ /**
18
+ * Object that defines new text for a selection of equation elements.
19
+ *
20
+ * Each key in the object is the name of the equation element whose text is to
21
+ * be updated.
22
+ *
23
+ * @property {string | FigureElement} [_elementName]
24
+ * @interface
25
+ * @group Misc Equation
26
+ */
27
+ export type EQN_UpdateElementText = {
28
+ [elementName: string]: string | FigureElement;
29
+ };
30
+ /**
31
+ * Object where keys are property names of a {@link FigureElement} and values
32
+ * are the values to set the properties to.
33
+ *
34
+ * @property {any} [_propertyName]
35
+ * @interface
36
+ * @group Misc Figure Element
37
+ */
38
+ export type OBJ_ElementPropertyMod = {
39
+ [propertyName: string]: any;
40
+ };
41
+ /**
42
+ * Object where keys are equation element names, and values are objects
43
+ * describing which element properties to modify after creation.
44
+ *
45
+ * @property {OBJ_ElementPropertyMod} [_elementName]
46
+ * @interface
47
+ * @group Misc Figure Element
48
+ */
49
+ export type OBJ_ElementMods = {
50
+ [elementName: string]: OBJ_ElementPropertyMod;
51
+ };
52
+ /**
53
+ * Definition of a text or equation element.
54
+ *
55
+ * The properties 'color', 'isTouchable', 'onClick' and `touchBorder`
56
+ * modify the corresponding properties on the {@link FigureElementPrimitive}
57
+ * itself, and so could equally be set in `mods`. They are provided in the
58
+ * root object for convenience as they are commonly used.
59
+ *
60
+ * @property {string} [text] - Text element only
61
+ * @property {OBJ_Font} [font] - Text element only
62
+ * @property {'italic' | 'normal'} [style] - Text element only
63
+ * @property {object} [mods] - Properties to set on instantiated element
64
+ * @property {TypeColor} [color] - Color to set the element
65
+ * @property {boolean} [isTouchable] - make the element touchable
66
+ * @property {() => void | 'string' | null} [onClick] - called when touched
67
+ * @property {TypeBorder | 'border' | number | 'rect' | 'draw' | 'buffer'} [touchBorder]
68
+ * set the element's touch border
69
+ * @property {OBJ_ElementMods} [mods]
70
+ * @interface
71
+ * @group Equations
72
+ */
73
+ export type EQN_TextElement = string | {
74
+ text?: string;
75
+ font?: OBJ_Font;
76
+ style?: 'italic' | 'normal' | null;
77
+ weight?: 'normal' | 'bold' | 'lighter' | 'bolder' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
78
+ size?: number;
79
+ color?: TypeColor;
80
+ isTouchable?: boolean;
81
+ onClick?: (() => void) | 'string' | null;
82
+ touchBorder?: TypeBorder | 'border' | number | 'rect' | 'draw' | 'buffer';
83
+ mods?: OBJ_ElementMods;
84
+ } | FigureElementPrimitive | FigureElementCollection;
85
+ /**
86
+ * An equation element can be any of the below. If `string`, then a
87
+ * {@link EQN_TextElement} will be used where the `text` property is the
88
+ * `string`.
89
+ *
90
+ * - `string`
91
+ * - {@link FigureElementPrimitive}
92
+ * - {@link FigureElementCollection}
93
+ * - {@link EQN_TextElement}
94
+ * - {@link EQN_VinculumSymbol}
95
+ * - {@link EQN_BoxSymbol}
96
+ * - {@link EQN_ArrowSymbol}
97
+ * - {@link EQN_SumSymbol}
98
+ * - {@link EQN_ProdSymbol}
99
+ * - {@link EQN_IntegralSymbol}
100
+ * - {@link EQN_StrikeSymbol}
101
+ * - {@link EQN_BracketSymbol}
102
+ * - {@link EQN_AngleBracketSymbol}
103
+ * - {@link EQN_BraceSymbol}
104
+ * - {@link EQN_BarSymbol}
105
+ * - {@link EQN_SquareBracketSymbol}
106
+ * - {@link EQN_LineSymbol}
107
+ * - {@link EQN_RadicalSymbol}
108
+ * @group Equations
109
+ */
110
+ export type TypeEquationElement = string | FigureElementPrimitive | FigureElementCollection | EQN_TextElement | EQN_VinculumSymbol | EQN_BoxSymbol | EQN_ArrowSymbol | EQN_SumSymbol | EQN_ProdSymbol | EQN_IntegralSymbol | EQN_StrikeSymbol | EQN_BracketSymbol | EQN_AngleBracketSymbol | EQN_BraceSymbol | EQN_BarSymbol | EQN_SquareBracketSymbol | EQN_LineSymbol | EQN_RadicalSymbol;
111
+ /**
112
+ * Object where keys are element names, and values are the element definitions
113
+ *
114
+ * @see {@link Equation}
115
+ *
116
+ * @property {TypeEquationElement} [_elementName]
117
+ * @interface
118
+ * @group Equations
119
+ */
120
+ export type EQN_EquationElements = {
121
+ [elementName: string]: TypeEquationElement;
122
+ };
123
+ /**
124
+ * Form alignment object definition.
125
+ *
126
+ * ![](./apiassets/eqn_formalignment_1.png)
127
+ *
128
+ * ![](./apiassets/eqn_formalignment_2.png)
129
+ *
130
+ * ![](./apiassets/eqn_formalignment_3.png)
131
+ *
132
+ * ![](./apiassets/eqn_formalignment_4.png)
133
+ *
134
+ * Each equation form is positioned within the {@link Equation}
135
+ * {@link FigureElementCollection} draw space (0, 0) point. This object
136
+ * defines how the form is aligned with this (0, 0) point.
137
+ *
138
+ * Using the `fixTo` property forms can either be aligned relative to the
139
+ * bounds of the form itself, or to an element within the form, or to a
140
+ * position other than the (0, 0) in in the equation's collection draw space.
141
+ *
142
+ * If `fixTo` is an element in the equation:
143
+ * - the `fixTo` element is positioned at (0, 0), and all other elements
144
+ * repositioned relative to that.
145
+ * - The equation collection setPosition (or translation transform) can
146
+ * then be used to position the equation in the figure (or relative
147
+ * collection space)
148
+ * - if `xAlign` is:
149
+ * - `'center'`: the `fixTo` element is centered in x around (0, 0)
150
+ * - `'right'`: the `fixTo` element right most point is at x = 0
151
+ * - `'left'`: default - the `fixTo` element x position at 0
152
+ * - if `yAlign` is:
153
+ * - `'middle'`: the `fixTo` element is centered in y around (0, 0)
154
+ * - `'bottom'`: the `fixTo` element bottom most point is at y = 0
155
+ * - `'top'`: the `fixTo` element top most point is at y = 0
156
+ * - `'baseline'`: default - the `fixTo` element y position at 0
157
+ *
158
+ * If `fixTo` is a Point, the equation is positioned at that point in the
159
+ * equation's draw space.
160
+ * - xAlign:
161
+ * - `'left'`: The equation's left most element's left most point is at
162
+ * Point.x
163
+ * - `'right'`: The equation's right most element's right most point is at
164
+ * Point.x
165
+ * - `'center'`: The equation is centered horizontally around Point.x
166
+ * - `yAlign`:
167
+ * - `'baseline'`: The equation's baseline is at Point.y
168
+ * - `'top'`: The equation's top most element's top most point is at Point.y
169
+ * - `'bottom'`: The equation's top most element's top most point is at
170
+ * Point.y
171
+ * - `'middle'`: The equation is centered vertically around Point.y
172
+ *
173
+ * @property {FigureElement | TypeParsablePoint | string } [fixTo] (`[0, 0]`)
174
+ * @property {TypeHAlign} [xAlign] (`'left'`)
175
+ * @property {TypeVAlign} [yAlign] (`'baseline'`)
176
+ *
177
+ * @see To test examples, append them to the
178
+ * <a href="#drawing-boilerplate">boilerplate</a>
179
+ *
180
+ * @example
181
+ * // Note - the points are drawn in the figure's draw space, but as the
182
+ * // equation collection is at (0, 0) and it has not scaling applied, then
183
+ * // the equation's draw space is the same as the figure's draw space.
184
+ *
185
+ * // Draw (0, 0) point in equation collection
186
+ * figure.add({
187
+ * make: 'polygon', options: { radius: 0.01, color: [0, 0, 1, 1], sides: 9 },
188
+ * });
189
+ * // Default alignment is left, baseline
190
+ * figure.add([
191
+ * {
192
+ * make: 'equation',
193
+ * forms: { 0: ['a', '_ = ', 'bg'] },
194
+ * },
195
+ * ]);
196
+ *
197
+ * @example
198
+ * // Draw (0, 0) point in equation collection
199
+ * figure.add({
200
+ * make: 'polygon', options: { radius: 0.01, color: [0, 0, 1, 1], sides: 9 },
201
+ * });
202
+ * // Align with right, middle
203
+ * figure.add([
204
+ * {
205
+ * make: 'equation',
206
+ * forms: { 0: ['a', '_ = ', 'bg'] },
207
+ * formDefaults: {
208
+ * alignment: {
209
+ * xAlign: 'right',
210
+ * yAlign: 'middle',
211
+ * },
212
+ * },
213
+ * },
214
+ * ]);
215
+ *
216
+ * @example
217
+ * // Draw (0, 0) point in equation collection
218
+ * figure.add({
219
+ * make: 'polygon', options: { radius: 0.01, color: [0, 0, 1, 1], sides: 9 },
220
+ * });
221
+ * // Align with center of equals sign
222
+ * figure.add([
223
+ * {
224
+ * make: 'equation',
225
+ * forms: { 0: ['a', '_ = ', 'bg'] },
226
+ * formDefaults: {
227
+ * alignment: {
228
+ * fixTo: '_ = ',
229
+ * xAlign: 'center',
230
+ * yAlign: 'baseline',
231
+ * },
232
+ * },
233
+ * },
234
+ * ]);
235
+ *
236
+ * @example
237
+ * // Draw (0, 0) and (0.2, 0.1) points
238
+ * figure.add([
239
+ * {
240
+ * make: 'polygon',
241
+ * options: { radius: 0.01, color: [0, 0, 1, 1], sides: 9 }
242
+ * },
243
+ * {
244
+ * make: 'polygon',
245
+ * options: {
246
+ * radius: 0.01, color: [0, 0.8, 0, 1], sides: 9, position: [0.2, 0.1],
247
+ * },
248
+ * },
249
+ * ]);
250
+ * // Align with point (0.2, 0.1) in the equation collection
251
+ * figure.add([
252
+ * {
253
+ * make: 'equation',
254
+ * forms: { 0: ['a', '_ = ', 'bg'] },
255
+ * formDefaults: {
256
+ * alignment: {
257
+ * fixTo: [0.2, 0.1],
258
+ * xAlign: 'right',
259
+ * yAlign: 'baseline',
260
+ * },
261
+ * },
262
+ * },
263
+ * ]);
264
+ * @interface
265
+ * @group Equations
266
+ */
267
+ type EQN_FormAlignment = {
268
+ fixTo: FigureElement | TypeParsablePoint | string;
269
+ xAlign: TypeHAlign;
270
+ yAlign: TypeVAlign;
271
+ };
272
+ /**
273
+ * Form translation properties
274
+ *
275
+ * @property {'curved' | 'linear'} style - element should move in a straight
276
+ * line, or through a curve. Default: `"linear"`
277
+ * @property {'up' | 'down'} [direction] - curve only - element should move
278
+ * through an up or down curve
279
+ * @property {number} [mag] - the magnitude of the curve
280
+ * @interface
281
+ * @group Equations
282
+ */
283
+ type EQN_TranslationStyle = {
284
+ style: 'curved' | 'linear';
285
+ direction?: 'up' | 'down';
286
+ mag: number;
287
+ };
288
+ /**
289
+ * Object where keys are element names and values are tranlation definition
290
+ * objects.
291
+ *
292
+ * `[elementName: string]: TypeEquationElement`
293
+ *
294
+ * @see {@link EQN_TranslationStyle}, {@link EQN_FormObjectDefinition}, {@link EQN_FromForm}.
295
+ *
296
+ * @property {EQN_TranslationStyle} [_elementName]
297
+ * @interface
298
+ * @group Misc Equation
299
+ */
300
+ export type EQN_TranslationStyles = {
301
+ [elementName: string]: EQN_TranslationStyle;
302
+ };
303
+ /**
304
+ * From form options object.
305
+ *
306
+ * Any defined properties will override the corrsponding properties of the form
307
+ * if it being animated to from a specific form.
308
+ *
309
+ * @property {?number} [duration] duration if animating to this form, use
310
+ * `null` for velocity based duration
311
+ * @property {EQN_TranslationStyle} [translation] translation style
312
+ * when animating to this form
313
+ * @property {string | (() => void)} [onTransition] called at the start of
314
+ * animating to this form, or when `showForm` is used.
315
+ * @property {string | (() => void)} [onShow] called after animation is finished
316
+ * or when `showForm` is used
317
+ * @property {OBJ_ElementMods} [elementMods] properties to set in the equation element
318
+ * (@FigureElementPrimitive) when this form is shown
319
+ * @interface
320
+ * @group Equations
321
+ */
322
+ export type EQN_FromForm = {
323
+ onTransition?: null | string | (() => void);
324
+ onShow?: null | string | (() => void);
325
+ duration?: number;
326
+ translation?: {
327
+ [elementName: string]: EQN_TranslationStyle;
328
+ };
329
+ elementMods?: OBJ_ElementMods;
330
+ };
331
+ /**
332
+ * Equation form FromForm definition.
333
+ *
334
+ * When animating from a specific form, it can be useful to customize some of
335
+ * the form properties specific to that transition.
336
+ *
337
+ * To do so, use this options object where each key is the specific form from
338
+ * which the equation is animating from, and the value is the specific
339
+ * properties.
340
+ *
341
+ * @property {EQN_FromForm} [_formName]
342
+ *
343
+ * @see {@link EQN_FromForm}, {@link EQN_FormObjectDefinition}
344
+ * @interface
345
+ * @group Equations
346
+ */
347
+ export type EQN_FromForms = {
348
+ [formName: string]: EQN_FromForm;
349
+ };
350
+ /**
351
+ * In mathematics, an equation form is a specific arrangement of an equation's
352
+ * terms and operators. Different forms will have different
353
+ * arrangements, that can be achieved by performing a series of operations to
354
+ * both sides of the equation.
355
+ *
356
+ * For instance, the equation:
357
+ *
358
+ * a + b = c
359
+ *
360
+ * can be rearranged to a different form:
361
+ *
362
+ * a = c - b
363
+ *
364
+ * From a FigureOne figure's perspective, a form is a specific layout of
365
+ * equation elements.
366
+ *
367
+ * This object defines a how the elements are laid out, what properties the
368
+ * elements have, and some animation properties for when animating to this form.
369
+ *
370
+ * @see {@link Equation}
371
+ *
372
+ * @property {TypeEquationPhrase} content The equation phrase of the form
373
+ * defines how the elements are laid out
374
+ * @property {number} [scale] scaling factor for this form
375
+ * @property {EQN_FormAlignment} [alignment] how the equation's position
376
+ * is aligned with this form
377
+ * @property {string} [description] description of this form
378
+ * @property {{}} [modifiers] description modifiers
379
+ * @property {?number} [duration] duration if animating to this form, use
380
+ * `null` for velocity based duration
381
+ * @property {EQN_TranslationStyles} [translation] translation style
382
+ * when animating to this form
383
+ * @property {string | (() => void)} [onTransition] called at the start of
384
+ * animating to this form, or when `showForm` is used.
385
+ * @property {string | (() => void)} [onShow] called after animation is finished
386
+ * or when `showForm` is used
387
+ * @property {OBJ_ElementMods} [elementMods] properties to set in the equation element
388
+ * (@FigureElementPrimitive) when this form is shown
389
+ * @property {EQN_FromForms} [fromForm] override `duration`, `translation`
390
+ * `onTransition` and/or `onShow` with this if coming from specific forms
391
+ * @property {boolean} [ignoreColor] when `false`, color will be set
392
+ * automatically in the equation based on EQN_Color equation functions. In such
393
+ * cases, colors that are set external to the equation will be overridden. Use
394
+ * `true` to allow setting of colors externally only. (`false`)
395
+ *
396
+ * @example
397
+ * // Simple form definition of two different forms of the same equation and one
398
+ * // of the elements is colored blue in one form and red in the other
399
+ * figure.add({
400
+ * name: 'eqn',
401
+ * make: 'equation',
402
+ * elements: { equals: ' = ', plus: ' + ', minus: ' \u2212 ' },
403
+ * forms: {
404
+ * form1: {
405
+ * content: ['a', 'plus', 'b', 'equals', 'c'],
406
+ * elementMods: {
407
+ * a: { color: [0, 0, 1, 1] },
408
+ * },
409
+ * },
410
+ * form2: {
411
+ * content: ['a', 'equals', 'c', 'minus', 'b'],
412
+ * elementMods: {
413
+ * a: { color: [1, 0, 0, 1] },
414
+ * },
415
+ * },
416
+ * },
417
+ * });
418
+ *
419
+ * @example
420
+ * // Example showing all form options
421
+ * figure.add({
422
+ * name: 'eqn',
423
+ * make: 'equation',
424
+ * forms: {
425
+ * form1: {
426
+ * content: ['a', 'b', 'c'],
427
+ * subForm: 'deg',
428
+ * scale: 1.2,
429
+ * alignment: {
430
+ * fixTo: 'b',
431
+ * xAlign: 'center',
432
+ * yAlign: 'bottom',
433
+ * },
434
+ * description: '|Form| 1 |description|',
435
+ * modifiers: {
436
+ * Form: { font: { color: [0, 0, 1, 0] } },
437
+ * },
438
+ * elementMods: {
439
+ * a: {
440
+ * color: [0, 0, 1, 1],
441
+ * isTouchable: true,
442
+ * },
443
+ * },
444
+ * duration: 1,
445
+ * translation: {
446
+ * a: {
447
+ * style: 'curved',
448
+ * direction: 'up',
449
+ * mag: 0.95,
450
+ * },
451
+ * b: ['curved', 'down', 0.45],
452
+ * },
453
+ * fromPrev: {
454
+ * duration: null,
455
+ * translation: {
456
+ * a: ['curved', 'down', 0.2],
457
+ * b: ['curved', 'down', 0.2],
458
+ * },
459
+ * },
460
+ * fromNext: {
461
+ * duration: 2,
462
+ * translation: {
463
+ * a: ['curved', 'down', 0.2],
464
+ * b: ['curved', 'down', 0.2],
465
+ * },
466
+ * },
467
+ * },
468
+ * },
469
+ * });
470
+ * @interface
471
+ * @group Equations
472
+ */
473
+ type EQN_FormObjectDefinition = {
474
+ content: TypeEquationPhrase;
475
+ scale?: number;
476
+ alignment?: EQN_FormAlignment;
477
+ description?: string;
478
+ modifiers?: {};
479
+ duration?: number | null;
480
+ translation?: EQN_TranslationStyles;
481
+ onShow?: string | (() => void);
482
+ onTransition?: string | (() => void);
483
+ elementMods?: OBJ_ElementMods;
484
+ fromForm: EQN_FromForms;
485
+ ignoreColor?: boolean;
486
+ };
487
+ /**
488
+ * A form definition can either be:
489
+ *
490
+ * * an equation form object {@link EQN_FormObjectDefinition}
491
+ * * an equation phrase {@link TypeEquationPhrase}
492
+ *
493
+ * @type {TypeEquationPhrase | EQN_FormObjectDefinition}
494
+ * @group Equations
495
+ */
496
+ type TypeEquationForm = TypeEquationPhrase | EQN_FormObjectDefinition;
497
+ /**
498
+ * An object of equation forms where each key is the form name and each value
499
+ * is a form defintion {@link TypeEquationForm}
500
+ *
501
+ * @property {TypeEquationForm} [_formName]
502
+ * @interface
503
+ * @group Equations
504
+ */
505
+ export type EQN_Forms = {
506
+ [formName: string]: TypeEquationForm;
507
+ };
508
+ /**
509
+ * When an equation form series is restarted, or cycled back to the first form
510
+ * in the series, then two special animations can be defined with this object:
511
+ * * `moveFrom`: the equation will move from a location (usually another equation of the same form)
512
+ * * `pulse`: An element will be pulsed when the animation is finished.
513
+ *
514
+ * The default values in the pulse object are are:
515
+ * * `duration`: 1s
516
+ * * `scale`: 1.1
517
+ * @interface
518
+ * @group Equations
519
+ */
520
+ type EQN_FormRestart = {
521
+ moveFrom?: Point | FigureElementCollection | null;
522
+ pulse?: {
523
+ duration?: number;
524
+ scale?: number;
525
+ element?: FigureElement | null;
526
+ };
527
+ };
528
+ /**
529
+ * {@link NextFormAnimationStep} options object.
530
+ *
531
+ * `OBJ_TriggerAnimationStep & EQN_EquationGoToForm`
532
+ *
533
+ * Duration will be automatically calculated (unless duration is set to 0).
534
+ * To specify it exactly, the `duration`, `dissolveOutTime`, `dissolveInTime`
535
+ * and `blankTime` must all be specified (or at least the ones that will be used
536
+ * in the form change).
537
+ *
538
+ * @extends OBJ_TriggerAnimationStep
539
+ * @extends EQN_EquationGoToForm
540
+ *
541
+ * @see {@link Equation}, {@link NextFormAnimationStep}
542
+ * @interface
543
+ * @group Misc Equation
544
+ */
545
+ export type OBJ_NextFormAnimationStep = {} & OBJ_TriggerAnimationStep;
546
+ /**
547
+ * {@link GoToFormAnimationStep} options object.
548
+ *
549
+ * `OBJ_TriggerAnimationStep & EQN_EquationGoToForm & { start?: 'string', target?: 'string'}`
550
+ *
551
+ * Duration will be automatically calculated (unless duration is set to 0).
552
+ * To specify it exactly, the `duration`, `dissolveOutTime`, `dissolveInTime`
553
+ * and `blankTime` must all be specified (or at least the ones that will be used
554
+ * in the form change).
555
+ *
556
+ * The `form` property of EQN_EquationGoToForm is not used. Use `target`
557
+ * instead.
558
+ *
559
+ * @extends OBJ_TriggerAnimationStep
560
+ * @extends EQN_EquationGoToForm
561
+ *
562
+ * @property {string} [start] form to start from. If undefined, then current
563
+ * form will be used
564
+ * @property {string} [target] form to go to. If undefined, then current
565
+ * form will be used
566
+ *
567
+ * @see {@link Equation}
568
+ * @interface
569
+ * @group Misc Equation
570
+ */
571
+ export type OBJ_GoToFormAnimationStep = {
572
+ start?: string;
573
+ target?: string;
574
+ } & OBJ_TriggerAnimationStep;
575
+ /**
576
+ * Default form values applied to all forms
577
+ *
578
+ * @see {@link EQN_FormObjectDefinition}
579
+ * @interface
580
+ * @group Equations
581
+ */
582
+ export type EQN_FormDefaults = {
583
+ alignment?: EQN_FormAlignment;
584
+ elementMods?: OBJ_ElementMods;
585
+ duration?: number;
586
+ translation?: EQN_TranslationStyle;
587
+ onShow?: null | string | (() => void);
588
+ onTransition?: null | string | (() => void);
589
+ layout?: 'lazy' | 'init' | 'always';
590
+ ignoreColor?: boolean;
591
+ };
592
+ /**
593
+ * Options objects to construct an {@link Equation} class.
594
+ *
595
+ * All properties are optional.
596
+ *
597
+ * @property {TypeColor} [color] default equation color
598
+ * @property {TypeColor} [dimColor] default equation dim color
599
+ * @property {OBJ_Font} [font] default {@link FigureFont} for math elements in
600
+ * the equation
601
+ * @property {OBJ_Font} [textFont] default {@link FigureFont} for text elements
602
+ * in the equation (defaults to `font`)
603
+ * @property {number} [scale] equation scale (`0.7`)
604
+ * @property {EQN_EquationElements} [elements] equation element definitions
605
+ * @property {EQN_Forms} [forms] form definitions
606
+ * @property {string} [initialForm] form to show when first added to a figure
607
+ * @property {EQN_FormDefaults} [formDefaults] default form options applied to
608
+ * all forms
609
+ * @property {Array<string> | Object.<Array<string>>} [formSeries] an object
610
+ * with each key being a form series name, and each value an array for form
611
+ * names. If defined as an array, then a form series object is created where
612
+ * the form series name is 'base'. Default: {}
613
+ * @property {string} [defaultFormSeries] If more than one form series is
614
+ * defined, then a default must be chosen to be the first current one. Default:
615
+ * first form defined
616
+ * @property {?EQN_FormRestart} [formRestart] behavior when form transitions
617
+ * from last in form series back to first
618
+ * @property {TypeParsablePoint} [position] position will override first
619
+ * translation element of transform
620
+ * @property {Transform} [transform]
621
+ * @interface
622
+ * @group Equations
623
+ */
624
+ export type EQN_Equation = {
625
+ color?: TypeColor;
626
+ dimColor?: TypeColor;
627
+ font?: OBJ_Font;
628
+ textFont?: OBJ_Font;
629
+ scale?: number;
630
+ elements?: EQN_EquationElements;
631
+ formDefaults: EQN_FormDefaults;
632
+ forms?: EQN_Forms;
633
+ initialForm?: string;
634
+ formSeries?: Array<string> | {};
635
+ defaultFormSeries?: string;
636
+ formRestart?: EQN_FormRestart;
637
+ position?: TypeParsablePoint;
638
+ transform?: Transform;
639
+ };
640
+ /**
641
+ * Options object for {@link Equation#goToForm}.
642
+ *
643
+ * Often, `goToForm` is called to animate from a shown form to a desired form.
644
+ * Therefore there will be some equation elements that:
645
+ * * Are currently shown, but need to be hidden as they are not in the desired form
646
+ * * Are currently shown, are in the desired form, and need to be moved to the
647
+ * correct layout position for the desired form
648
+ * * Are currently hidden and need to be shown in the desired form
649
+ *
650
+ * The order that elements are shown, hidden and moved is defined by the
651
+ * `animate` property:
652
+ * * `'move'`: Dissolve out elements to hide, move existing elements to new,
653
+ * dissolve in elements that need to be shown
654
+ * * `'dissolveInThenMove'`: Dissolve out the elements to hide, dissolve in the
655
+ * elements that need to be shown in the correct locations of the form, then
656
+ * move existing elements to their correct locations
657
+ * * `'dissolve'`: Dissolve out the entire current form, and then dissolve in the entire new form
658
+ * * `'moveFrom'`: Shows the desired form at the position defined in the
659
+ * formRestart property of {@link EQN_Equation}, then moves it to the
660
+ * current location
661
+ * * `'pulse'`: Same as `'dissolve'`, but once finished will pulse the element
662
+ * defined in the pulse object in the formRestart property of {@link EQN_Equation}
663
+ *
664
+ * If a form is already animating, then the `ifAnimating` property will define
665
+ * the behavior of the animation:
666
+ * * `cancelGoTo: true`, `skipToTarget: true`: Current animation will skip to
667
+ * the end, and current goTo call will be cancelled
668
+ * * `cancelGoTo: true`, `skipToTarget: false`: Current animation will stop in
669
+ * its current state, and current goTo call will be cancelled
670
+ * * `cancelGoTo: false`, `skipToTarget: true`: Current animation will skip to
671
+ * the end, and current goTo call will then be executed
672
+ * * `cancelGoTo: false`, `skipToTarget: false`: Current animation will stop in
673
+ * its current state, and current goTo call will be executed
674
+ *
675
+ * @property {string} [name] - form name to goto
676
+ * @property {number} [index] - form index to goto (can be used instead of name)
677
+ * @property {'move' | 'dissolve' | 'moveFrom' | 'pulse' |
678
+ * 'dissolveInThenMove'} [animate] - default: `"dissolve"`
679
+ * @property {number} [delay] - delay before goto start. Default: `0`
680
+ * @property {number} [dissolveOutTime] - Default: 0.4 of duration, or 0.4s if
681
+ * no duration
682
+ * @property {number} [duration] - animation duration. Default: `null`
683
+ * @property {number} [blankTime] - time between dissolve out and dissolve in
684
+ * when animating with `dissolve` or `pulse`. Default: 0.2 of duration, or 0.2s
685
+ * if no duration
686
+ * @property {number} [dissolveInTime] - Default: 0.4 of duration, or 0.4s if
687
+ * no duration
688
+ * @property {boolean} [prioritizeFormDuration] - use duration from the form
689
+ * definition {@link EQN_FormObjectDefinition}. Default: `true`
690
+ * @property {'fromPrev' | 'fromNext'} [fromWhere] - prioritze *fromPrev* or
691
+ * *fromNext* duration from the form definition. {@link EQN_FormObjectDefinition}
692
+ * Default: `null`
693
+ * @property {{cancelGoTo?: boolean, skipToTarget?: boolean}} [ifAnimating] -
694
+ * behavior for if currently animating between forms. Default:
695
+ * `skipToTarget: true`, `cancelGoTo: true`
696
+ * @property {?() => void} [callback] - call when goto finished
697
+ * @interface
698
+ * @group Misc Equation
699
+ */
700
+ type EQN_EquationGoToForm = {
701
+ name?: string;
702
+ index?: number;
703
+ animate?: 'move' | 'dissolve' | 'moveFrom' | 'pulse' | 'dissolveInThenMove';
704
+ delay?: number;
705
+ dissolveOutTime?: number;
706
+ duration?: number | null;
707
+ dissolveInTime?: number;
708
+ blankTime?: number;
709
+ prioritizeFormDuration?: boolean;
710
+ fromWhere?: string | null;
711
+ ifAnimating?: {
712
+ cancelGoTo?: boolean;
713
+ skipToTarget?: boolean;
714
+ };
715
+ callback?: (string | (() => void)) | null;
716
+ };
717
+ /**
718
+ * An Equation is a collection of elements that can be arranged into different
719
+ * forms.
720
+ *
721
+ * `Equation` should be instantiated from an *object definition*, or from
722
+ * the `figure.collections.equation` method.
723
+ *
724
+ * Equation includes two additional animation steps in {@link Equation.animations}:
725
+ * * {@link GoToFormAnimationStep}
726
+ * * {@link NextFormAnimationStep}
727
+ *
728
+ * @extends FigureElementCollection
729
+ *
730
+ * @see To test examples, append them to the
731
+ * <a href="#drawing-boilerplate">boilerplate</a>
732
+ *
733
+ * @param {EQN_Equation} options
734
+ * @example
735
+ * // Create with options definition
736
+ * figure.add({
737
+ * name: 'eqn',
738
+ * make: 'equation',
739
+ * elements: {
740
+ * a: 'a',
741
+ * b: { color: [0, 0, 1, 1] },
742
+ * c: 'c',
743
+ * equals: ' = ',
744
+ * plus: ' + ',
745
+ * },
746
+ * forms: {
747
+ * 1: ['a', 'equals', 'b', 'plus', 'c'],
748
+ * },
749
+ * });
750
+ *
751
+ * @example
752
+ * // Create with methods
753
+ * const eqn = figure.collections.equation();
754
+ * eqn.addElements({
755
+ * a: 'a',
756
+ * b: { color: [0, 0, 1, 1] },
757
+ * c: 'c',
758
+ * equals: ' = ',
759
+ * plus: ' + ',
760
+ * });
761
+ * eqn.addForms({
762
+ * 1: ['a', 'equals', 'b', 'plus', 'c'],
763
+ * });
764
+ * figure.add('eqn', eqn);
765
+ * eqn.showForm('1');
766
+ * @group Equations
767
+ */
768
+ export declare class Equation extends FigureElementCollection {
769
+ /**
770
+ * Equation parameters and functions
771
+ * @property {EquationFunctions} functions - equation functions
772
+ */
773
+ eqn: {
774
+ forms: {
775
+ [formName: string]: EquationForm;
776
+ };
777
+ functions: EquationFunctions;
778
+ symbols: EquationSymbols;
779
+ currentForm: string;
780
+ font: FigureFont;
781
+ textFont: FigureFont;
782
+ scale: number;
783
+ formSeries: {
784
+ [key: string]: Array<string>;
785
+ };
786
+ currentFormSeries: Array<string>;
787
+ currentFormSeriesName: string;
788
+ formDefaults: {
789
+ alignment: {
790
+ fixTo: (FigureElementPrimitive | FigureElementCollection | Point);
791
+ xAlign: TypeHAlign;
792
+ yAlign: TypeVAlign;
793
+ };
794
+ elementMods: OBJ_ElementMods;
795
+ duration?: number;
796
+ translation?: EQN_TranslationStyle;
797
+ onShow?: null | string | (() => void);
798
+ onTransition?: null | string | (() => void);
799
+ layout?: 'always' | 'lazy' | 'init';
800
+ ignoreColor?: boolean;
801
+ };
802
+ isAnimating: boolean;
803
+ descriptionElement: FigureElementPrimitive | null;
804
+ descriptionPosition: Point;
805
+ formRestart: {
806
+ moveFrom?: Point | FigureElementCollection;
807
+ pulse?: {
808
+ duration: number;
809
+ scale: number;
810
+ element: FigureElement;
811
+ };
812
+ } | null | undefined;
813
+ };
814
+ initialForm: string | null;
815
+ defaultTextType: TypeText;
816
+ /**
817
+ * {@link AnimationManager} extended to include additional animation steps
818
+ * specific to equations
819
+ * @property {NextFormAnimationStep} nextForm
820
+ * @property {GoToFormAnimationStep} goToForm
821
+ * @extends AnimationManager
822
+ */
823
+ animations: {
824
+ nextForm: (...opt: Array<any>) => TriggerAnimationStep;
825
+ goToForm: (...opt: Array<any>) => TriggerAnimationStep;
826
+ } & AnimationManager;
827
+ shapes: Record<string, any>;
828
+ /**
829
+ * @hideconstructor
830
+ */
831
+ constructor(shapes: Record<string, any>, options?: EQN_Equation);
832
+ stateSet(): void;
833
+ setFigure(figure: OBJ_FigureForElement, notify?: boolean): void;
834
+ fontUpdated(): void;
835
+ _getStateProperties(options: Record<string, any>): string[];
836
+ _getStatePropertiesMin(): string[];
837
+ /**
838
+ * Set the current form series to 'name'
839
+ */
840
+ setFormSeries(name: string): void;
841
+ /**
842
+ * Get the current form series name
843
+ */
844
+ getFormSeries(): string;
845
+ /**
846
+ * For equation layout. If an equation layout happens before a desired font
847
+ * is fully loaded, then use this method to re-layout the equation when the
848
+ * font is available.
849
+ *
850
+ * Either the current form only, all forms already laid out (set), or all
851
+ * forms of the equation can be re-laid-out.
852
+ *
853
+ * @param {'none' | 'current' | 'all' | 'set' | 'reset'} forms
854
+ * @param {boolean} show true will re-show current form
855
+ */
856
+ layoutForms(forms?: 'none' | 'current' | 'all' | 'set' | 'reset', show?: boolean): void;
857
+ contextLost(): void;
858
+ /**
859
+ * Update text of equation element or elements
860
+ *
861
+ * @param {EQN_UpdateElementText} elements elements to update
862
+ * @param {'all' | 'current' | 'none'} [layoutForms] which forms to re-layout
863
+ * with the updated text
864
+ *
865
+ */
866
+ updateElementText(elements: EQN_UpdateElementText, layoutForms?: 'all' | 'current' | 'none'): void;
867
+ makeTextElem(options: {
868
+ text?: string;
869
+ font?: FigureFont | OBJ_Font;
870
+ style?: 'italic' | 'normal';
871
+ weight?: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
872
+ size?: number;
873
+ family?: string;
874
+ width?: number;
875
+ color?: TypeColor;
876
+ touchBorder?: TypeParsableBuffer | Array<Point>;
877
+ onClick?: (() => void) | 'string' | null;
878
+ isTouchable?: boolean;
879
+ mods?: Record<string, any>;
880
+ }, defaultText?: string): any;
881
+ getTextFromKey(key: string): string;
882
+ getExistingOrAddSymbol(symbol: string | Record<string, any>): any;
883
+ getExistingOrAddSymbolFromKey(key: string, options?: Record<string, any>): any;
884
+ addElementFromKey(key: string, options?: Record<string, any>): any;
885
+ makeSymbolElem(options: any): import("./Symbols/Bracket").default | import("./Symbols/Box").default | import("./Symbols/Sum").default | import("./Symbols/Product").default | import("./Symbols/Integral").default | import("./Symbols/Vinculum").default | import("./Symbols/Strike").default | import("./Symbols/Radical").default | import("./Symbols/Division").default | import("./Symbols/Line").default | null;
886
+ /**
887
+ * Add elements to equation.
888
+ */
889
+ addElements(elems: EQN_EquationElements): void;
890
+ addDescriptionElement(descriptionElement?: FigureElementPrimitive | null, descriptionPosition?: Point): void;
891
+ setPosition(pointOrX: TypeParsablePoint | number, y?: number): void;
892
+ addPhrases(phrases: {
893
+ [phraseName: string]: TypeEquationPhrase;
894
+ }): void;
895
+ /**
896
+ * Add forms to equation.
897
+ */
898
+ addForms(forms: EQN_Forms): void;
899
+ checkFixTo(fixTo: FigureElementCollection | FigureElementPrimitive | string | Point | null, formElements: Array<FigureElementPrimitive | FigureElementCollection>): FigureElementPrimitive | FigureElementCollection | Point;
900
+ createForm(elements?: any): EquationForm;
901
+ /**
902
+ * Return all the elements that are used in a form.
903
+ * @param {string} form
904
+ * @return {Array<FigureElement>}
905
+ */
906
+ getFormElements(form: string, includeHidden?: boolean): (FigureElementCollection | FigureElementPrimitive | ElementInterface)[];
907
+ /**
908
+ * Return all the elements that are used in an equation phrase.
909
+ * @param {TypeEquationPhrase} phrase
910
+ * @return {Array<FigureElement>}
911
+ */
912
+ getPhraseElements(phrase: string | Array<string>): any[];
913
+ getUnusedElements(): string[];
914
+ stopEquationAnimating(how?: 'complete' | 'cancel'): void;
915
+ addForm(name: string, content: Array<ElementInterface>, options?: {
916
+ scale?: number;
917
+ alignment?: EQN_FormAlignment;
918
+ description?: string;
919
+ modifiers?: Record<string, any>;
920
+ elementMods?: {
921
+ [elementName: string]: Record<string, any>;
922
+ };
923
+ onTransition?: null | string | (() => void);
924
+ onShow?: null | string | (() => void);
925
+ duration?: number;
926
+ translation?: {
927
+ [elementName: string]: EQN_TranslationStyle;
928
+ };
929
+ fromForm: {
930
+ [formName: string]: {
931
+ onTransition?: null | string | (() => void);
932
+ onShow?: null | string | (() => void);
933
+ duration?: number;
934
+ translation?: {
935
+ [elementName: string]: EQN_TranslationStyle;
936
+ };
937
+ elementMods?: {
938
+ [elementName: string]: Record<string, any>;
939
+ };
940
+ };
941
+ };
942
+ }): void;
943
+ /**
944
+ * Get the current equation form
945
+ */
946
+ getCurrentForm(): EquationForm | null;
947
+ render(animationStop?: boolean): void;
948
+ /**
949
+ * Set current equation form - Note, this does not show the form.
950
+ */
951
+ setCurrentForm(formOrName: EquationForm | string): void;
952
+ /**
953
+ * Show equation form
954
+ */
955
+ showForm(formOrName?: EquationForm | string, animationStop?: boolean): void;
956
+ showAll(): void;
957
+ cleanup(): void;
958
+ cleanupForms(): void;
959
+ /**
960
+ * Get an equation form object from a form name
961
+ */
962
+ getForm(formOrName: string | EquationForm): null | EquationForm;
963
+ /**
964
+ * Start an animation to an equation form
965
+ */
966
+ goToForm(optionsIn?: EQN_EquationGoToForm): void;
967
+ getFormIndex(formToGet?: null | EquationForm | string): number;
968
+ /**
969
+ * Animate to previous form in the current form series
970
+ */
971
+ prevForm(durationOrOptions?: number | null | EQN_EquationGoToForm, delay?: number): void;
972
+ /**
973
+ * Animate to next form in the current form series
974
+ */
975
+ nextForm(durationOrOptions?: number | null | EQN_EquationGoToForm, delay?: number): void;
976
+ /**
977
+ * Start from previous form and animate to current form
978
+ */
979
+ replayCurrentForm(duration: number): void;
980
+ animateToForm(name: string, duration?: number | null, delay?: number, callback?: null | string | (() => void)): void;
981
+ changeDescription(formOrName: EquationForm | string, description?: string, modifiers?: Record<string, any>): void;
982
+ getDescription(formOrName: EquationForm | string): string;
983
+ }
984
+ export {};