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,392 @@
1
+ import { FigureElement } from '../Element';
2
+ import * as anim from './Animation';
3
+ import type { Recorder } from '../Recorder/Recorder';
4
+ import type { AnimationStep, OBJ_AnimationBuilder, OBJ_AnimationStep, OBJ_RotationAnimationStep, OBJ_ScaleAnimationStep, OBJ_TriggerAnimationStep, OBJ_PositionAnimationStep, OBJ_ColorAnimationStep, OBJ_OpacityAnimationStep, OBJ_TransformAnimationStep, OBJ_PulseTransformAnimationStep, OBJ_PulseAnimationStep, OBJ_ElementAnimationStep, OBJ_ScenarioAnimationStep, OBJ_ScenariosAnimationStep, OBJ_CustomAnimationStep } from './Animation';
5
+ import TimeKeeper from '../TimeKeeper';
6
+ import { NotificationManager } from '../../tools/tools';
7
+ import { FunctionMap } from '../../tools/FunctionMap';
8
+ import type { TypeWhen } from '../TimeKeeper';
9
+ import type { TypeParsablePoint, TypeParsableTransform } from '../../tools/g2';
10
+ import type { TypeColor } from '../../tools/types';
11
+ import type { OBJ_Scenario } from '../Element';
12
+ /**
13
+ * Animation start time options.
14
+ *
15
+ * {@link TypeWhen} | number | null
16
+ *
17
+ * When multiple animations need to be started, it is often
18
+ * desirable to synchronise their start times.
19
+ *
20
+ * `'nextFrame'` will start the animation on the
21
+ * next animation frame. Starting several animations with `nextFrame`
22
+ * will ensure they are all synchronized to that frame time.
23
+ *
24
+ * Similarly `'prevFrame'` starts the animation on the last animation
25
+ * frame.
26
+ *
27
+ * `'syncNow'` will start an animation at a synchronized 'now' time. The
28
+ * first time 'syncNow' is used, the current time will be stored and used
29
+ * for all subsequent calls to 'syncNow'. 'syncNow' is reset every
30
+ * time a new animation frame is drawn.
31
+ *
32
+ * Alternately, `'now'` can be used which will use the current time as
33
+ * the animation start time. As javascript is single threaded, using `'now`
34
+ * on multiple animations will result in them all having slightly different
35
+ * start times.
36
+ *
37
+ * A custom time can be used if a `number` is defined.
38
+ *
39
+ * `null` will result in `'nextFrame'` being used
40
+ * @typedef {TypeWhen | number | null} AnimationStartTime
41
+ * @group Misc Animation
42
+ */
43
+ export type AnimationStartTime = TypeWhen | number | null;
44
+ /**
45
+ * Start animation options object.
46
+ *
47
+ * @property {null | string} [name] name of animation to start - f null, then
48
+ * all animations associated with this animation manager will start (`null`)
49
+ * @property {AnimationStartTime} startTime when to
50
+ * start the animation
51
+ * @interface
52
+ * @group Misc Animation
53
+ */
54
+ export type OBJ_AnimationStart = {
55
+ name?: string;
56
+ startTime: AnimationStartTime;
57
+ };
58
+ export type TypeAnimationManagerInputOptions = {
59
+ element?: FigureElement;
60
+ finishedCallback?: (string | (() => void)) | null;
61
+ recorder?: Recorder;
62
+ timeKeeper: TimeKeeper;
63
+ };
64
+ /**
65
+ * Animation Manager
66
+ *
67
+ * This class manages animations and creates animation steps for use in
68
+ * animations.
69
+ *
70
+ * Each {@link FigureElement} has its own `AnimationManager` in the
71
+ * `animations` property, though any
72
+ * animation manager can animate any other element. Therefore all parallel
73
+ * animations can go through the same manager, or be spread throughout
74
+ * different element's animation managers. Spread animations out between
75
+ * elements, or keeping them all in one `AnimationManager` can change how
76
+ * readable code is, how convenient it is to cancel running animations, and
77
+ * what order the animations are performed in (`AnimationManager`s tied
78
+ * to elements drawn earlier will perform their animation steps before those
79
+ * tied to elements drawn later). `AnimationManager`s will only be processed
80
+ * on each animation frame if the element they are tied to is not hidden.
81
+ *
82
+ * The `animations` property within `AnimationManager` is simply an array that
83
+ * contains a number {@link AnimationStep}s that are executed in parallel.
84
+ * Typically, these steps would themselves be {@link SerialAnimationStep}s or a
85
+ * series of animations. This means the animation manager is running a number of
86
+ * animation series in parallel.
87
+ *
88
+ *
89
+ * The `AnimationManager`s on {@link FigureElement}s should be used instead
90
+ * of instantiating this class separately, as those on `FigureElements` will
91
+ * be automatically processed every animation frame.
92
+ *
93
+ * @param
94
+ * @property {'animating' | 'idle' | 'waitingToStart'} state
95
+ * @property {Array<AnimationStep>} animations
96
+ * @property {NotificationManager} notifications
97
+ * @see {@link FigureElement}
98
+ * @see {@link AnimationBuilder}
99
+ * @example
100
+ * // At its heart the `AnimationManager` is just executing
101
+ * // an array of animation steps.
102
+ *
103
+ * // Create animation steps
104
+ * const position = new Fig.Animation.PositionAnimationStep({
105
+ * element: p,
106
+ * target: [1, 0],
107
+ * duration: 2,
108
+ * });
109
+ * const rotation = new Fig.Animation.RotationAnimationStep({
110
+ * element: p,
111
+ * target: Math.PI,
112
+ * duration: 2,
113
+ * });
114
+ *
115
+ * // Combine the animations into a SerialAnimationStep
116
+ * const series = new Fig.Animation.SerialAnimationStep([
117
+ * position,
118
+ * rotation,
119
+ * ]);
120
+ *
121
+ * // Add the animations to the animation manager and start
122
+ * p.animations.animations.push(series);
123
+ * p.animations.start();
124
+ *
125
+ * @example
126
+ * // Using the `new` method in `AnimationManager` creates a convenient
127
+ * // `AnimationBuilder` which extends a `SerialAnimationStep` by using
128
+ * // a fluent API pattern
129
+ * //
130
+ * // Create animation steps
131
+ * const position = new Fig.Animation.PositionAnimationStep({
132
+ * element: p,
133
+ * target: [1, 0],
134
+ * duration: 2,
135
+ * });
136
+ * const rotation = new Fig.Animation.RotationAnimationStep({
137
+ * element: p,
138
+ * target: Math.PI,
139
+ * duration: 2,
140
+ * });
141
+ *
142
+ * // Build and start the animation
143
+ * p.animations.new()
144
+ * .then(position)
145
+ * .then(rotation)
146
+ * .start();
147
+ *
148
+ * @example
149
+ * // `AnimationStep`s can also be created from the `AnimationManager`
150
+ * // with the added convenience that the `FigureElement` that
151
+ * // has the `AnimationManager` will be used as the default
152
+ * // `element` property. This combined with the `AnimationBuilder`
153
+ * // makes defining most animations clean and readable code
154
+ *
155
+ * // Build and start the animation
156
+ * p.animations.new()
157
+ * .position({ target: [1, 0], duration: 2 })
158
+ * .rotation({ target: Math.PI, duration: 2 })
159
+ * .start();
160
+ *
161
+ * @example
162
+ * // Parallel animations however still need to use explicit animation steps.
163
+ * // Creating the steps from the `AnimationManager` means the `element` doesn't
164
+ * // need to be defined.
165
+ * //
166
+ * p.animations.new()
167
+ * .inParallel([
168
+ * p.animations.position({ target: [1, 0], duration: 2 }),
169
+ * p.animations.rotation({ target: Math.PI, duration: 2 })
170
+ * ])
171
+ * .start();
172
+ * @group Animation
173
+ */
174
+ export default class AnimationManager {
175
+ element: FigureElement | null | undefined;
176
+ animations: Array<anim.AnimationStep>;
177
+ state: 'animating' | 'idle' | 'waitingToStart';
178
+ fnMap: FunctionMap;
179
+ finishedCallback: (string | (() => void)) | null;
180
+ notifications: NotificationManager;
181
+ options: {
182
+ translation?: {
183
+ style: 'curve' | 'linear';
184
+ angle: number;
185
+ magnitude: number;
186
+ offset: number;
187
+ controlPoint: TypeParsablePoint | null;
188
+ direction: 'positive' | 'negative' | 'up' | 'down' | 'left' | 'right';
189
+ };
190
+ };
191
+ recorder: Recorder;
192
+ timeKeeper: TimeKeeper;
193
+ animationSpeed: number;
194
+ customSteps: Array<{
195
+ step: (options: Record<string, any>) => AnimationStep;
196
+ name: string;
197
+ }>;
198
+ /**
199
+ * @hideconstructor
200
+ */
201
+ constructor(elementOrOptionsIn?: FigureElement | TypeAnimationManagerInputOptions, ...optionsIn: Array<TypeAnimationManagerInputOptions>);
202
+ /**
203
+ * New animation builder attached to this animation manager
204
+ * @return AnimationBuilder
205
+ * @example
206
+ * p.animations.new()
207
+ * .position({ target: [0.5, 0], duration: 2 })
208
+ * .rotation({ target: Math.PI, duration: 2 })
209
+ * .start();
210
+ *
211
+ */
212
+ new(name?: string | null): anim.AnimationBuilder;
213
+ /**
214
+ * Set time speed of animation relative to real time, where 1 is real time,
215
+ * <1 is slower than real time and >1 is faster than real time.
216
+ *
217
+ * @param {number} speed
218
+ */
219
+ setTimeSpeed(speed?: number): void;
220
+ /**
221
+ * Animation builder object
222
+ * @param {OBJ_AnimationBuilder} options
223
+ * @return {AnimationBuilder}
224
+ */
225
+ builder(...options: Array<OBJ_AnimationBuilder>): anim.AnimationBuilder;
226
+ /**
227
+ * Create a Rotation animation step that uses this element by default
228
+ * @param {OBJ_RotationAnimationStep} options
229
+ * @return {RotationAnimationStep}
230
+ * @example
231
+ * const rot = p.animations.rotation({ target: Math.PI, duration: 2 });
232
+ * p.animations.new()
233
+ * .then(rot)
234
+ * .start();
235
+ */
236
+ rotation(targetOrOptions: OBJ_RotationAnimationStep | number): any;
237
+ /**
238
+ * Create a Scale animation step tied to this element
239
+ * @param {TypeParsablePoint | OBJ_ScaleAnimationStep | number} targetOrOptionsOrX
240
+ * when a number is used, it will apply to both x and y if y is null
241
+ * @param {number | null} y use a number to define the y scale, or use null
242
+ * to use the `x` value (`null`)
243
+ * @return {ScaleAnimationStep}
244
+ */
245
+ scale(targetOrOptionsOrX: TypeParsablePoint | OBJ_ScaleAnimationStep | number, y?: null | number, z?: number): any;
246
+ /**
247
+ * Create a Trigger animation step
248
+ * @param {OBJ_TriggerAnimationStep | function(): void | string} callbackOrOptions
249
+ * callback can be a function or an id to a function map
250
+ * @return {TriggerAnimationStep}
251
+ */
252
+ trigger(callbackOrOptions: (() => void) | string | OBJ_TriggerAnimationStep): anim.TriggerAnimationStep;
253
+ /**
254
+ * Add a custom animation step that uses this element by default
255
+ * @param {string | ((number) => void) | OBJ_CustomAnimationStep} callbackOrOptions
256
+ * @return {AnimationBuilder}
257
+ */
258
+ custom(callbackOrOptions: string | ((percent: number) => void) | OBJ_CustomAnimationStep): anim.CustomAnimationStep;
259
+ /**
260
+ * Create a Delay animation step
261
+ * Use the `duration` value in `options` to define delay duration
262
+ * @param {number | OBJ_AnimationStep} delayOrOptions
263
+ * @return {DelayAnimationStep}
264
+ */
265
+ delay(delayOrOptions?: number | OBJ_AnimationStep): anim.DelayAnimationStep;
266
+ /**
267
+ * Create a Translation or Position animation step tied to this element
268
+ * @param {OBJ_PositionAnimationStep | TypeParsablePoint | number} targetOrOptionsOrX
269
+ * @param {number} y define if `targetOrOptionsOrX` is x (number)
270
+ * @return {PositionAnimationStep}
271
+ */
272
+ translation(targetOrOptionsOrX: TypeParsablePoint | OBJ_PositionAnimationStep | number, y?: number, z?: number): void;
273
+ /**
274
+ * Create a Translation or Position animation step tied to this element
275
+ * @param {OBJ_PositionAnimationStep | TypeParsablePoint | number} targetOrOptionsOrX
276
+ * @param {number} y define if `targetOrOptionsOrX` is x (number)
277
+ * @return {PositionAnimationStep}
278
+ */
279
+ position(targetOrOptionsOrX: TypeParsablePoint | OBJ_PositionAnimationStep | number, y?: number, z?: number): any;
280
+ /**
281
+ * Create a Color animation step tied to this element
282
+ * @param {OBJ_ColorAnimationStep | TypeColor} colorOrOptions
283
+ * @return {ColorAnimationStep}
284
+ */
285
+ color(colorOrOptions: OBJ_ColorAnimationStep | TypeColor): any;
286
+ /**
287
+ * Create a Opacity animation step tied to this element
288
+ * @param {OBJ_OpacityAnimationStep | number} opacityOrOptions
289
+ * @return {OpacityAnimationStep}
290
+ */
291
+ opacity(opacityOrOptions: OBJ_OpacityAnimationStep | number): any;
292
+ /**
293
+ * Create a Transform animation step tied to this element
294
+ * @param {OBJ_TransformAnimationStep | TypeParsableTransform} transformOrOptions
295
+ * @return {TransformAnimationStep}
296
+ */
297
+ transform(transformOrOptions: OBJ_TransformAnimationStep | TypeParsableTransform): any;
298
+ pulseTransform(...options: Array<OBJ_PulseTransformAnimationStep>): any;
299
+ /**
300
+ * Create a pulse animation step tied to this element
301
+ * @param {OBJ_PulseAnimationStep | number} scaleOrOptions pulse scale
302
+ * (number) or pulse animation step options
303
+ * @return {PulseAnimationStep}
304
+ */
305
+ pulse(scaleOrOptions: OBJ_PulseAnimationStep | number): any;
306
+ /**
307
+ * Create a Dissolve in animation step
308
+ * Use the `duration` value in `options` to define dissolving duration
309
+ * @param {number | OBJ_ElementAnimationStep} timeOrOptions
310
+ * @return {DissolveInAnimationStep}
311
+ */
312
+ dissolveIn(durationOrOptions?: number | OBJ_ElementAnimationStep): any;
313
+ /**
314
+ * Create a Dissolve out animation step
315
+ * Use the `duration` value in `options` to define dissolving duration
316
+ * @param {number | OBJ_ElementAnimationStep} durationOrOptions
317
+ * @return {DissolveOutAnimationStep}
318
+ */
319
+ dissolveOut(durationOrOptions?: number | OBJ_ElementAnimationStep): any;
320
+ /**
321
+ * Create a Dim color animation step
322
+ * Use the `duration` value in `options` to define dimming duration
323
+ * @param {number | OBJ_ElementAnimationStep} durationOrOptions
324
+ * @return {DimAnimationStep}
325
+ */
326
+ dim(durationOrOptions?: number | OBJ_ElementAnimationStep): any;
327
+ /**
328
+ * Create a Undim color animation step
329
+ * Use the `duration` value in `options` to define undimming duration
330
+ * @param {number | OBJ_ElementAnimationStep} durationOrOptions
331
+ * @return {UndimAnimationStep}
332
+ */
333
+ undim(durationOrOptions?: number | OBJ_ColorAnimationStep): any;
334
+ getStep(options: Record<string, any>, animName: string): any;
335
+ /**
336
+ * Create a Scenario animation step tied to this element
337
+ * @param {OBJ_ScenarioAnimationStep | OBJ_Scenario | string} scenarioOrOptions
338
+ * @return {ScenarioAnimationStep}
339
+ */
340
+ scenario(scenarioOrOptions: string | OBJ_Scenario | OBJ_ScenarioAnimationStep): any;
341
+ /**
342
+ * Create a Parallel animation step that animates
343
+ * all child elements with the target scenario name
344
+ * @param {string | OBJ_ScenariosAnimationStep} scenarioNameOrOptions
345
+ * @return {ParallelAnimationStep}
346
+ */
347
+ scenarios(scenarioOrOptions: string | OBJ_ScenariosAnimationStep): anim.ParallelAnimationStep;
348
+ _state(options: Record<string, any>): Record<string, any>;
349
+ setTimeDelta(delta: number | null | undefined): void;
350
+ willStartAnimating(): boolean;
351
+ isAnimating(): boolean;
352
+ nextFrame(now: number): number | null;
353
+ cleanAnimations(): void;
354
+ /**
355
+ * Cancel one or all animations managed by this manager (in the `animations`
356
+ * array).
357
+ * @param {null | string} name name of animation or `null` to cancel all
358
+ * (`null`)
359
+ * @param {null | 'complete' | 'freeze'} force force the animation to complete
360
+ * or freeze - `null` will perform the default operation (`null`)
361
+ */
362
+ cancel(name?: string | null | undefined, force?: 'complete' | 'freeze' | null): void;
363
+ /**
364
+ * Get an animation by name.
365
+ @param {string} name
366
+ @return {AnimationStep | null}
367
+ */
368
+ get(name: string): anim.AnimationStep | null;
369
+ cancelAll(how?: 'complete' | 'freeze' | null, force?: boolean): void;
370
+ getFrameTime(frame: 'nextFrame' | 'prevFrame' | 'now' | 'syncNow'): void;
371
+ /**
372
+ * Start one or all animations managed by this manager (in the `animations`
373
+ * array).
374
+ *
375
+ * @param {OBJ_AnimationStart} [options]
376
+ */
377
+ start(options: OBJ_AnimationStart): void;
378
+ startAll(optionsIn: {
379
+ startTime?: AnimationStartTime;
380
+ }): void;
381
+ getTotalDuration(): number | null;
382
+ /**
383
+ * Get remaining duration of all animations
384
+ * @param {number} now define this if you want remaining duration from a
385
+ * custom time
386
+ */
387
+ getRemainingTime(animationNames?: Array<string> | string, now?: number): number;
388
+ getNextAnimationFinishTime(now?: number): null | number;
389
+ addTo(name: string): anim.AnimationStep | anim.AnimationBuilder;
390
+ newFromStep(nameOrStep: anim.AnimationStep): anim.AnimationStep;
391
+ _dup(): anim.AnimationManager;
392
+ }
@@ -0,0 +1,99 @@
1
+ import type { OBJ_AnimationStep } from '../AnimationStep';
2
+ import AnimationStep from '../AnimationStep';
3
+ import type { AnimationStartTime } from '../AnimationManager';
4
+ /**
5
+ * {@link CustomAnimationStep} options object
6
+ *
7
+ * @extends OBJ_AnimationStep
8
+ *
9
+ * @property {string | function(int): void} callback function to run each
10
+ * animation frame
11
+ * @property {number} [startPercent] percent to start animation at (`0`)
12
+ * @property {'linear' | 'easeinout' | 'easein' | 'easeout' | AnimationProgression} [progression]
13
+ * @interface
14
+ * @group Misc Animation
15
+ */
16
+ export type OBJ_CustomAnimationStep = {
17
+ callback?: string | ((percent: number) => void);
18
+ startPercent?: number;
19
+ progression?: 'linear' | 'easeinout' | 'easein' | 'easeout' | ((percent: number) => number);
20
+ duration?: number | null;
21
+ } & OBJ_AnimationStep;
22
+ /**
23
+ * Custom animation step
24
+ *
25
+ * ![](./apiassets/custom_animation.gif)
26
+ *
27
+ * Custom animation steps are useful for orchestrating complex animations, or
28
+ * performing non-linear animations.
29
+ *
30
+ * This step will execute a custom callback function on each animation frame.
31
+ * Custom animations can either have finite `duration` or infinite
32
+ * (`duration` = `null`). If finite, the callback function will be passed
33
+ * percentage progress through the duration. If infinite, the callback function
34
+ * will be passed the delta time from the start of the animation.
35
+ *
36
+ * The animation can be stopped at any time by returning `true` from the
37
+ * callback funciton/
38
+ *
39
+ * For finite durations, the percentage progress can either be linear with
40
+ * time, or non-linear.
41
+ * Built-in non-linear progressions are `'easeinout'`, `'easein`' and
42
+ * `'easeout'` which will slow progress at the start and/or end of the
43
+ * animation. A function to create a custom non-linear progressor can also be
44
+ * used.
45
+ *
46
+ * @extends AnimationStep
47
+ *
48
+ * @param {OBJ_CustomAnimationStep} options
49
+ *
50
+ * @see To test examples, append them to the
51
+ * <a href="#animation-boilerplate">boilerplate</a>
52
+ *
53
+ * @example
54
+ * // Move an object through a sine wave of wavelength 1 from
55
+ * // x = -1 to x = 1
56
+ * function sine(percentComplete) {
57
+ * const x = -1 + percentComplete * 2;
58
+ * const y = 0.5 * Math.sin(Math.PI * 2 * x);
59
+ * p.setPosition(x, y);
60
+ * }
61
+ *
62
+ * p.animations.new()
63
+ * .custom({ callback: sine, duration: 5 })
64
+ * .start();
65
+ *
66
+ * @example
67
+ * // Animate a object in a circle indefinitely at a frequency of 0.1Hz
68
+ * p.animations.new()
69
+ * .custom({
70
+ * callback: (t) => {
71
+ * const x = 0.5 * Math.cos(2 * Math.PI * 0.1 * t);
72
+ * const y = 0.5 * Math.sin(2 * Math.PI * 0.1 * t);
73
+ * p.setPosition(x, y);
74
+ * },
75
+ * duration: null,
76
+ * })
77
+ * .start();
78
+ * @group Animation
79
+ */
80
+ export declare class CustomAnimationStep extends AnimationStep {
81
+ callback: ((percent: number) => void) | null;
82
+ startPercent: number | null | undefined;
83
+ progression: string | ((percent: number, invert?: boolean) => number);
84
+ customProperties: Record<string, any>;
85
+ isInfinite: boolean;
86
+ /**
87
+ * @hideconstructor
88
+ */
89
+ constructor(...optionsIn: Array<OBJ_CustomAnimationStep>);
90
+ fnExec(idOrFn: string | Function | null, ...args: any): any;
91
+ start(startTime?: AnimationStartTime | null): void;
92
+ _getStateProperties(): string[];
93
+ _getStateName(): string;
94
+ setFrame(deltaTime: number): void;
95
+ getPercentComplete(percentTime: number, invert?: boolean): any;
96
+ setToEnd(): void;
97
+ _dup(): CustomAnimationStep;
98
+ }
99
+ export declare function custom(...optionsIn: Array<OBJ_CustomAnimationStep>): CustomAnimationStep;
@@ -0,0 +1,24 @@
1
+ import type { OBJ_AnimationStep } from '../AnimationStep';
2
+ import AnimationStep from '../AnimationStep';
3
+ import type { AnimationStartTime } from '../AnimationManager';
4
+ /**
5
+ * Delay animation step
6
+ *
7
+ * While all animations steps accept a delay property,
8
+ * having this step sometimes makes the animation seem
9
+ * more readable.
10
+ *
11
+ * @param {number | OBJ_AnimationStep} delayOrOptions
12
+ * @extends AnimationStep
13
+ * @group Animation
14
+ */
15
+ export declare class DelayAnimationStep extends AnimationStep {
16
+ /**
17
+ * @hideconstructor
18
+ */
19
+ constructor(numOrOptions?: number | OBJ_AnimationStep, ...args: Array<OBJ_AnimationStep>);
20
+ _dup(): DelayAnimationStep;
21
+ start(startTime?: AnimationStartTime | null): void;
22
+ _getStateName(): string;
23
+ }
24
+ export declare function delay(numOrOptionsIn?: number | OBJ_AnimationStep, ...args: Array<OBJ_AnimationStep>): DelayAnimationStep;