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,235 @@
1
+ import { Point } from '../../tools/g2';
2
+ import type { TypeParsableBuffer } from '../../tools/g2';
3
+ import { FigureElementCollection, FigureElementPrimitive } from '../Element';
4
+ import * as animation from '../Animation/Animation';
5
+ import type { OBJ_CustomAnimationStep } from '../Animation/Animation';
6
+ import type { OBJ_LineStyleSimple, OBJ_Texture, OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
7
+ import type { TypeColor, OBJ_CurvedCorner } from '../../tools/types';
8
+ import type { FigureElement } from '../Element';
9
+ import type FigureCollections from './FigureCollections';
10
+ import type CollectionsText from './Text';
11
+ import type { OBJ_FormattedText } from './Text';
12
+ /**
13
+ * Surround animation step.
14
+ *
15
+ * @property {FigureElement} [start] start element to surround (`this`)
16
+ * @property {FigureElement} [target] target element to surround (`this`)
17
+ * @property {TypeParsableBuffer} [space] space between rectangle and element (`0`)
18
+ * @extends OBJ_CustomAnimationStep
19
+ * @interface
20
+ * @group Misc Shapes
21
+ */
22
+ export type OBJ_SurroundAnimationStep = {
23
+ start?: number;
24
+ target?: number;
25
+ } & OBJ_CustomAnimationStep;
26
+ /**
27
+ * Button colors when clicked.
28
+ * @interface
29
+ * @group Misc Shapes
30
+ */
31
+ export type OBJ_ButtonColor = {
32
+ line?: TypeColor;
33
+ fill?: TypeColor;
34
+ label?: TypeColor;
35
+ };
36
+ /**
37
+ * {@link CollectionsRectangle} options object that extends {@link OBJ_Collection}
38
+ * options object (without `parent`).
39
+ *
40
+ * This rectangle is similar to {@link OBJ_Rectangle}, except it can accomodate
41
+ * both a fill and a border or line simultaneously with different colors.
42
+ *
43
+ * @extends OBJ_Collection
44
+ *
45
+ * @property {number} [width] rectangle width
46
+ * @property {number} [height] rectangle height
47
+ * @property {'left' | 'center' | 'right' | number} [xAlign] horiztonal
48
+ * alignment of the rectangle
49
+ * @property {'bottom' | 'middle' | 'top' | number} [yAlign] vertical alignment
50
+ * of the rectangle
51
+ * @property {OBJ_LineStyleSimple} [line] lines style - leave empty if only
52
+ * want fill
53
+ * @property {TypeColor | OBJ_Texture} [fill] fill color or texture
54
+ * @property {OBJ_CurvedCorner} [corner] corner style of rectangle
55
+ * @property {OBJ_TextLines} [label] Rectangle label
56
+ * @property {boolean | TypeColor | OBJ_ButtonColor} [button] `true` to
57
+ * make the rectangle behave like a button when clicked. `TypeColor` to
58
+ * make fill, line and label the same color when clicked or `OBJ_ButtonColor`
59
+ * to specify click colors for each (`false`)
60
+ * @interface
61
+ * @group 2D Shape Collections
62
+ */
63
+ export type COL_Rectangle = {
64
+ width?: number;
65
+ height?: number;
66
+ xAlign?: 'left' | 'center' | 'right' | number;
67
+ yAlign?: 'bottom' | 'middle' | 'top' | number;
68
+ line?: OBJ_LineStyleSimple;
69
+ fill?: TypeColor | OBJ_Texture;
70
+ corner?: OBJ_CurvedCorner;
71
+ label?: OBJ_FormattedText;
72
+ button?: boolean | TypeColor | OBJ_ButtonColor;
73
+ } & OBJ_Collection;
74
+ /**
75
+ * {@link FigureElementCollection} representing a rectangle.
76
+ *
77
+ * ![](./apiassets/advrectangle_ex1.png)
78
+ * ![](./apiassets/advrectangle_ex2.png)
79
+ *
80
+ * <p class="inline_gif"><img src="./apiassets/advrectangle.gif" class="inline_gif_image"></p>
81
+ *
82
+ * <p class="inline_gif"><img src="./apiassets/advrectangle_button.gif" class="inline_gif_image"></p>
83
+ *
84
+ * This object defines a rectangle
85
+ * {@link FigureElementCollection} that may include:
86
+ * - border (line)
87
+ * - fill
88
+ * - label
89
+ * - ability to surround another {@link FigureElement} with some space
90
+ * - button behavior when clicked
91
+ *
92
+ * Surrounding another element can be executed through either the
93
+ * <a href="#collectionsrectanglesurround">surround</a> method
94
+ * or the {@link OBJ_SurroundAnimationStep} found in the in
95
+ * the animation manager ({@link FigureElement}.animations),
96
+ * and in the animation builder
97
+ * (<a href="#animationmanagernew">animations.new</a>
98
+ * and <a href="#animationmanagerbuilder">animations.builder</a>).
99
+ *
100
+ * Button behavior means the button will temporarily change a different color
101
+ * when it is clicked. By default, the button will become a little more
102
+ * transparent, but colors for the fill, label and border can also be
103
+ * specified.
104
+ *
105
+ * @see
106
+ *
107
+ * See {@link COL_Rectangle} for setup options.
108
+ *
109
+ * See {@link OBJ_SurroundAnimationStep} for surround animation step options.
110
+ *
111
+ * To test examples below, append them to the
112
+ * <a href="#drawing-boilerplate">boilerplate</a>.
113
+ *
114
+ * @example
115
+ * // Simple rectangle
116
+ * figure.add({
117
+ * name: 'rect',
118
+ * make: 'collections.rectangle',
119
+ * width: 2,
120
+ * height: 1,
121
+ * });
122
+ *
123
+ * @example
124
+ * // Round corner rectangle with fill and outside line
125
+ * const rect = figure.collections.rectangle({
126
+ * width: 2,
127
+ * height: 1,
128
+ * line: {
129
+ * width: 0.02,
130
+ * widthIs: 'outside',
131
+ * dash: [0.1, 0.02],
132
+ * },
133
+ * corner: {
134
+ * radius: 0.2,
135
+ * sides: 10,
136
+ * },
137
+ * fill: [0.7, 0.7, 1, 1],
138
+ * });
139
+ * figure.add('rect', rect);
140
+ *
141
+ * @example
142
+ * // Rectangle surrounds elements of an equation
143
+ * figure.add([
144
+ * {
145
+ * name: 'rect',
146
+ * make: 'collections.rectangle',
147
+ * color: [0.3, 0.3, 1, 1],
148
+ * line: { width: 0.01 },
149
+ * },
150
+ * {
151
+ * name: 'eqn',
152
+ * make: 'equation',
153
+ * forms: { 0: [{ frac: ['a', 'vinculum', 'b'] }, ' ', 'c'] },
154
+ * position: [1, 0],
155
+ * scale: 1.5,
156
+ * }
157
+ * ]);
158
+ *
159
+ * const rect = figure.getElement('rect');
160
+ * const eqn = figure.getElement('eqn');
161
+ *
162
+ * rect.surround(eqn._a, 0.03);
163
+ * rect.animations.new()
164
+ * .pulse({ delay: 1, scale: 1.5 })
165
+ * .surround({ target: eqn._b, space: 0.03, duration: 1 })
166
+ * .pulse({ delay: 1, scale: 1.5 })
167
+ * .surround({ target: eqn._c, space: 0.03, duration: 1 })
168
+ * .pulse({ delay: 1, scale: 1.5 })
169
+ * .start();
170
+ *
171
+ * @example
172
+ * // Make a rectangle that behaves like a button
173
+ * figure.add([
174
+ * {
175
+ * name: 'rect',
176
+ * make: 'collections.rectangle',
177
+ * width: 0.5,
178
+ * height: 0.3,
179
+ * color: [0.3, 0.3, 0.3, 1],
180
+ * label: 'Save',
181
+ * corner: { radius: 0.05, sides: 10 },
182
+ * fill: [0.9, 0.9, 0.9, 1],
183
+ * button: {
184
+ * fill: [0.95, 0.95, 0.95, 1],
185
+ * },
186
+ * mods: {
187
+ * isTouchable: true,
188
+ * onClick: () => console.log('clicked'),
189
+ * },
190
+ * },
191
+ * ]);
192
+ * @group 2D Shape Collections
193
+ */
194
+ declare class CollectionsRectangle extends FigureElementCollection {
195
+ _line: FigureElementPrimitive | null;
196
+ _fill: FigureElementPrimitive | null;
197
+ _label: CollectionsText | null;
198
+ width: number;
199
+ height: number;
200
+ xAlign: 'left' | 'center' | 'right' | number;
201
+ yAlign: 'bottom' | 'middle' | 'top' | number;
202
+ corner: OBJ_CurvedCorner;
203
+ labelOffset: Point;
204
+ animations: {
205
+ surround: (...args: any[]) => animation.CustomAnimationStep;
206
+ } & animation.AnimationManager;
207
+ /**
208
+ * @hideconstructor
209
+ */
210
+ constructor(collections: FigureCollections, optionsIn: COL_Rectangle);
211
+ addButtonBehavior(onClickColors: {
212
+ line?: TypeColor;
213
+ fill?: TypeColor;
214
+ label?: TypeColor;
215
+ } | TypeColor | boolean): void;
216
+ addRect(rectOptions: OBJ_LineStyleSimple, name: string, fill: boolean): void;
217
+ setPositions(): void;
218
+ addlabel(textOptions: OBJ_FormattedText | string): void;
219
+ getSurround(element: FigureElement | Array<FigureElement>, space?: TypeParsableBuffer, isInLocalSpace?: boolean): (number | Point)[];
220
+ /**
221
+ * Surround element of elements with the rectangle.
222
+ */
223
+ surround(element: FigureElement | Array<FigureElement>, space?: TypeParsableBuffer, isInLocalSpace?: boolean): void;
224
+ setSurround(position: Point, width: number, height: number): void;
225
+ stateSet(): void;
226
+ /**
227
+ * Set button label.
228
+ */
229
+ setLabel(text: string | OBJ_FormattedText): void;
230
+ /**
231
+ * Get button label.
232
+ */
233
+ getLabel(): string;
234
+ }
235
+ export default CollectionsRectangle;
@@ -0,0 +1,255 @@
1
+ import { FigureElementCollection } from '../Element';
2
+ import type { FigureElement } from '../Element';
3
+ import type { OBJ_Arrow } from '../FigurePrimitives/FigurePrimitiveTypes2D';
4
+ import type { OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
5
+ import type FigureCollections from './FigureCollections';
6
+ import SlideNavigator from '../SlideNavigator';
7
+ import type { OBJ_SlideNavigatorSlide } from '../SlideNavigator';
8
+ import type { COL_Rectangle } from './Rectangle';
9
+ import type Figure from '../Figure';
10
+ import type { Equation } from '../Equation/Equation';
11
+ import type { OBJ_FormattedText } from './Text';
12
+ /**
13
+ * CollectionsSlideNavigator Button.
14
+ * @property {'arrow' | 'rectangle'} type
15
+ * @extends COL_Rectangle
16
+ * @extends OBJ_Arrow
17
+ * @interface
18
+ * @group Misc SlideNavigator
19
+ */
20
+ export type COL_SlideNavigatorButton = {
21
+ type: 'arrow' | 'rectangle';
22
+ } & COL_Rectangle & OBJ_Arrow;
23
+ /**
24
+ * CollectionsSlideNavigator equation animation defaults
25
+ * @interface
26
+ * @group Misc SlideNavigator
27
+ */
28
+ export type COL_SlideNavigatorEqnDefaults = {
29
+ duration?: number;
30
+ animate?: 'move' | 'dissolve' | 'instant';
31
+ };
32
+ /**
33
+ * {@link CollectionsSlideNavigator} options object that extends
34
+ * {@link OBJ_Collection} options object (without `parent`).
35
+ *
36
+ * This rectangle is similar to {@link OBJ_Rectangle}, except it can accomodate
37
+ * both a fill and a border or line simultaneously with different colors.
38
+ *
39
+ * @extends OBJ_Collection
40
+ *
41
+ * @property {Figure | FigureElementCollection | string} [collection]
42
+ * collection to tie slide navigator to. By default will tie to its parent.
43
+ * @property {Array<OBJ_SlideNavigatorSlide>} [slides]
44
+ * @property {COL_SlideNavigatorButton | null} [prevButton] previous button
45
+ * options - use `null` to hide
46
+ * @property {COL_SlideNavigatorButton | null} [nextButton] next button options
47
+ * - use `null` to hide
48
+ * @property {OBJ_FormattedText | null} [text] text options - use `null` to hide
49
+ * @property {Equation | string | Array<string | Equation>} [equation] equation
50
+ * to tie to SlideNavigator
51
+ * @property {COL_SlideNavigatorEqnDefaults} [equationDefaults] default
52
+ * equation animation options
53
+ * @property {number} [disableOpacity] opacity for previous button when disabled (`0.7`)
54
+ * @interface
55
+ * @group Slide Navigator
56
+ */
57
+ export type COL_SlideNavigator = {
58
+ collection?: Figure | FigureElementCollection | string;
59
+ slides?: Array<OBJ_SlideNavigatorSlide>;
60
+ prevButton?: COL_SlideNavigatorButton | null;
61
+ nextButton?: COL_SlideNavigatorButton | null;
62
+ text?: OBJ_FormattedText | null;
63
+ equation?: Equation | string | Array<string | Equation>;
64
+ equationDefaults?: COL_SlideNavigatorEqnDefaults;
65
+ disableOpacity?: number;
66
+ } & OBJ_Collection;
67
+ /**
68
+ * {@link FigureElementCollection} that creates elements to work with {@link SlideNavigator}.
69
+ *
70
+ * <p class="inline_gif"><img src="./apiassets/slidenavigator1.gif" class="inline_gif_image"></p>
71
+ *
72
+ * <p class="inline_gif"><img src="./apiassets/slidenavigator2.gif" class="inline_gif_image"></p>
73
+ *
74
+ * <p class="inline_gif"><img src="./apiassets/slidenavigator3.gif" class="inline_gif_image"></p>
75
+ *
76
+ * This object defines a rectangle
77
+ * {@link FigureElementCollection} that may include:
78
+ * - previous button
79
+ * - next button
80
+ * - {@link OBJ_TextLines} object
81
+ *
82
+ *
83
+ * @see
84
+ *
85
+ * See {@link SlideNavigator} for information about what a slide navigator is.
86
+ *
87
+ * To test examples below, append them to the
88
+ * <a href="#drawing-boilerplate">boilerplate</a>.
89
+ *
90
+ *
91
+ * @example
92
+ * // At its simplest, the SlideNavigator can be used to navigate an equation
93
+ * figure.add([
94
+ * {
95
+ * name: 'eqn',
96
+ * make: 'equation',
97
+ * formDefaults: { alignment: { xAlign: 'center' } },
98
+ * forms: {
99
+ * 0: ['a', '_ + ', 'b', '_ = ', 'c'],
100
+ * 1: ['a', '_ + ', 'b', '_ - b_1', '_ = ', 'c', '_ - ', 'b_2'],
101
+ * 2: ['a', '_ = ', 'c', '_ - ', 'b_2'],
102
+ * },
103
+ * formSeries: ['0', '1', '2'],
104
+ * },
105
+ * {
106
+ * name: 'nav',
107
+ * make: 'collections.slideNavigator',
108
+ * equation: 'eqn',
109
+ * },
110
+ * ]);
111
+ *
112
+ * @example
113
+ * // Text can be used to describe each slide
114
+ * figure.add([
115
+ * {
116
+ * name: 'eqn',
117
+ * make: 'equation',
118
+ * formDefaults: { alignment: { xAlign: 'center' } },
119
+ * forms: {
120
+ * 0: ['a', '_ + ', 'b', '_ = ', 'c'],
121
+ * 1: ['a', '_ + ', 'b', '_ - b_1', '_ = ', 'c', '_ - ', 'b_2'],
122
+ * 2: ['a', '_ = ', 'c', '_ - ', 'b_2'],
123
+ * },
124
+ * },
125
+ * {
126
+ * name: 'nav',
127
+ * make: 'collections.slideNavigator',
128
+ * equation: 'eqn',
129
+ * text: { position: [0, 0.3] },
130
+ * slides: [
131
+ * { text: 'Start with the equation', form: '0' },
132
+ * { text: 'Subtract b from both sides' },
133
+ * { form: '1' },
134
+ * { text: 'The b terms cancel on the left hand side' },
135
+ * { form: '2' },
136
+ * ],
137
+ * },
138
+ * ]);
139
+ *
140
+ * @example
141
+ * // This example creates a story by evolving a description, a diagram
142
+ * // and an equation.
143
+ * figure.add([
144
+ * { // Square drawing
145
+ * name: 'square',
146
+ * make: 'primitives.rectangle',
147
+ * width: 0.4,
148
+ * height: 0.4,
149
+ * line: { width: 0.005 },
150
+ * },
151
+ * { // Side length label
152
+ * name: 'label',
153
+ * make: 'text',
154
+ * yAlign: 'middle',
155
+ * position: [0.3, 0],
156
+ * font: { size: 0.1 },
157
+ * },
158
+ * { // Equation
159
+ * name: 'eqn',
160
+ * make: 'equation',
161
+ * elements: {
162
+ * eq1: ' = ',
163
+ * eq2: ' = ',
164
+ * eq3: ' = ',
165
+ * },
166
+ * phrases: {
167
+ * sideSqrd: { sup: ['side', '_2'] },
168
+ * areaEqSide: [{ bottomComment: ['Area', 'square'] }, 'eq1', 'sideSqrd'],
169
+ * },
170
+ * formDefaults: { alignment: { xAlign: 'center' } },
171
+ * forms: {
172
+ * 0: ['areaEqSide'],
173
+ * 1: ['areaEqSide', 'eq2', { sup: ['_1', '_2_1'] }, 'eq3', '_1_1'],
174
+ * 2: ['areaEqSide', 'eq2', { sup: ['_2_2', '_2_1'] }, 'eq3', '4'],
175
+ * },
176
+ * position: [0, -0.8],
177
+ * },
178
+ * { // Slide Navigator
179
+ * name: 'nav',
180
+ * make: 'collections.slideNavigator',
181
+ * equation: 'eqn',
182
+ * nextButton: { type: 'arrow', position: [1.2, -0.8] },
183
+ * prevButton: { type: 'arrow', position: [-1.2, -0.8] },
184
+ * text: { position: [0, 0.7], font: { size: 0.12 } },
185
+ * },
186
+ * ]);
187
+ *
188
+ * const square = figure.getElement('square');
189
+ * const label = figure.getElement('label');
190
+ *
191
+ * // Update the square size, and side label for any sideLength
192
+ * const update = (sideLength) => {
193
+ * square.custom.updatePoints({ width: sideLength, height: sideLength });
194
+ * label.setPosition(sideLength / 2 + 0.1, 0);
195
+ * label.setText({ text: `${(sideLength / 0.4).toFixed(1)}` });
196
+ * };
197
+ *
198
+ * // Add slides to the navigator
199
+ * figure.getElement('nav').loadSlides([
200
+ * {
201
+ * showCommon: ['square', 'label', 'eqn'],
202
+ * text: 'The area of a square is the side length squared',
203
+ * form: '0',
204
+ * steadyStateCommon: () => update(0.4),
205
+ * },
206
+ * { text: 'So for side length of 1 we have and area of 1' },
207
+ * { form: '1' },
208
+ * { form: null, text: 'What is the area for side length 2?' },
209
+ * {
210
+ * transition: (done) => {
211
+ * square.animations.new()
212
+ * .custom({
213
+ * duration: 1,
214
+ * callback: p => update(0.4 + p * 0.4),
215
+ * })
216
+ * .whenFinished(done)
217
+ * .start();
218
+ * },
219
+ * steadyStateCommon: () => update(0.8),
220
+ * },
221
+ * { form: '2' },
222
+ * ]);
223
+ * @group Slide Navigator
224
+ */
225
+ declare class CollectionsSlideNavigator extends FigureElementCollection {
226
+ _nextButton: FigureElement | null;
227
+ _prevButton: FigureElement | null;
228
+ _text: FigureElement | null;
229
+ nav: SlideNavigator;
230
+ /**
231
+ * @hideconstructor
232
+ */
233
+ constructor(collections: FigureCollections, optionsIn: COL_SlideNavigator);
234
+ /**
235
+ * Load slides into navigator
236
+ */
237
+ loadSlides(slides: Array<OBJ_SlideNavigatorSlide>): void;
238
+ /**
239
+ * Jump to a specific slide.
240
+ */
241
+ goToSlide(slideIndex: number): void;
242
+ /**
243
+ * Progress to the next slide.
244
+ */
245
+ nextSlide(ignoreTransition?: boolean): void;
246
+ /**
247
+ * Go to the previous slide.
248
+ */
249
+ prevSlide(): void;
250
+ addText(textOptions: OBJ_FormattedText | string): void;
251
+ addButton(options: COL_SlideNavigatorButton, type: 'Next' | 'Prev'): void;
252
+ getRectangleButton(options: COL_SlideNavigatorButton, type: 'Next' | 'Prev'): import("./Rectangle").default;
253
+ getArrowButton(options: COL_SlideNavigatorButton, type: 'Next' | 'Prev'): any;
254
+ }
255
+ export default CollectionsSlideNavigator;
@@ -0,0 +1,155 @@
1
+ import { FigureElementCollection, FigureElementPrimitive } from '../Element';
2
+ import type { OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
3
+ import type { TypeColor } from '../../tools/types';
4
+ import type FigureCollections from './FigureCollections';
5
+ /**
6
+ * Border of circle or bar of slider.
7
+ *
8
+ * @property {width} [number] border width
9
+ * @property {color} [TypeColor] border color
10
+ * @see {@link OBJ_Slider}
11
+ * @interface
12
+ * @group Misc Shapes
13
+ */
14
+ export type OBJ_SliderBorder = {
15
+ width?: number;
16
+ color?: TypeColor;
17
+ };
18
+ /**
19
+ * Slider marker options.
20
+ *
21
+ * @property {'polygon' | 'rectangle'} [style]
22
+ * @property {number} [width] width of 'rectangle'
23
+ * @see {@link OBJ_Slider}
24
+ * @interface
25
+ * @group Misc Shapes
26
+ */
27
+ export type OBJ_SliderMarker = {
28
+ width?: number;
29
+ style?: 'polygon' | 'rectangle';
30
+ };
31
+ /**
32
+ * {@link CollectionsSlider} options object that extends {@link OBJ_Collection}
33
+ * options object (without `parent`).
34
+ *
35
+ * @property {number} [width] slider width
36
+ * @property {number} [height] slider height
37
+ * @property {number} [barHeight] height of slider bar bar
38
+ * @property {number} [sides] number of sides in curves (`20`)
39
+ * @property {OBJ_SliderMarker | 'polygon' | 'rectangle' | 'none'} [marker] marker style
40
+ * (`'polygon'`)
41
+ * @property {'dark' | 'light'} [theme] selects default colors for a light or
42
+ * dark switch (`dark`)
43
+ * @property {TypeColor} [colorOff] slider off color (bar color from slider
44
+ * value to 1)
45
+ * @property {TypeColor} [colorOn] slider on color (bar color from 0 to slider
46
+ * value (`[0, 1, 0, 1]`)
47
+ * @property {OBJ_SliderBorder} [markerBorder] border around circle (defaults to on
48
+ * where width is half the figure's default line width)
49
+ * @property {OBJ_SliderBorder} [barBorder] border around bar
50
+ * (defaults to off - width = 0)
51
+ * @extends OBJ_Collection
52
+ * @interface
53
+ * @group 2D Shape Collections
54
+ */
55
+ export type COL_Slider = {
56
+ width?: number;
57
+ height?: number;
58
+ barHeight?: number;
59
+ marker?: OBJ_SliderMarker | 'polygon' | 'rectangle' | 'none';
60
+ sides?: number;
61
+ theme?: 'dark' | 'light';
62
+ colorOff?: TypeColor;
63
+ colorOn?: TypeColor;
64
+ markerBorder?: OBJ_SliderBorder;
65
+ barBorder?: OBJ_SliderBorder;
66
+ } & OBJ_Collection;
67
+ /**
68
+ * {@link FigureElementCollection} representing a slider control.
69
+ *
70
+ * ![](./apiassets/slider.png)
71
+ *
72
+ * ![](./apiassets/slider.gif)
73
+ *
74
+ * Notifications - The notification manager property `notifications` will
75
+ * publish the following events:
76
+ * - `changed`: slider value is changed - slider position in percent is passed
77
+ * as parameter to callback.
78
+ *
79
+ * See {@link COL_Slider} for setup options.
80
+ *
81
+ * To test examples below, append them to the
82
+ * <a href="#drawing-boilerplate">boilerplate</a>
83
+ *
84
+ * @example
85
+ * // Simple slider with notification causing a console statement
86
+ * const slider = figure.add({
87
+ * make: 'collections.slider',
88
+ * barHeight: 0.02,
89
+ * height: 0.1,
90
+ * width: 1,
91
+ * color: [0.5, 0.5, 0.5, 1],
92
+ * touchBorder: 0.2,
93
+ * });
94
+ *
95
+ * slider.notifications.add('changed', (position) => {
96
+ * console.log(position)
97
+ * });
98
+ *
99
+ * @example
100
+ * // Slider without a marker and red fill for on
101
+ * figure.add({
102
+ * make: 'collections.slider',
103
+ * barHeight: 0.1,
104
+ * colorOn: [1, 0, 0, 1],
105
+ * width: 1,
106
+ * touchBorder: 0.2,
107
+ * marker: 'none',
108
+ * });
109
+ *
110
+ * @example
111
+ * // Slider with rectangle marker and multi-colors
112
+ * const slider = figure.add({
113
+ * make: 'collections.slider',
114
+ * barHeight: 0.02,
115
+ * height: 0.1,
116
+ * width: 1,
117
+ * marker: 'rectangle',
118
+ * colorOff: [1, 0, 0, 1],
119
+ * colorOn: [0, 0.8, 0, 1],
120
+ * color: [0, 0, 0, 1],
121
+ * });
122
+ * @group 2D Shape Collections
123
+ */
124
+ declare class CollectionsSlider extends FigureElementCollection {
125
+ _marker: FigureElementPrimitive;
126
+ _bar: FigureElementPrimitive;
127
+ _barOn: FigureElementPrimitive;
128
+ _markerBorder: FigureElementPrimitive | null;
129
+ _barBorder: FigureElementPrimitive | null;
130
+ width: number;
131
+ height: number;
132
+ markerWidth: number;
133
+ colorOn: TypeColor;
134
+ colorOff: TypeColor;
135
+ barHeight: number;
136
+ /**
137
+ * @hideconstructor
138
+ */
139
+ constructor(collections: FigureCollections, optionsIn: COL_Slider);
140
+ /**
141
+ * Set slider to value between 0 and 1.
142
+ * @param {number} percentage between 0 and 1
143
+ * @param {boolean} notify `true` to send notifications on change, `false` to
144
+ * supress (`true`)
145
+ */
146
+ setValue(percentage: number, notify?: boolean): void;
147
+ /**
148
+ * Get slider value.
149
+ * @return {number} between 0 and 1
150
+ */
151
+ getValue(): number;
152
+ setElementsToCircle(): void;
153
+ notify(): void;
154
+ }
155
+ export default CollectionsSlider;