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,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;
@@ -0,0 +1,146 @@
1
+ import Scene from '../../../tools/geometry/scene';
2
+ import type { Type3DMatrix } from '../../../tools/m3';
3
+ import WebGLInstance from '../../webgl/webgl';
4
+ import type { TypeFragmentShader, TypeVertexShader } from '../../webgl/shaders';
5
+ import { Rect } from '../../../tools/g2';
6
+ import DrawingObject from '../DrawingObject';
7
+ import type { TypeColor } from '../../../tools/types';
8
+ /**
9
+ * `'BYTE' | 'UNSIGNED_BYTE' | 'SHORT' | 'UNSIGNED_SHORT' | 'FLOAT'`
10
+ * @group Shaders
11
+ */
12
+ export type TypeGLBufferType = 'BYTE' | 'UNSIGNED_BYTE' | 'SHORT' | 'UNSIGNED_SHORT' | 'FLOAT';
13
+ /**
14
+ * `'STATIC' | 'DYNAMIC'`
15
+ * @group Shaders
16
+ */
17
+ export type TypeGLBufferUsage = 'STATIC' | 'DYNAMIC';
18
+ /**
19
+ * `'FLOAT' | 'FLOAT_VECTOR' | 'INT' | 'INT_VECTOR'`
20
+ * @group Shaders
21
+ */
22
+ export type TypeGLUniform = 'FLOAT' | 'FLOAT_VECTOR' | 'INT' | 'INT_VECTOR';
23
+ /**
24
+ * FigureElementPrimitive that can be used to utilize custom shaders for WebGL.
25
+ *
26
+ * @group Misc Figure Element
27
+ */
28
+ declare class GLObject extends DrawingObject {
29
+ gl: WebGLRenderingContext;
30
+ webgl: WebGLInstance;
31
+ glPrimitive: number;
32
+ z: number;
33
+ texture: {
34
+ id: string;
35
+ src?: string;
36
+ points: Array<number>;
37
+ buffer?: WebGLBuffer | null;
38
+ repeat?: boolean;
39
+ mapTo: Rect;
40
+ mapFrom: Rect;
41
+ data?: HTMLImageElement | null;
42
+ loadColor: TypeColor;
43
+ [key: string]: any;
44
+ } | null;
45
+ attributes: {
46
+ [attributeName: string]: {
47
+ buffer: WebGLBuffer | null;
48
+ size: number;
49
+ type: number;
50
+ normalize: boolean;
51
+ stride: number;
52
+ offset: number;
53
+ usage: number;
54
+ data: Array<number>;
55
+ };
56
+ };
57
+ points: Array<number>;
58
+ uniforms: {
59
+ [uniformName: string]: {
60
+ value: Array<number>;
61
+ method: (location: WebGLUniformLocation, name: string) => void;
62
+ };
63
+ };
64
+ numVertices: number;
65
+ state: 'loading' | 'loaded';
66
+ programIndex: number;
67
+ selectorProgramIndex: number;
68
+ onLoad: ((result: boolean, id: string) => void) | null | undefined;
69
+ vertexShader: TypeVertexShader;
70
+ fragmentShader: TypeFragmentShader;
71
+ selectorVertexShader: TypeVertexShader;
72
+ selectorFragmentShader: TypeFragmentShader;
73
+ constructor(webgl: WebGLInstance, vertexShader?: TypeVertexShader, fragmentShader?: TypeFragmentShader, selectorVertexShader?: TypeVertexShader, selectorFragShader?: TypeFragmentShader);
74
+ init(webgl: WebGLInstance): void;
75
+ initProgram(): void;
76
+ showShaders(): void;
77
+ showSelectorShaders(): void;
78
+ getCanvas(): HTMLCanvasElement | OffscreenCanvas;
79
+ setPrimitive(primitiveType: 'TRIANGLES' | 'POINTS' | 'TRIANGLE_FAN' | 'TRIANGLE_STRIP' | 'LINES' | 'LINE_LOOP' | 'LINE_STRIP' | 'FAN' | 'STRIP'): void;
80
+ initAttributes(): void;
81
+ setZ(z: number): void;
82
+ contextLost(): void;
83
+ updateTextureMap(points?: Array<number>): void;
84
+ /**
85
+ * Buffer a texture for the shape to be painted with.
86
+ */
87
+ addTexture(location: string, mapFrom?: Rect, mapTo?: Rect, mapToBuffer?: string, points?: Array<number>, repeat?: boolean, onLoad?: null | (() => void), loadColor?: TypeColor): void;
88
+ updateTexture(data: HTMLImageElement): void;
89
+ initTexture(force?: boolean): void;
90
+ createTextureMap(xMinGL?: number, xMaxGL?: number, yMinGL?: number, yMaxGL?: number, xMinTex?: number, xMaxTex?: number, yMinTex?: number, yMaxTex?: number): void;
91
+ addVertices(vertices: Array<number>, dimension?: 2 | 3, usage?: TypeGLBufferUsage): void;
92
+ addVertices3(vertices: Array<number>, usage?: TypeGLBufferUsage): void;
93
+ addNormals(normals: Array<number>, usage?: TypeGLBufferUsage): void;
94
+ addColors(colors: Array<number>, normalized?: boolean, usage?: TypeGLBufferUsage): void;
95
+ addAttribute(name: string, size: number, data: Array<number>, typeIn?: TypeGLBufferType, normalize?: boolean, stride?: number, offset?: number, usageIn?: TypeGLBufferUsage): void;
96
+ fillBuffer(name: string, data: Array<number>): void;
97
+ executeOnLoad(result: boolean, id: string): void;
98
+ resetTextureBuffer(deleteTexture?: boolean): void;
99
+ cleanup(deleteTexture?: boolean): void;
100
+ resetBuffers(deleteTexture?: boolean): void;
101
+ updateVertices(vertices: Array<number>): void;
102
+ updateVertices3(vertices: Array<number>): void;
103
+ updateAttribute(name: string, data: Array<number>): void;
104
+ _getStateProperties(): never[];
105
+ /**
106
+ * Get the current value of a uniform
107
+ */
108
+ getUniform(uniformName: string): number[];
109
+ /**
110
+ * Add a uniform.
111
+ *
112
+ * Length 16 corresponds to a 4x4 matrix and can only be
113
+ * `'FLOAT_VECTOR'` type.
114
+ *
115
+ * @param {string} uniformName The variable name used in the shader
116
+ * @param {1 | 2 | 3 | 4 | 16} length (`1`) number of values in uniform
117
+ * @param {'FLOAT' | 'FLOAT_VECTOR' | 'INT' | 'INT_VECTOR'} type type of
118
+ * value. Use '_VECTOR' suffix if using vector methods on the uniform in the
119
+ * shader (`'FLOAT'`).
120
+ * @param {number | Array<number> | null} initialValue initial value to use
121
+ * for uniform - if null then uniform will be all 0 (`null`)
122
+ */
123
+ addUniform(uniformName: string, length?: 1 | 2 | 3 | 4 | 16, type?: TypeGLUniform, initialValue?: number | Array<number> | null): void;
124
+ uploadUniform1f(location: WebGLUniformLocation, name: string): void;
125
+ uploadUniform2f(location: WebGLUniformLocation, name: string): void;
126
+ uploadUniform3f(location: WebGLUniformLocation, name: string): void;
127
+ uploadUniform4f(location: WebGLUniformLocation, name: string): void;
128
+ uploadUniform1fv(location: WebGLUniformLocation, name: string): void;
129
+ uploadUniform2fv(location: WebGLUniformLocation, name: string): void;
130
+ uploadUniform3fv(location: WebGLUniformLocation, name: string): void;
131
+ uploadUniform4fv(location: WebGLUniformLocation, name: string): void;
132
+ uploadUniform1iv(location: WebGLUniformLocation, name: string): void;
133
+ uploadUniform2iv(location: WebGLUniformLocation, name: string): void;
134
+ uploadUniform3iv(location: WebGLUniformLocation, name: string): void;
135
+ uploadUniform4iv(location: WebGLUniformLocation, name: string): void;
136
+ uploadUniform16fv(location: WebGLUniformLocation, name: string): void;
137
+ uploadUniform1i(location: WebGLUniformLocation, name: string): void;
138
+ uploadUniform2i(location: WebGLUniformLocation, name: string): void;
139
+ uploadUniform3i(location: WebGLUniformLocation, name: string): void;
140
+ uploadUniform4i(location: WebGLUniformLocation, name: string): void;
141
+ updateUniform(uniformName: string, value: number | Array<number>): void;
142
+ drawWithTransformMatrix(scene: Scene, worldMatrix: Type3DMatrix, color: TypeColor, numDrawVertices?: number, targetTexture?: boolean): void;
143
+ getPointCountForAngle(drawAngle?: number): number;
144
+ getPointCountForLength(drawLength: number): number;
145
+ }
146
+ export default GLObject;
@@ -0,0 +1,29 @@
1
+ import { Point } from '../../../tools/g2';
2
+ import DrawingObject from '../DrawingObject';
3
+ import type { TypeColor } from '../../../tools/types';
4
+ import type { Type3DMatrix } from '../../../tools/m3';
5
+ import type Scene from '../../../tools/geometry/scene';
6
+ declare class HTMLObject extends DrawingObject {
7
+ border: Array<Array<Point>>;
8
+ id: string;
9
+ location: Point;
10
+ element: HTMLElement;
11
+ parentDiv: HTMLElement;
12
+ xAlign: 'left' | 'right' | 'center';
13
+ yAlign: 'top' | 'bottom' | 'middle';
14
+ show: boolean;
15
+ lastMatrix: Array<number>;
16
+ lastColor: Array<number>;
17
+ forceDraw: boolean;
18
+ originalElement: HTMLElement;
19
+ copy: () => HTMLObject;
20
+ constructor(parentDiv: HTMLElement, id: string, location: Point, yAlign: "top" | "bottom" | "middle" | undefined, xAlign: "left" | "right" | "center" | undefined, originalElement: HTMLElement | Array<HTMLElement>);
21
+ _dup(): any;
22
+ setBorder(): void;
23
+ getBoundaries(): Array<Array<Point>>;
24
+ glToPixelSpace(p: Point): Point;
25
+ change(newHtml: any, lastDrawTransformMatrix?: any): void;
26
+ transformHtml(transformMatrix: Type3DMatrix, opacity?: number): void;
27
+ drawWithTransformMatrix(scene: Scene, worldMatrix: Type3DMatrix, color: TypeColor): void;
28
+ }
29
+ export default HTMLObject;