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,36 @@
1
+ import type { OBJ_PositionAnimationStep } from './AnimationStep/ElementAnimationStep/PositionAnimationStep';
2
+ import PositionAnimationStep from './AnimationStep/ElementAnimationStep/PositionAnimationStep';
3
+ import type { OBJ_ScenarioAnimationStep, OBJ_ScenariosAnimationStep } from './AnimationStep/ElementAnimationStep/ScenarioAnimationStep';
4
+ import ScenarioAnimationStep from './AnimationStep/ElementAnimationStep/ScenarioAnimationStep';
5
+ import type { OBJ_ColorAnimationStep } from './AnimationStep/ElementAnimationStep/ColorAnimationStep';
6
+ import { ColorAnimationStep, DimAnimationStep, UndimAnimationStep, dim, undim } from './AnimationStep/ElementAnimationStep/ColorAnimationStep';
7
+ import type { OBJ_OpacityAnimationStep } from './AnimationStep/ElementAnimationStep/OpacityAnimationStep';
8
+ import { OpacityAnimationStep, DissolveInAnimationStep, dissolveIn, DissolveOutAnimationStep, dissolveOut } from './AnimationStep/ElementAnimationStep/OpacityAnimationStep';
9
+ import type { OBJ_TransformAnimationStep } from './AnimationStep/ElementAnimationStep/TransformAnimationStep';
10
+ import TransformAnimationStep from './AnimationStep/ElementAnimationStep/TransformAnimationStep';
11
+ import type { OBJ_PulseTransformAnimationStep } from './AnimationStep/ElementAnimationStep/PulseTransformAnimationStep';
12
+ import PulseTransformAnimationStep from './AnimationStep/ElementAnimationStep/PulseTransformAnimationStep';
13
+ import type { OBJ_RotationAnimationStep } from './AnimationStep/ElementAnimationStep/RotationAnimationStep';
14
+ import RotationAnimationStep from './AnimationStep/ElementAnimationStep/RotationAnimationStep';
15
+ import type { OBJ_ScaleAnimationStep } from './AnimationStep/ElementAnimationStep/ScaleAnimationStep';
16
+ import ScaleAnimationStep from './AnimationStep/ElementAnimationStep/ScaleAnimationStep';
17
+ import type { OBJ_PulseAnimationStep } from './AnimationStep/ElementAnimationStep/PulseAnimationStep';
18
+ import PulseAnimationStep from './AnimationStep/ElementAnimationStep/PulseAnimationStep';
19
+ import type { OBJ_TriggerAnimationStep } from './AnimationStep/TriggerStep';
20
+ import { TriggerAnimationStep, trigger } from './AnimationStep/TriggerStep';
21
+ import type { OBJ_CustomAnimationStep } from './AnimationStep/CustomStep';
22
+ import { CustomAnimationStep, custom } from './AnimationStep/CustomStep';
23
+ import type { OBJ_ElementAnimationStep } from './AnimationStep/ElementAnimationStep';
24
+ import type { OBJ_ParallelAnimationStep } from './AnimationStep/ParallelAnimationStep';
25
+ import { ParallelAnimationStep, inParallel } from './AnimationStep/ParallelAnimationStep';
26
+ import type { OBJ_SerialAnimationStep } from './AnimationStep/SerialAnimationStep';
27
+ import { SerialAnimationStep, inSerial } from './AnimationStep/SerialAnimationStep';
28
+ import { DelayAnimationStep, delay } from './AnimationStep/DelayStep';
29
+ import type { OBJ_AnimationStep } from './AnimationStep';
30
+ import AnimationStep from './AnimationStep';
31
+ import type { TypeAnimationManagerInputOptions } from './AnimationManager';
32
+ import AnimationManager from './AnimationManager';
33
+ import type { OBJ_AnimationBuilder } from './AnimationBuilder';
34
+ import AnimationBuilder from './AnimationBuilder';
35
+ export type { OBJ_PositionAnimationStep, OBJ_AnimationBuilder, OBJ_ParallelAnimationStep, OBJ_SerialAnimationStep, OBJ_TransformAnimationStep, OBJ_AnimationStep, OBJ_TriggerAnimationStep, OBJ_ColorAnimationStep, OBJ_CustomAnimationStep, TypeAnimationManagerInputOptions, OBJ_RotationAnimationStep, OBJ_ScaleAnimationStep, OBJ_PulseAnimationStep, OBJ_OpacityAnimationStep, OBJ_ScenarioAnimationStep, OBJ_PulseTransformAnimationStep, OBJ_ElementAnimationStep, OBJ_ScenariosAnimationStep, };
36
+ export { PositionAnimationStep, AnimationBuilder, ParallelAnimationStep, SerialAnimationStep, TransformAnimationStep, AnimationStep, DelayAnimationStep, TriggerAnimationStep, inParallel, inSerial, trigger, delay, ColorAnimationStep, DissolveInAnimationStep, dissolveIn, DissolveOutAnimationStep, dissolveOut, CustomAnimationStep, custom, AnimationManager, RotationAnimationStep, ScaleAnimationStep, PulseAnimationStep, OpacityAnimationStep, DimAnimationStep, dim, UndimAnimationStep, undim, ScenarioAnimationStep, PulseTransformAnimationStep, };
@@ -0,0 +1,173 @@
1
+ import { FigureElement } from '../Element';
2
+ import type { OBJ_Scenario } from '../Element';
3
+ import type { OBJ_SerialAnimationStep } from './AnimationStep/SerialAnimationStep';
4
+ import type { OBJ_PositionAnimationStep, OBJ_ParallelAnimationStep, OBJ_AnimationStep, OBJ_TriggerAnimationStep, OBJ_ColorAnimationStep, OBJ_CustomAnimationStep, OBJ_TransformAnimationStep, OBJ_RotationAnimationStep, OBJ_ScaleAnimationStep, OBJ_PulseAnimationStep, OBJ_OpacityAnimationStep, OBJ_PulseTransformAnimationStep, AnimationStep, OBJ_ScenarioAnimationStep, OBJ_ElementAnimationStep, OBJ_ScenariosAnimationStep } from './Animation';
5
+ import type { TypeParsablePoint, TypeParsableTransform } from '../../tools/g2';
6
+ import * as animation from './Animation';
7
+ import type { TypeColor } from '../../tools/types';
8
+ /**
9
+ * Animation builder options object
10
+ * @extends OBJ_SerialAnimationStep
11
+ * @property {FigureElement} [element]
12
+ * @interface
13
+ * @group Misc Animation
14
+ */
15
+ export type OBJ_AnimationBuilder = {
16
+ element?: FigureElement;
17
+ customSteps?: Array<{
18
+ step: (options: Record<string, any>) => AnimationStep;
19
+ name: string;
20
+ }>;
21
+ } & OBJ_SerialAnimationStep;
22
+ /**
23
+ * Animation Builder
24
+ *
25
+ * Convenient way to build animation steps in serial. Each step returns the
26
+ * same builder object, and so chaining in a fluent like API can be achieved.
27
+ *
28
+ * @extends SerialAnimationStep
29
+ * @see <a href="#animationmanagernew">AnimationManager.new</a>
30
+ *
31
+ * @example
32
+ * p.animations.new()
33
+ * .delay(1)
34
+ * .position({ target: [1, 0], duration: 2 })
35
+ * .delay(1)
36
+ * .rotation({ target: Math.PI, duration: 2 })
37
+ * .start();
38
+ * @group Animation
39
+ */
40
+ export default class AnimationBuilder extends animation.SerialAnimationStep {
41
+ /**
42
+ * @hideconstructor
43
+ */
44
+ constructor(elementOrOptions?: FigureElement | OBJ_AnimationBuilder, ...options: Array<OBJ_AnimationBuilder>);
45
+ fnExec(idOrFn: string | Function | null, ...args: any): any;
46
+ _getStateProperties(): string[];
47
+ _getStateName(): string;
48
+ /**
49
+ * Add a custom animation step that uses this element by default
50
+ * @param {string | ((number) => void) | OBJ_CustomAnimationStep} callbackOrOptions
51
+ * @return {AnimationBuilder}
52
+ */
53
+ custom(callbackOrOptions: string | ((percent: number) => void) | OBJ_CustomAnimationStep): this;
54
+ /**
55
+ * Add a rotation animation step that uses this element by default
56
+ * @param {OBJ_RotationAnimationStep | number} targetOrOptions
57
+ * @return {AnimationBuilder}
58
+ */
59
+ rotation(targetOrOptions: OBJ_RotationAnimationStep | number, ry?: number | null, rz?: number): this;
60
+ /**
61
+ * Add a position animation step that uses this element by default
62
+ * @param {TypeParsablePoint | OBJ_PositionAnimationStep | number} targetOrOptionsOrX
63
+ * @param {number} y define if `targetOrOptionsOrX` is x (number)
64
+ * @return {AnimationBuilder}
65
+ */
66
+ position(targetOrOptionsOrX: TypeParsablePoint | OBJ_PositionAnimationStep | number, y?: number, z?: number): this;
67
+ /**
68
+ * Add a translation animation step that uses this element by default
69
+ * @param {TypeParsablePoint | OBJ_PositionAnimationStep | number} targetOrOptionsOrX
70
+ * @param {number} y define if `targetOrOptionsOrX` is x (number)
71
+ * @return {AnimationBuilder}
72
+ */
73
+ translation(targetOrOptionsOrX: TypeParsablePoint | OBJ_PositionAnimationStep | number, y?: number, z?: number): this;
74
+ /**
75
+ * Add a scale animation step that uses this element by default
76
+ * @param {TypeParsablePoint | OBJ_ScaleAnimationStep | number} targetOrOptionsOrX
77
+ * when a number is used, it will apply to both x and y if y is null
78
+ * @param {number | null} y use a number to define the y scale, or use null
79
+ * to use the `x` value (`null`)
80
+ * @return {AnimationBuilder}
81
+ */
82
+ scale(targetOrOptionsOrX: TypeParsablePoint | OBJ_ScaleAnimationStep | number, y?: null | number, z?: number): this;
83
+ /**
84
+ * Add a transform animation step that uses this element by default
85
+ * @param {OBJ_TransformAnimationStep | TypeParsableTransform} transformOrOptions
86
+ * @return {AnimationBuilder}
87
+ */
88
+ transform(transformOrOptions: OBJ_TransformAnimationStep | TypeParsableTransform): this;
89
+ pulseTransforms(...options: Array<OBJ_PulseTransformAnimationStep>): this;
90
+ /**
91
+ * Add a scenario animation step that uses this element by default
92
+ * @param {OBJ_ScenarioAnimationStep | OBJ_Scenario | string} scenarioOrOptions
93
+ * @return {AnimationBuilder}
94
+ */
95
+ scenario(scenarioOrOptions: string | OBJ_Scenario | OBJ_ScenarioAnimationStep): this;
96
+ /**
97
+ * Add a scenarios animation step that uses this element by default
98
+ * @param {string | OBJ_ScenariosAnimationStep} scenarioNameOrOptions
99
+ * @return {AnimationBuilder}
100
+ */
101
+ scenarios(scenarioOrOptions: string | OBJ_ScenariosAnimationStep): this;
102
+ /**
103
+ * Add a color animation step that uses this element by default
104
+ * @param {OBJ_ColorAnimationStep | TypeColor} colorOrOptions
105
+ * @return {AnimationBuilder}
106
+ */
107
+ color(colorOrOptions: OBJ_ColorAnimationStep | TypeColor): this;
108
+ /**
109
+ * Add an opacity animation step that uses this element by default
110
+ * @param {OBJ_OpacityAnimationStep | number} opacityOrOptions
111
+ * @return {AnimationBuilder}
112
+ */
113
+ opacity(opacityOrOptions: OBJ_OpacityAnimationStep | number): this;
114
+ /**
115
+ * Add an dissolve out animation step that uses this element by default
116
+ * @param {number | OBJ_ElementAnimationStep} durationOrOptions
117
+ * @return {AnimationBuilder}
118
+ */
119
+ dissolveOut(durationOrOptions?: number | OBJ_ElementAnimationStep): this;
120
+ /**
121
+ * Add an dissolve in animation step that uses this element by default
122
+ * @param {number | OBJ_ElementAnimationStep} durationOrOptions
123
+ * @return {AnimationBuilder}
124
+ */
125
+ dissolveIn(durationOrOptions?: number | OBJ_ElementAnimationStep): this;
126
+ addStep(animName: string, ...params: Array<any>): this;
127
+ /**
128
+ * Add an dim animation step that uses this element by default
129
+ * @param {OBJ_ElementAnimationStep | number} durationOrOptions
130
+ * @return {AnimationBuilder}
131
+ */
132
+ dim(durationOrOptions?: number | OBJ_ElementAnimationStep): this;
133
+ /**
134
+ * Add an undim animation step that uses this element by default
135
+ * @param {OBJ_ElementAnimationStep | number} durationOrOptions
136
+ * @return {AnimationBuilder}
137
+ */
138
+ undim(durationOrOptions?: number | OBJ_ElementAnimationStep): this;
139
+ /**
140
+ * Add a delay animation step
141
+ * @param {OBJ_AnimationStep | number} delayOrOptions
142
+ * @return {AnimationBuilder}
143
+ */
144
+ delay(delayOrOptions?: number | OBJ_AnimationStep): this;
145
+ /**
146
+ * Add a trigger animation step
147
+ * @param {OBJ_TriggerAnimationStep | function(): void | string} callbackOrOptions
148
+ * callback can be a function or an id to a function map
149
+ * @return {AnimationBuilder}
150
+ */
151
+ trigger(callbackOrOptions: (() => void) | string | OBJ_TriggerAnimationStep): this;
152
+ /**
153
+ * Add a parallel animation step
154
+ * @param {Array<AnimationStep | null> | OBJ_ParallelAnimationStep} stepsOrOptions
155
+ * @return {AnimationBuilder}
156
+ */
157
+ inParallel(stepsOrOptions?: Array<animation.AnimationStep | null> | OBJ_ParallelAnimationStep, ...options: Array<OBJ_ParallelAnimationStep>): this;
158
+ /**
159
+ * Add a serial animation step
160
+ * @param {Array<AnimationStep | null> | OBJ_SerialAnimationStep} stepsOrOptions
161
+ * @return {AnimationBuilder}
162
+ */
163
+ inSerial(stepsOrOptions?: Array<animation.AnimationStep> | OBJ_SerialAnimationStep, ...options: Array<OBJ_SerialAnimationStep>): this;
164
+ /**
165
+ * Add a pulse animation step
166
+ * @param {OBJ_PulseAnimationStep | number} scaleOrOptions pulse scale
167
+ * (number) or pulse animation step options
168
+ * @return {PulseAnimationStep}
169
+ */
170
+ pulse(scaleOrOptions: OBJ_PulseAnimationStep | number): this;
171
+ reset(): void;
172
+ _dup(): animation.AnimationBuilder;
173
+ }
@@ -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
+ }