figureone 0.15.10 → 1.0.1

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 (160) hide show
  1. package/figureone.min.js +1 -1
  2. package/index.js +79170 -0
  3. package/llms.txt +548 -0
  4. package/package.json +16 -1
  5. package/types/index.d.ts +128 -0
  6. package/types/js/figure/Animation/Animation.d.ts +36 -0
  7. package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
  8. package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
  9. package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
  10. package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
  11. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
  12. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
  13. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
  14. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
  15. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
  16. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
  17. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
  18. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
  19. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
  20. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
  21. package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
  22. package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
  23. package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
  24. package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
  25. package/types/js/figure/DrawContext2D.d.ts +9 -0
  26. package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
  27. package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
  28. package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
  29. package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
  30. package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
  31. package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
  32. package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
  33. package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
  34. package/types/js/figure/Element.d.ts +1212 -0
  35. package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
  36. package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
  37. package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
  38. package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
  39. package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
  40. package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
  41. package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
  42. package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
  43. package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
  44. package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
  45. package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
  46. package/types/js/figure/Equation/Equation.d.ts +984 -0
  47. package/types/js/figure/Equation/EquationForm.d.ts +139 -0
  48. package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
  49. package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
  50. package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
  51. package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
  52. package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
  53. package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
  54. package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
  55. package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
  56. package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
  57. package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
  58. package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
  59. package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
  60. package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
  61. package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
  62. package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
  63. package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
  64. package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
  65. package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
  66. package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
  67. package/types/js/figure/Figure.d.ts +711 -0
  68. package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
  69. package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
  70. package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
  71. package/types/js/figure/FigureCollections/Button.d.ts +195 -0
  72. package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
  73. package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
  74. package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
  75. package/types/js/figure/FigureCollections/Line.d.ts +587 -0
  76. package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
  77. package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
  78. package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
  79. package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
  80. package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
  81. package/types/js/figure/FigureCollections/Text.d.ts +307 -0
  82. package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
  83. package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
  84. package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
  85. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
  86. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
  87. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
  88. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
  89. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
  90. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
  91. package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
  92. package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
  93. package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
  94. package/types/js/figure/FontManager.d.ts +113 -0
  95. package/types/js/figure/Gesture.d.ts +39 -0
  96. package/types/js/figure/Recorder/Recorder.d.ts +291 -0
  97. package/types/js/figure/Recorder/parseState.d.ts +3 -0
  98. package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
  99. package/types/js/figure/Recorder/state.d.ts +7 -0
  100. package/types/js/figure/SlideNavigator.d.ts +606 -0
  101. package/types/js/figure/TimeKeeper.d.ts +174 -0
  102. package/types/js/figure/geometries/arc.d.ts +18 -0
  103. package/types/js/figure/geometries/arrow.d.ts +215 -0
  104. package/types/js/figure/geometries/buffer.d.ts +4 -0
  105. package/types/js/figure/geometries/copy/copy.d.ts +178 -0
  106. package/types/js/figure/geometries/ellipse.d.ts +17 -0
  107. package/types/js/figure/geometries/line.d.ts +13 -0
  108. package/types/js/figure/geometries/lines/corners.d.ts +7 -0
  109. package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
  110. package/types/js/figure/geometries/lines/lines.d.ts +31 -0
  111. package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
  112. package/types/js/figure/geometries/rectangle.d.ts +19 -0
  113. package/types/js/figure/geometries/triangle.d.ts +27 -0
  114. package/types/js/figure/webgl/Atlas.d.ts +42 -0
  115. package/types/js/figure/webgl/shaders.d.ts +143 -0
  116. package/types/js/figure/webgl/target.d.ts +9 -0
  117. package/types/js/figure/webgl/webgl.d.ts +54 -0
  118. package/types/js/tools/FunctionMap.d.ts +69 -0
  119. package/types/js/tools/color.d.ts +11 -0
  120. package/types/js/tools/colorNames.d.ts +2 -0
  121. package/types/js/tools/d2/polygon.d.ts +60 -0
  122. package/types/js/tools/d2/triangles.d.ts +0 -0
  123. package/types/js/tools/d3/cone.d.ts +57 -0
  124. package/types/js/tools/d3/cube.d.ts +26 -0
  125. package/types/js/tools/d3/cylinder.d.ts +45 -0
  126. package/types/js/tools/d3/line3.d.ts +55 -0
  127. package/types/js/tools/d3/prism.d.ts +49 -0
  128. package/types/js/tools/d3/revolve.d.ts +87 -0
  129. package/types/js/tools/d3/sphere.d.ts +33 -0
  130. package/types/js/tools/d3/surface.d.ts +47 -0
  131. package/types/js/tools/g2.d.ts +242 -0
  132. package/types/js/tools/geometry/Bounds.d.ts +446 -0
  133. package/types/js/tools/geometry/Line.d.ts +314 -0
  134. package/types/js/tools/geometry/Path.d.ts +67 -0
  135. package/types/js/tools/geometry/Plane.d.ts +201 -0
  136. package/types/js/tools/geometry/Point.d.ts +359 -0
  137. package/types/js/tools/geometry/Rect.d.ts +115 -0
  138. package/types/js/tools/geometry/Transform.d.ts +623 -0
  139. package/types/js/tools/geometry/angle.d.ts +105 -0
  140. package/types/js/tools/geometry/common.d.ts +9 -0
  141. package/types/js/tools/geometry/coordinates.d.ts +30 -0
  142. package/types/js/tools/geometry/deceleration.d.ts +13 -0
  143. package/types/js/tools/geometry/polygon.d.ts +4 -0
  144. package/types/js/tools/geometry/quaternion.d.ts +15 -0
  145. package/types/js/tools/geometry/scene.d.ts +282 -0
  146. package/types/js/tools/geometry/tools.d.ts +8 -0
  147. package/types/js/tools/geometry/types.d.ts +2 -0
  148. package/types/js/tools/getCssColors.d.ts +1 -0
  149. package/types/js/tools/getCssVariables.d.ts +4 -0
  150. package/types/js/tools/getImageData.d.ts +1 -0
  151. package/types/js/tools/getScssColors.d.ts +2 -0
  152. package/types/js/tools/htmlGenerator.d.ts +85 -0
  153. package/types/js/tools/m2.d.ts +24 -0
  154. package/types/js/tools/m3.d.ts +71 -0
  155. package/types/js/tools/math.d.ts +112 -0
  156. package/types/js/tools/morph.d.ts +651 -0
  157. package/types/js/tools/styleSheets.d.ts +3 -0
  158. package/types/js/tools/tools.d.ts +281 -0
  159. package/types/js/tools/types.d.ts +305 -0
  160. package/figureone.worker.js +0 -1
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Animations are simply interpolating each value within a rotation definition
3
+ * independently (either between a `start` and `target` or from a `start` with
4
+ * `velocity`). Therefore, animating any values that belong to vectors
5
+ * (direction ('dir' or 'rd'), change of basis ('rbasis' or 'rb'), or the axis
6
+ * of axis/angle) may result in unexpected animations. For example, if animating
7
+ * a rotation direction from [1, 0, 0] to [-1, 0, 0] it might be expected that
8
+ * a π radians rotation would occur. Instead, it will look like no rotation
9
+ * will have started, then a π rotation will happen in a single frame, and then
10
+ * it will look stationary again. This is because only the x component of the
11
+ * direction vector will change each animation frame. As a rotation direciton
12
+ * that is [0.5, 0, 0] is the same as [1, 0, 0], then for half the animation it
13
+ * will look like nothing is changing. When the x component cross from the 0
14
+ * point, the element's rotation will instantly flip. Then for the second have
15
+ * of the rotation as the x component gets more negative it will once again
16
+ * look stationary.
17
+ *
18
+ * If wanting to animate a direction vector, use {@link directionToAxisAngle}
19
+ * or {@link angleFromVectors} and then use a axis/angle rotation
20
+ * keeping the axis constant. If wanting to animate a change of basis rotation,
21
+ * then use a {@link CustomAnimationStep} to manage how to change the basis
22
+ * vectors over time.
23
+ */
24
+ import { Transform } from '../../../../tools/g2';
25
+ import type { OBJ_TranslationPath } from '../../../../tools/g2';
26
+ import type { OBJ_ElementAnimationStep } from '../ElementAnimationStep';
27
+ import ElementAnimationStep from '../ElementAnimationStep';
28
+ import type { AnimationStartTime } from '../../AnimationManager';
29
+ /**
30
+ * {@link TransformAnimationStep} options object
31
+ *
32
+ * @extends OBJ_ElementAnimationStep
33
+ *
34
+ * @property {TypeParsableTransform} [start]
35
+ * @property {TypeParsableTransform} [target]
36
+ * @property {TypeParsableTransform} [delta]
37
+ * @property {null | TypeParsableTransform} [velocity] velocity of
38
+ * transform overrides `duration` - `null` to use `duration` (`null`)
39
+ * @property {OBJ_TranslationPath} [path] translation path style and options
40
+ * (`{ style: 'linear' }`)
41
+ * @property {0 | 1 | -1 | 2} [rotDirection] where `0` is quickest direction,
42
+ * `1` is positive of CCW direction, `-1` is negative of CW direction and `2` is
43
+ * whichever direction doesn't pass through angle 0 (`0`).
44
+ * @property {'0to360' | '-180to180' | null} [clipRotationTo]
45
+ * @property {number | null} [maxDuration] maximum duration to clip animation
46
+ * to where `null` is unlimited (`null`)
47
+ * @interface
48
+ * @group Misc Animation
49
+ */
50
+ export type OBJ_TransformAnimationStep = {
51
+ start?: Transform;
52
+ target?: Transform;
53
+ delta?: Transform;
54
+ path?: OBJ_TranslationPath;
55
+ rotDirection?: 0 | 1 | -1 | 2;
56
+ clipRotationTo?: '0to360' | '-180to180' | null;
57
+ velocity?: Transform | number | null | undefined;
58
+ maxDuration?: number;
59
+ } & OBJ_ElementAnimationStep;
60
+ /**
61
+ * Transform Animation Step
62
+ *
63
+ * ![](./apiassets/transform_animation.gif)
64
+ *
65
+ * By default, the transform will start with the element's current transform.
66
+ *
67
+ * A {@link Transform} chains many transform links where each link might be
68
+ * a {@link Rotation}, {@link Scale} or {@link Translation} transform.
69
+ *
70
+ * `start`, `target` and `delta` should have the same order of transform links
71
+ * as the `element`'s transform.
72
+ *
73
+ * The {@link TransformAnimationStep} will animate each of these links with the
74
+ * same duration. If `velocity` is used to calculate the duration, then the link
75
+ * with the longest duration will define the duration of the animation.
76
+ * `velocity` can either be a transform with the same order of transform links
77
+ * as the `element` or it can be a constant value, which will be applied to
78
+ * all transform links. `velocity` cannot be 0.
79
+ *
80
+ * Use either `delta` or `target` to define it's end point of the animation.
81
+ *
82
+ * @extends ElementAnimationStep
83
+ * @param {OBJ_TransformAnimationStep} options
84
+ *
85
+ * @see To test examples, append them to the
86
+ * <a href="#animation-boilerplate">boilerplate</a>
87
+ *
88
+ * @example
89
+ * // Using duration
90
+ * p.animations.new()
91
+ * .transform({
92
+ * target: new Fig.Transform().scale(2, 2).rotate(0.5).translate(1, 0),
93
+ * duration: 2,
94
+ * })
95
+ * .start();
96
+ *
97
+ * @example
98
+ * // Using velocity as a transform
99
+ * p.animations.new()
100
+ * .transform({
101
+ * target: new Fig.Transform().scale(2, 2).rotate(0.5).translate(1, 0),
102
+ * velocity: new Fig.Transform().scale(0.5, 0.5).rotate(0.25).translate(0.5, 0.5),
103
+ * })
104
+ * .start();
105
+ *
106
+ * @example
107
+ * // Using velocity as a number
108
+ * p.animations.new()
109
+ * .transform({
110
+ * target: new Fig.Transform().scale(2, 2).rotate(0.5).translate(1, 0),
111
+ * velocity: 0.5,
112
+ * })
113
+ * .start();
114
+ *
115
+ * @example
116
+ * // Using TypeParsableTransform as transform definition
117
+ * p.animations.new()
118
+ * .transform({
119
+ * target: [['s', 1.5, 1.5], ['r', 0.5], ['t', 1, 0]],
120
+ * duration: 2,
121
+ * })
122
+ * .start();
123
+ *
124
+ * @example
125
+ * // Different ways to create a stand-alone step
126
+ * const step1 = p.animations.transform({
127
+ * target: [['s', 1.5, 1.5], ['r', 1], ['t', 1, 0]],
128
+ * duration: 2,
129
+ * });
130
+ * const step2 = new Fig.Animation.TransformAnimationStep({
131
+ * element: p,
132
+ * target: [['s', 1, 1], ['r', 0], ['t', 0, 0]],
133
+ * duration: 2,
134
+ * });
135
+ *
136
+ * p.animations.new()
137
+ * .then(step1)
138
+ * .then(step2)
139
+ * .start();
140
+ * @group Animation
141
+ */
142
+ export default class TransformAnimationStep extends ElementAnimationStep {
143
+ transform: {
144
+ start: Transform;
145
+ delta: Transform;
146
+ target: Transform;
147
+ rotDirection: 0 | 1 | -1 | 2;
148
+ path: OBJ_TranslationPath;
149
+ velocity: Transform | number | null | undefined;
150
+ clipRotationTo: '0to360' | '-180to180' | null;
151
+ maxDuration: number | null | undefined;
152
+ };
153
+ /**
154
+ * @hideconstructor
155
+ */
156
+ constructor(...optionsIn: Array<OBJ_TransformAnimationStep>);
157
+ _getStateProperties(): string[];
158
+ _getStateName(): string;
159
+ start(startTime?: AnimationStartTime | null): void;
160
+ setFrame(deltaTime: number): void;
161
+ setToEnd(): void;
162
+ _dup(): TransformAnimationStep;
163
+ }
@@ -0,0 +1,56 @@
1
+ import type { OBJ_AnimationStep } from '../AnimationStep';
2
+ import AnimationStep from '../AnimationStep';
3
+ import type { FigureElement } from '../../Element';
4
+ import type { AnimationStartTime } from '../AnimationManager';
5
+ /**
6
+ * Animation progression function.
7
+ *
8
+ * As the animation time progresses, a percentage of the total animation
9
+ * duration will be passed to this function.
10
+ *
11
+ * This function then calculates and returns the percent progress of the
12
+ * animation.
13
+ *
14
+ * This function can be used to make non-linear progressions of an animation.
15
+ * For instance, it could be used to create a progression that is slowed
16
+ * at the start or end of the animation.
17
+ *
18
+ * @param {number} percent percentage of duration
19
+ * @return {number} percent of animation complete
20
+ * @group Misc Animation
21
+ */
22
+ export type AnimationProgression = (percent: number) => number;
23
+ /**
24
+ * {@link ElementAnimationStep} options object
25
+ *
26
+ * @extends OBJ_AnimationStep
27
+ * @property {FigureElement} [element]
28
+ * @property {'linear' | 'easeinout' | 'easein' | 'easeout' | AnimationProgression} [progression]
29
+ * how the animation progresses - defaults to `linear` for color, opacity and
30
+ * custom animations and `easeinout` for others
31
+ * @interface
32
+ * @group Misc Animation
33
+ */
34
+ export type OBJ_ElementAnimationStep = {
35
+ element?: FigureElement;
36
+ type?: 'transform' | 'color' | 'custom' | 'position' | 'rotation' | 'scale' | 'opacity';
37
+ progression?: 'linear' | 'easeinout' | 'easein' | 'easeout' | AnimationProgression;
38
+ } & OBJ_AnimationStep;
39
+ /**
40
+ * Animation Step tied to an element
41
+ *
42
+ * Default values for the animation step will then come from this element.
43
+ *
44
+ * @extends AnimationStep
45
+ * @group Misc Animation
46
+ */
47
+ export default class ElementAnimationStep extends AnimationStep {
48
+ type: 'transform' | 'color' | 'custom' | 'position' | 'setPosition' | 'opacity';
49
+ progression: ((percent: number, invert?: boolean) => number) | string;
50
+ constructor(optionsIn?: OBJ_ElementAnimationStep);
51
+ fnExec(idOrFn: string | Function | null, ...args: any): any;
52
+ _getStateProperties(): string[];
53
+ getPercentComplete(percentTime: number): any;
54
+ start(startTime?: AnimationStartTime | null): void;
55
+ _dup(): ElementAnimationStep;
56
+ }
@@ -0,0 +1,70 @@
1
+ import type { OBJ_AnimationStep } from '../AnimationStep';
2
+ import AnimationStep from '../AnimationStep';
3
+ import type { AnimationStartTime } from '../AnimationManager';
4
+ /**
5
+ * Parallel animation step options object
6
+ * @extends OBJ_AnimationStep
7
+ * @property {Array<AnimationStep>} steps animation steps to perform in parallel
8
+ * @interface
9
+ * @group Misc Animation
10
+ */
11
+ export type OBJ_ParallelAnimationStep = {
12
+ steps?: Array<AnimationStep>;
13
+ } & OBJ_AnimationStep;
14
+ /**
15
+ * Execute an array of `{@link AnimationStep}`s in parallel.
16
+ *
17
+ * ![](./apiassets/parallel_animation.gif)
18
+ *
19
+ * The parallel animation step will not complete till all steps are finished.
20
+ *
21
+ * @param {Array<AnimationStep> | OBJ_SerialAnimationStep} steps
22
+ * animation steps to perform in serial
23
+ * @extends AnimationStep
24
+ * @see To test examples, append them to the
25
+ * <a href="#animation-boilerplate">boilerplate</a>
26
+ *
27
+ * @example
28
+ * p.animations.new()
29
+ * .inParallel([
30
+ * p.animations.position({ target: [1, 0], duration: 2 }),
31
+ * p.animations.scale({ target: 2, duration: 2 }),
32
+ * ])
33
+ * .start();
34
+ *
35
+ * @example
36
+ * // One of the parallel steps is a series of steps
37
+ * p.animations.new()
38
+ * .delay(1)
39
+ * .inParallel([
40
+ * p.animations.builder()
41
+ * .scale({ target: 0.5, duration: 1 })
42
+ * .scale({ target: 2, duration: 1 })
43
+ * .scale({ target: 1, duration: 2 }),
44
+ * p.animations.color({ target: [0, 0, 1, 1], duration: 4 }),
45
+ * p.animations.rotation({ target: Math.PI, duration: 4 }),
46
+ * ])
47
+ * .start();
48
+ * @group Animation
49
+ */
50
+ export declare class ParallelAnimationStep extends AnimationStep {
51
+ steps: Array<AnimationStep>;
52
+ /**
53
+ * @hideconstructor
54
+ */
55
+ constructor(stepsOrOptionsIn?: Array<AnimationStep | null> | OBJ_ParallelAnimationStep, ...optionsIn: Array<OBJ_ParallelAnimationStep>);
56
+ _getStateProperties(): string[];
57
+ _getStateName(): string;
58
+ setTimeDelta(delta: number | null | undefined): void;
59
+ with(step: AnimationStep): this;
60
+ setTimeSpeed(oldSpeed: number, newSpeed: number, now: number): void;
61
+ nextFrame(now: number, speed?: number): number | null;
62
+ finishIfZeroDuration(): void;
63
+ startWaiting(): void;
64
+ start(startTime?: AnimationStartTime | null): void;
65
+ finish(cancelled?: boolean, force?: 'complete' | 'freeze' | null): void;
66
+ getTotalDuration(): number | null;
67
+ getRemainingTime(now: number): number | null;
68
+ _dup(): ParallelAnimationStep;
69
+ }
70
+ export declare function inParallel(stepsOrOptionsIn?: Array<AnimationStep | null> | OBJ_ParallelAnimationStep, ...optionsIn: Array<OBJ_ParallelAnimationStep>): ParallelAnimationStep;
@@ -0,0 +1,84 @@
1
+ import type { OBJ_AnimationStep } from '../AnimationStep';
2
+ import AnimationStep from '../AnimationStep';
3
+ import type { AnimationStartTime } from '../AnimationManager';
4
+ /**
5
+ * Serial animation step options object
6
+ *
7
+ * @extends OBJ_AnimationStep
8
+ * @property {Array<AnimationStep>} [steps] animation steps to execute in series
9
+ * @interface
10
+ * @group Misc Animation
11
+ */
12
+ export type OBJ_SerialAnimationStep = {
13
+ steps?: Array<AnimationStep>;
14
+ } & OBJ_AnimationStep;
15
+ /**
16
+ * Execute an array of {@link AnimationStep}s in series.
17
+ *
18
+ * ![](./apiassets/serial_animation.gif)
19
+ *
20
+ * Often the {@link AnimationBuilder} class which extends
21
+ * `SerialAnimationStep` can be used to create serial animations
22
+ * in a more clean way.
23
+ *
24
+ * @param {Array<AnimationStep> | OBJ_SerialAnimationStep} steps
25
+ * animation steps to perform in serial
26
+ * @extends AnimationStep
27
+ * @see To test examples, append them to the
28
+ * <a href="#animation-boilerplate">boilerplate</a>
29
+ *
30
+ * @example
31
+ * // Using a SerialAnimation step can be cumbersome, but
32
+ * // can be useful if modularizing animations between files
33
+ * const Rot = Fig.Animation.RotationAnimationStep;
34
+ * const Delay = Fig.Animation.DelayAnimationStep;
35
+ * const Pos = Fig.Animation.PositionAnimationStep;
36
+ *
37
+ * const series = new Fig.Animation.SerialAnimationStep([
38
+ * new Rot({ element: p, target: Math.PI / 2, duration: 2 }),
39
+ * new Delay({ duration: 0.2 }),
40
+ * new Rot({ element: p, target: Math.PI, duration: 2 }),
41
+ * new Delay({ duration: 0.2 }),
42
+ * new Rot({ element: p, target: 0, direction: -1, duration: 1.3, progression: 'easein' }),
43
+ * new Pos({ element: p, target: [1, 0], duration: 2, progression: 'easeout' }),
44
+ * ]);
45
+ *
46
+ * p.animations.animations.push(series);
47
+ * p.animations.start()
48
+ *
49
+ * @example
50
+ * // Same animation but with `AnimationBuilder` (which is an extension of
51
+ * // `SerialAnimationStep`)
52
+ * p.animations.new()
53
+ * .rotation({ target: Math.PI / 2, duration: 2 })
54
+ * .delay(0.2)
55
+ * .rotation({ target: Math.PI, duration: 2 })
56
+ * .delay(0.2)
57
+ * .rotation({ target: 0, duration: 1, direction: -1, progression: 'easein' })
58
+ * .position({ target: [1, 0], duration: 2, progression: 'easeout' })
59
+ * .start();
60
+ * @group Animation
61
+ */
62
+ export declare class SerialAnimationStep extends AnimationStep {
63
+ steps: Array<AnimationStep>;
64
+ index: number;
65
+ /**
66
+ * @hideconstructor
67
+ */
68
+ constructor(stepsOrOptionsIn?: Array<AnimationStep> | OBJ_SerialAnimationStep, ...optionsIn: Array<OBJ_SerialAnimationStep>);
69
+ _getStateProperties(): string[];
70
+ _getStateName(): string;
71
+ setTimeDelta(delta: number | null | undefined): void;
72
+ then(step: AnimationStep | null | undefined): this;
73
+ startWaiting(): void;
74
+ start(startTime?: AnimationStartTime | null): void;
75
+ finishIfZeroDuration(startIndex?: number): void;
76
+ startStep(startTime?: AnimationStartTime | null): void;
77
+ setTimeSpeed(oldSpeed: number, newSpeed: number, now: number): void;
78
+ nextFrame(now: number, speed?: number): number | null;
79
+ finish(cancelled?: boolean, force?: 'complete' | 'freeze' | null): void;
80
+ getTotalDuration(): number | null;
81
+ getRemainingTime(now: number): number | null;
82
+ _dup(): SerialAnimationStep;
83
+ }
84
+ export declare function inSerial(stepsOrOptionsIn?: Array<AnimationStep> | OBJ_SerialAnimationStep, ...optionsIn: Array<OBJ_SerialAnimationStep>): SerialAnimationStep;
@@ -0,0 +1,106 @@
1
+ import type { OBJ_AnimationStep } from '../AnimationStep';
2
+ import AnimationStep from '../AnimationStep';
3
+ import type { AnimationStartTime } from '../AnimationManager';
4
+ /**
5
+ * {@link TriggernAnimationStep} options object
6
+ *
7
+ * @extends OBJ_AnimationStep
8
+ *
9
+ * @property {string | function(any): number | void} callback if desired, return
10
+ * a number from `callback` to update the duration of the trigger animation
11
+ * step. Doing so will make any previous calculations of remaining animation
12
+ * time incorrect. Make sure to initialize this step with a non-zero duration
13
+ * for this to work.
14
+ * @property {any} [payload] payload to pass to callback (`null`)
15
+ * @property {FigureElement} element {@link FigureElement} to associate with
16
+ * callback - if the `callback` is a string then this element's
17
+ * {@link FunctionMap} will be searched for the corresponding function
18
+ *
19
+ * @interface
20
+ * @group Misc Animation
21
+ */
22
+ export type OBJ_TriggerAnimationStep = {
23
+ callback?: Function;
24
+ payload?: any;
25
+ setToEnd?: string | Function;
26
+ } & OBJ_AnimationStep;
27
+ /**
28
+ * Trigger Animation Step
29
+ *
30
+ * ![](./apiassets/trigger_animation.gif)
31
+ *
32
+ * A trigger step executes a custom function
33
+ *
34
+ * A `delay` will delay the triggering of the custom function
35
+ * while `duration` will pad time at the end of the trigger before
36
+ * the animation step finishes.
37
+ *
38
+ * @extends AnimationStep
39
+ * @param {OBJ_TriggerAnimationStep | function(): void} options
40
+ *
41
+ * @see To test examples, append them to the
42
+ * <a href="#animation-boilerplate">boilerplate</a>
43
+ *
44
+ * @example
45
+ * // Simple trigger
46
+ * p.animations.new()
47
+ * .position({ target: [1, 0], duration: 2 })
48
+ * .trigger(() => { console.log('arrived at (1, 0)') })
49
+ * .position({ target: [0, 0], duration: 2 })
50
+ * .trigger(() => { console.log('arrived at (0, 0)') })
51
+ * .start();
52
+ *
53
+ * @example
54
+ * // Trigger with delay, duration and payload
55
+ * const printPosition = (pos) => {
56
+ * console.log(`arrived at ${pos}`);
57
+ * };
58
+ *
59
+ * p.animations.new()
60
+ * .position({ target: [1, 0], duration: 2 })
61
+ * .trigger({
62
+ * delay: 1,
63
+ * callback: printPosition,
64
+ * payload: '(1, 0)',
65
+ * duration: 1,
66
+ * })
67
+ * .position({ target: [0, 0], duration: 2 })
68
+ * .trigger({ callback: printPosition, payload: '(0, 0)' })
69
+ * .start();
70
+ *
71
+ * @example
72
+ * // Different ways to create a stand-alone step
73
+ * const step1 = p.animations.trigger({
74
+ * callback: () => { console.log('arrived at (1, 0)') },
75
+ * });
76
+ * const step2 = new Fig.Animation.TriggerAnimationStep({
77
+ * callback: () => { console.log('arrived at (0, 0)') },
78
+ * });
79
+ *
80
+ * p.animations.new()
81
+ * .position({ target: [1, 0], duration: 2 })
82
+ * .then(step1)
83
+ * .position({ target: [0, 0], duration: 2 })
84
+ * .then(step2)
85
+ * .start();
86
+ * @group Animation
87
+ */
88
+ export declare class TriggerAnimationStep extends AnimationStep {
89
+ callback: (string | Function) | null;
90
+ payload: Record<string, any> | null | undefined;
91
+ setToEndCallback: (string | Function) | null;
92
+ customProperties: Record<string, any>;
93
+ autoDuration: boolean;
94
+ /**
95
+ * @hideconstructor
96
+ */
97
+ constructor(triggerOrOptionsIn?: Function | OBJ_TriggerAnimationStep, ...optionsIn: Array<OBJ_TriggerAnimationStep>);
98
+ fnExec(idOrFn: string | Function | null, ...args: any): any;
99
+ _getStateProperties(): string[];
100
+ _getStateName(): string;
101
+ setFrame(): void;
102
+ start(startTime?: AnimationStartTime | null): void;
103
+ setToEnd(): void;
104
+ _dup(): TriggerAnimationStep;
105
+ }
106
+ export declare function trigger(triggerOrOptionsIn?: Function | OBJ_TriggerAnimationStep, ...optionsIn: Array<OBJ_TriggerAnimationStep>): TriggerAnimationStep;
@@ -0,0 +1,110 @@
1
+ import type { FigureElement } from '../Element';
2
+ import { FunctionMap } from '../../tools/FunctionMap';
3
+ import TimeKeeper from '../TimeKeeper';
4
+ import type { AnimationStartTime } from './AnimationManager';
5
+ /**
6
+ * Animation Step options object
7
+ *
8
+ * @property {number} [duration] in seconds (`0`)
9
+ * @property {number} [delay] delay before animation starts in seconds (`0`)
10
+ * @property {string} [name] animation name identifier (a random string)
11
+ * @property {null | (boolean) => void} [onFinish] called when animation is
12
+ * finished - a `true` parameter is passed to the callback if the animation was
13
+ * cancelled
14
+ * @property {boolean} [removeOnFinish] `true` to remove the animation from the
15
+ * animation manager when it is finished (`true`)
16
+ * @property {null | boolean} [completeOnCancel] `true` to skip to end of
17
+ * animation on cancel (`null`)
18
+ * @property {number} [precision] precision to do calculations to (`8`)
19
+ * @property {TimeKeepr} [timeKeeper] animations need to be tied to a time
20
+ * reference. If this is not supplied, then the default browser time reference
21
+ * performance.now will be used and methods with {@link TypeWhen} parameters
22
+ * will allow only `'now'` and `'nextFrame'` and not `'lastFrame'`, `'syncNow'`.
23
+ * When the animation step is created from an element in a figure (using
24
+ * `element.animations` or `element.animations.new()`), then the
25
+ * animation step will automatically inherit the figure's TimeKeeper.
26
+ * @interface
27
+ * @group Misc Animation
28
+ */
29
+ export type OBJ_AnimationStep = {
30
+ onFinish?: ((cancelled: boolean) => void) | null;
31
+ completeOnCancel?: boolean | null;
32
+ removeOnFinish?: boolean;
33
+ name?: string;
34
+ duration?: number;
35
+ delay?: number;
36
+ precision?: number;
37
+ timeKeeper?: TimeKeeper | null;
38
+ };
39
+ /**
40
+ * Animation step base class. All animation steps extend this class.
41
+ *
42
+ * @property {number} duration in seconds
43
+ * @property {number} startDelay delay before animation starts in seconds
44
+ * @property {string} name animation name identifier
45
+ * @property {null | (boolean) => void} [onFinish] called when animation is
46
+ * finished - a `true` parameter is passed to the callback if the animation was
47
+ * cancelled
48
+ * @property {null | boolean} [completeOnCancel] `true` to skip to end of
49
+ * animation on cancel
50
+ * @property {boolean} [removeOnFinish] `true` to remove the animation from the
51
+ * animation manager when it is finished (`true`)
52
+ * @property {number} [precision] precision to do calculations to (`8`)
53
+ * @property {'animating' | 'waitingToStart' | 'idle' | 'finished'} state
54
+ * @group Misc Animation
55
+ */
56
+ export default class AnimationStep {
57
+ startTime: number | null | undefined;
58
+ duration: number;
59
+ onFinish: (string | ((cancelled: boolean) => void)) | null | undefined;
60
+ completeOnCancel: boolean | null | undefined;
61
+ state: 'animating' | 'waitingToStart' | 'idle' | 'finished';
62
+ startTimeOffset: number;
63
+ removeOnFinish: boolean;
64
+ name: string;
65
+ startDelay: number;
66
+ beforeFrame: ((percent: number) => void) | null | undefined;
67
+ afterFrame: ((percent: number) => void) | null | undefined;
68
+ _stepType: string;
69
+ fnMap: FunctionMap;
70
+ precision: number;
71
+ timeKeeper: TimeKeeper | null;
72
+ element: FigureElement | null | undefined;
73
+ constructor(optionsIn?: OBJ_AnimationStep);
74
+ _fromDef(definition: Record<string, any>, getElement?: ((name: string) => FigureElement) | null): this;
75
+ fnExec(idOrFn: string | Function | null, ...args: any): any;
76
+ setTimeDelta(delta: number | null | undefined): void;
77
+ _getStateProperties(): string[];
78
+ _getStateName(): string;
79
+ _state(options: Record<string, any>): {
80
+ f1Type: string;
81
+ state: Record<string, any>;
82
+ };
83
+ _fromState(state: Record<string, any>, getElement: ((name: string) => FigureElement) | null | undefined, timeKeeper: TimeKeeper): this;
84
+ setTimeSpeed(oldSpeed: number, newSpeed: number, now: number): void;
85
+ nextFrame(now: number, speed?: number): number | null;
86
+ /**
87
+ * Get remaining duration of the animation.
88
+ * @param {number} now define this if you want remaining duration from a
89
+ * custom time
90
+ */
91
+ getRemainingTime(now: number): number | null;
92
+ getTotalDuration(): number | null;
93
+ setFrame(deltaTime: number): void;
94
+ startWaiting(): void;
95
+ /**
96
+ * Start animation
97
+ * @param {AnimationStartTime} startTime
98
+ */
99
+ start(startTime?: AnimationStartTime | null): void;
100
+ finishIfZeroDuration(): void;
101
+ setToEnd(): void;
102
+ finish(cancelled?: boolean, force?: 'complete' | 'freeze' | null): void;
103
+ cancelledWithNoComplete(): void;
104
+ cancel(force?: 'complete' | 'freeze' | null): void;
105
+ _dup(): AnimationStep;
106
+ whenFinished(callback: string | ((cancelled: boolean) => void)): this;
107
+ ifCanceledThenComplete(): this;
108
+ ifCancelled(then?: 'complete' | 'freeze'): this;
109
+ ifCanceledThenStop(): this;
110
+ }
@@ -0,0 +1,9 @@
1
+ declare class DrawContext2D {
2
+ canvas: HTMLCanvasElement;
3
+ ctx: CanvasRenderingContext2D;
4
+ ratio: number;
5
+ constructor(canvas: HTMLCanvasElement);
6
+ resize(): void;
7
+ _dup(): this;
8
+ }
9
+ export default DrawContext2D;
@@ -0,0 +1,45 @@
1
+ import { Point } from '../../tools/g2';
2
+ import type { Type3DMatrix } from '../../tools/m3';
3
+ import type Scene from '../../tools/geometry/scene';
4
+ import type { TypeColor } from '../../tools/types';
5
+ import type { CPY_Step } from '../geometries/copy/copy';
6
+ import type WebGLInstance from '../webgl/webgl';
7
+ /**
8
+ * Drawing Object
9
+ *
10
+ * Manages drawing an element to a WebGL or Context 2D canvas. Can also
11
+ * be used to manage a HTML element on the screen.
12
+ *
13
+ * @property {Array<Array<Point>>} border each array of points defines a
14
+ * closed boundary or border of the element. An element may have multiple
15
+ * closed borders. A border defines where a shape can be touched, or how it
16
+ * bounces of figure boundaries
17
+ * @see {@link FigureElementPrimitive}
18
+ * @group Misc Figure Element
19
+ */
20
+ declare class DrawingObject {
21
+ location: Point;
22
+ border: Array<Array<Point>>;
23
+ textBorder: Array<Array<Point>>;
24
+ textBorderBuffer: Array<Array<Point>>;
25
+ type: string;
26
+ state: 'loading' | 'loaded';
27
+ constructor();
28
+ _dup(): this;
29
+ setText(textOrOptions: string | Record<string, any>, index?: number): void;
30
+ update(options: Record<string, any>): void;
31
+ getCanvas(): any;
32
+ drawWithTransformMatrix(scene: Scene, transformMatrix: Type3DMatrix, color: TypeColor, numPoints: number, targetTexture?: boolean): void;
33
+ getLocation(transformMatrix?: Type3DMatrix | null): Point;
34
+ getPointCountForAngle(): number;
35
+ updateVertices(vertices: Array<number>): void;
36
+ updateBuffer(name: string, data: Array<number>): void;
37
+ updateUniform(uniformName: string, value: number | Array<number>): void;
38
+ getUniform(uniformName: string): void;
39
+ cleanup(): void;
40
+ change(drawingPrimitive: any, copy?: Array<CPY_Step>): void;
41
+ _getStateProperties(): never[];
42
+ _state(options: Record<string, any>): Record<string, any>;
43
+ init(webgl: WebGLInstance): void;
44
+ }
45
+ export default DrawingObject;