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.
- package/figureone.min.js +1 -1
- package/index.js +79170 -0
- package/llms.txt +548 -0
- package/package.json +16 -1
- package/types/index.d.ts +128 -0
- package/types/js/figure/Animation/Animation.d.ts +36 -0
- package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
- package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
- package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
- package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
- package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
- package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
- package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
- package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
- package/types/js/figure/DrawContext2D.d.ts +9 -0
- package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
- package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
- package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
- package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
- package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
- package/types/js/figure/Element.d.ts +1212 -0
- package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
- package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
- package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
- package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
- package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
- package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
- package/types/js/figure/Equation/Equation.d.ts +984 -0
- package/types/js/figure/Equation/EquationForm.d.ts +139 -0
- package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
- package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
- package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
- package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
- package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
- package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
- package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
- package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
- package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
- package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
- package/types/js/figure/Figure.d.ts +711 -0
- package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
- package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
- package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
- package/types/js/figure/FigureCollections/Button.d.ts +195 -0
- package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
- package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
- package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
- package/types/js/figure/FigureCollections/Line.d.ts +587 -0
- package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
- package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
- package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
- package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
- package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
- package/types/js/figure/FigureCollections/Text.d.ts +307 -0
- package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
- package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
- package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
- package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
- package/types/js/figure/FontManager.d.ts +113 -0
- package/types/js/figure/Gesture.d.ts +39 -0
- package/types/js/figure/Recorder/Recorder.d.ts +291 -0
- package/types/js/figure/Recorder/parseState.d.ts +3 -0
- package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
- package/types/js/figure/Recorder/state.d.ts +7 -0
- package/types/js/figure/SlideNavigator.d.ts +606 -0
- package/types/js/figure/TimeKeeper.d.ts +174 -0
- package/types/js/figure/geometries/arc.d.ts +18 -0
- package/types/js/figure/geometries/arrow.d.ts +215 -0
- package/types/js/figure/geometries/buffer.d.ts +4 -0
- package/types/js/figure/geometries/copy/copy.d.ts +178 -0
- package/types/js/figure/geometries/ellipse.d.ts +17 -0
- package/types/js/figure/geometries/line.d.ts +13 -0
- package/types/js/figure/geometries/lines/corners.d.ts +7 -0
- package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
- package/types/js/figure/geometries/lines/lines.d.ts +31 -0
- package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
- package/types/js/figure/geometries/rectangle.d.ts +19 -0
- package/types/js/figure/geometries/triangle.d.ts +27 -0
- package/types/js/figure/webgl/Atlas.d.ts +42 -0
- package/types/js/figure/webgl/shaders.d.ts +143 -0
- package/types/js/figure/webgl/target.d.ts +9 -0
- package/types/js/figure/webgl/webgl.d.ts +54 -0
- package/types/js/tools/FunctionMap.d.ts +69 -0
- package/types/js/tools/color.d.ts +11 -0
- package/types/js/tools/colorNames.d.ts +2 -0
- package/types/js/tools/d2/polygon.d.ts +60 -0
- package/types/js/tools/d2/triangles.d.ts +0 -0
- package/types/js/tools/d3/cone.d.ts +57 -0
- package/types/js/tools/d3/cube.d.ts +26 -0
- package/types/js/tools/d3/cylinder.d.ts +45 -0
- package/types/js/tools/d3/line3.d.ts +55 -0
- package/types/js/tools/d3/prism.d.ts +49 -0
- package/types/js/tools/d3/revolve.d.ts +87 -0
- package/types/js/tools/d3/sphere.d.ts +33 -0
- package/types/js/tools/d3/surface.d.ts +47 -0
- package/types/js/tools/g2.d.ts +242 -0
- package/types/js/tools/geometry/Bounds.d.ts +446 -0
- package/types/js/tools/geometry/Line.d.ts +314 -0
- package/types/js/tools/geometry/Path.d.ts +67 -0
- package/types/js/tools/geometry/Plane.d.ts +201 -0
- package/types/js/tools/geometry/Point.d.ts +359 -0
- package/types/js/tools/geometry/Rect.d.ts +115 -0
- package/types/js/tools/geometry/Transform.d.ts +623 -0
- package/types/js/tools/geometry/angle.d.ts +105 -0
- package/types/js/tools/geometry/common.d.ts +9 -0
- package/types/js/tools/geometry/coordinates.d.ts +30 -0
- package/types/js/tools/geometry/deceleration.d.ts +13 -0
- package/types/js/tools/geometry/polygon.d.ts +4 -0
- package/types/js/tools/geometry/quaternion.d.ts +15 -0
- package/types/js/tools/geometry/scene.d.ts +282 -0
- package/types/js/tools/geometry/tools.d.ts +8 -0
- package/types/js/tools/geometry/types.d.ts +2 -0
- package/types/js/tools/getCssColors.d.ts +1 -0
- package/types/js/tools/getCssVariables.d.ts +4 -0
- package/types/js/tools/getImageData.d.ts +1 -0
- package/types/js/tools/getScssColors.d.ts +2 -0
- package/types/js/tools/htmlGenerator.d.ts +85 -0
- package/types/js/tools/m2.d.ts +24 -0
- package/types/js/tools/m3.d.ts +71 -0
- package/types/js/tools/math.d.ts +112 -0
- package/types/js/tools/morph.d.ts +651 -0
- package/types/js/tools/styleSheets.d.ts +3 -0
- package/types/js/tools/tools.d.ts +281 -0
- package/types/js/tools/types.d.ts +305 -0
- package/figureone.worker.js +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { TypeParsablePoint } from '../../../../tools/g2';
|
|
2
|
+
import type { OBJ_ElementAnimationStep } from '../ElementAnimationStep';
|
|
3
|
+
import ElementAnimationStep from '../ElementAnimationStep';
|
|
4
|
+
import type { TypeWhen } from '../../../TimeKeeper';
|
|
5
|
+
import type { FigureElement } from '../../../Element';
|
|
6
|
+
/**
|
|
7
|
+
* {@link PulseAnimationStep} options object
|
|
8
|
+
*
|
|
9
|
+
* @extends OBJ_ElementAnimationStep
|
|
10
|
+
* @property {number} [frequency] pulse frequency in Hz - a frequency of zero
|
|
11
|
+
* will set the frequency so just one cycle will be performed in the duration
|
|
12
|
+
* (`0`)
|
|
13
|
+
* @property {number} [scale] maximum scale value to pulse to (`1.5`)
|
|
14
|
+
* @property {number} [rotation] maximum rotation value to pulse to
|
|
15
|
+
* @property {number} [translation] maximum translation displacment value to
|
|
16
|
+
* pulse to (`1.5`)
|
|
17
|
+
* @property {number} [angle] translation angle (`0`)
|
|
18
|
+
* @property {number} [min] minimum value to pulse to
|
|
19
|
+
* @property {null | FigureElement | TypeParsablePoint} [centerOn] center
|
|
20
|
+
* of scale or rotation pulse. By default, the element calling the pulse
|
|
21
|
+
* will be the default `centerOn`.
|
|
22
|
+
* @property {'left' | 'center' | 'right' | 'location' | number} [xAlign]
|
|
23
|
+
* if `centerOn` is a {@link FigureElement} then this property can be used to
|
|
24
|
+
* horizontally align the pulse center with the element. `'location'` is the
|
|
25
|
+
* (0, 0) draw space coordinate of the element. `number` defines the percent
|
|
26
|
+
* width from the left of the element (`'center'`)
|
|
27
|
+
* @property {'bottom' | 'middle' | 'top' | 'location' | number} [yAlign]
|
|
28
|
+
* if `centerOn` is a {@link FigureElement} then this property can be used to
|
|
29
|
+
* vertically align the pulse center with the element. `'location'` is the
|
|
30
|
+
* (0, 0) draw space coordinate of the element. `number` defines the percent
|
|
31
|
+
* width from the left of the element (`'center'`)
|
|
32
|
+
* @property {'figure' | 'gl' | 'local' | 'draw' | 'pixel'} [space]
|
|
33
|
+
* if `centerOn` is a point, use this to define the space the point is in
|
|
34
|
+
* (`'figure'`)
|
|
35
|
+
* @property {number} [num] the number of draw copies of the pulse to make (`1`)
|
|
36
|
+
* @property {null | string | function(): void} [done] callback when pulse is
|
|
37
|
+
* finished. If `string` then the element's {@link FunctionMap} `fnMap` will be
|
|
38
|
+
* used (`null`)
|
|
39
|
+
* @property {TypeWhen} [when] when to start the pulse (`'syncNow'`)
|
|
40
|
+
*
|
|
41
|
+
* @interface
|
|
42
|
+
* @group Misc Animation
|
|
43
|
+
*/
|
|
44
|
+
export type OBJ_PulseAnimationStep = {
|
|
45
|
+
stopAfterDuration?: boolean | null | undefined;
|
|
46
|
+
frequency?: number;
|
|
47
|
+
scale?: number;
|
|
48
|
+
rotation?: number;
|
|
49
|
+
translation?: number;
|
|
50
|
+
angle?: number;
|
|
51
|
+
min?: number;
|
|
52
|
+
centerOn?: null | FigureElement | TypeParsablePoint;
|
|
53
|
+
xAlign?: 'left' | 'center' | 'right' | 'origin' | number;
|
|
54
|
+
yAlign?: 'bottom' | 'middle' | 'top' | 'origin' | number;
|
|
55
|
+
space?: 'figure' | 'gl' | 'local' | 'draw';
|
|
56
|
+
done?: ((arg: any) => void) | null | undefined;
|
|
57
|
+
num?: number;
|
|
58
|
+
when?: TypeWhen;
|
|
59
|
+
} & OBJ_ElementAnimationStep;
|
|
60
|
+
/**
|
|
61
|
+
* Pulse animation step
|
|
62
|
+
*
|
|
63
|
+
* 
|
|
64
|
+
*
|
|
65
|
+
* The pulse animation step animates a pulse.
|
|
66
|
+
*
|
|
67
|
+
* The options are the same as those in the * <a href="#figureelementpulse">pulse</a> method.
|
|
68
|
+
*
|
|
69
|
+
* @extends ElementAnimationStep
|
|
70
|
+
* @param {OBJ_PulseAnimationStep} options
|
|
71
|
+
*
|
|
72
|
+
*
|
|
73
|
+
* @see To test examples, append them to the
|
|
74
|
+
* <a href="#animation-boilerplate">boilerplate</a>
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // Scale pulse, rotation pulse and translation pulse
|
|
78
|
+
* p.animations.new()
|
|
79
|
+
* .pulse({
|
|
80
|
+
* scale: 1.5,
|
|
81
|
+
* duration: 1,
|
|
82
|
+
* })
|
|
83
|
+
* .pulse({
|
|
84
|
+
* duration: 1,
|
|
85
|
+
* rotation: 0.15,
|
|
86
|
+
* frequency: 4,
|
|
87
|
+
* })
|
|
88
|
+
* .pulse({
|
|
89
|
+
* duration: 1,
|
|
90
|
+
* translation: 0.02,
|
|
91
|
+
* min: -0.02,
|
|
92
|
+
* frequency: 4,
|
|
93
|
+
* })
|
|
94
|
+
* .start();
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* // Different ways to create a stand-alone step
|
|
98
|
+
* const step1 = p.animations.pulse({
|
|
99
|
+
* scale: 1.5,
|
|
100
|
+
* duration: 1,
|
|
101
|
+
* });
|
|
102
|
+
* const step2 = new Fig.Animation.PulseAnimationStep({
|
|
103
|
+
* element: p,
|
|
104
|
+
* rotation: 0.15,
|
|
105
|
+
* frequency: 4,
|
|
106
|
+
* });
|
|
107
|
+
* p.animations.new()
|
|
108
|
+
* .then(step1)
|
|
109
|
+
* .then(step2)
|
|
110
|
+
* .start();
|
|
111
|
+
* @group Animation
|
|
112
|
+
*/
|
|
113
|
+
export default class PulseAnimationStep extends ElementAnimationStep {
|
|
114
|
+
pulse: {
|
|
115
|
+
frequency: number;
|
|
116
|
+
scale: number;
|
|
117
|
+
rotation?: number;
|
|
118
|
+
translation?: number;
|
|
119
|
+
angle: number;
|
|
120
|
+
min: number;
|
|
121
|
+
centerOn: null | FigureElement | TypeParsablePoint;
|
|
122
|
+
xAlign: 'left' | 'center' | 'right' | 'origin' | number;
|
|
123
|
+
yAlign: 'bottom' | 'middle' | 'top' | 'origin' | number;
|
|
124
|
+
space: 'figure' | 'gl' | 'local' | 'draw';
|
|
125
|
+
done: ((arg: any) => void) | null | undefined;
|
|
126
|
+
num: number;
|
|
127
|
+
when: TypeWhen;
|
|
128
|
+
stopAfterDuration: boolean;
|
|
129
|
+
};
|
|
130
|
+
toStart: boolean;
|
|
131
|
+
constructor(...optionsIn: Array<OBJ_PulseAnimationStep>);
|
|
132
|
+
_getStateProperties(): string[];
|
|
133
|
+
_getStateName(): string;
|
|
134
|
+
setFrame(): void;
|
|
135
|
+
setToEnd(): void;
|
|
136
|
+
_dup(): PulseAnimationStep;
|
|
137
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Transform } from '../../../../tools/g2';
|
|
2
|
+
import type { TypeParsablePoint, TypeParsableTransform } from '../../../../tools/g2';
|
|
3
|
+
import type { OBJ_ElementAnimationStep } from '../ElementAnimationStep';
|
|
4
|
+
import ElementAnimationStep from '../ElementAnimationStep';
|
|
5
|
+
import type { AnimationStartTime } from '../../AnimationManager';
|
|
6
|
+
import type { OBJ_TranslationPath } from '../../../../tools/geometry/Path';
|
|
7
|
+
export type OBJ_PulseTransformAnimationStep = {
|
|
8
|
+
start?: Array<Transform>;
|
|
9
|
+
target?: Array<Transform>;
|
|
10
|
+
path?: OBJ_TranslationPath;
|
|
11
|
+
rotDirection: 0 | 1 | -1 | 2;
|
|
12
|
+
clipRotationTo: '0to360' | '-180to180' | null;
|
|
13
|
+
velocity?: Transform | number | {
|
|
14
|
+
position?: TypeParsablePoint | number;
|
|
15
|
+
translation?: TypeParsablePoint | number;
|
|
16
|
+
rotation?: number;
|
|
17
|
+
scale?: TypeParsablePoint | number;
|
|
18
|
+
transform?: TypeParsableTransform;
|
|
19
|
+
} | null;
|
|
20
|
+
maxDuration?: number;
|
|
21
|
+
zeroDurationThreshold?: number;
|
|
22
|
+
} & OBJ_ElementAnimationStep;
|
|
23
|
+
export default class PulseTransformAnimationStep extends ElementAnimationStep {
|
|
24
|
+
transform: {
|
|
25
|
+
start: Array<Transform>;
|
|
26
|
+
delta: Array<Transform>;
|
|
27
|
+
target: Array<Transform>;
|
|
28
|
+
rotDirection: 0 | 1 | -1 | 2;
|
|
29
|
+
path: OBJ_TranslationPath;
|
|
30
|
+
velocity: Transform | number | {
|
|
31
|
+
position?: TypeParsablePoint | number;
|
|
32
|
+
translation?: TypeParsablePoint | number;
|
|
33
|
+
rotation?: number;
|
|
34
|
+
scale?: TypeParsablePoint | number;
|
|
35
|
+
transform?: TypeParsableTransform;
|
|
36
|
+
} | null | undefined;
|
|
37
|
+
clipRotationTo: '0to360' | '-180to180' | null;
|
|
38
|
+
maxDuration: number | null | undefined;
|
|
39
|
+
zeroDurationThreshold: number;
|
|
40
|
+
};
|
|
41
|
+
constructor(...optionsIn: Array<OBJ_PulseTransformAnimationStep>);
|
|
42
|
+
spread(transforms: Array<Transform>, toNum: number): Transform[];
|
|
43
|
+
setStartAndTarget(): void;
|
|
44
|
+
calculateStartTargetDelta(): void;
|
|
45
|
+
_getStateProperties(): string[];
|
|
46
|
+
_getStateName(): string;
|
|
47
|
+
getVelocityTransform(): Transform;
|
|
48
|
+
start(startTime?: AnimationStartTime | null): void;
|
|
49
|
+
setFrame(deltaTime: number): void;
|
|
50
|
+
setToEnd(): void;
|
|
51
|
+
_dup(): PulseTransformAnimationStep;
|
|
52
|
+
}
|
package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { OBJ_ElementAnimationStep } from '../ElementAnimationStep';
|
|
2
|
+
import ElementAnimationStep from '../ElementAnimationStep';
|
|
3
|
+
import type { AnimationStartTime } from '../../AnimationManager';
|
|
4
|
+
/**
|
|
5
|
+
* {@link RotationAnimationStep} step options object.
|
|
6
|
+
*
|
|
7
|
+
* The {@link RotationAnimationStep} animates the rotation value of a the first
|
|
8
|
+
* rotation component in a {@link Transform}.
|
|
9
|
+
*
|
|
10
|
+
* To rotate from a `start` rotation to a `target` rotation use the
|
|
11
|
+
* `start`, `delta` and/or `target` properties.
|
|
12
|
+
*
|
|
13
|
+
* If `start` is not defined, the current rotation angle (when the animation
|
|
14
|
+
* is started) will be used as `start`.
|
|
15
|
+
*
|
|
16
|
+
* Either `target` or `delta` (from start) can be used to define the target.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* The animation can either move to the target with a `duration`, or the
|
|
20
|
+
* `duration` can be determined by a `velocity`.
|
|
21
|
+
*
|
|
22
|
+
* Rotation animation targets can also be created with `velocity`, `start` and
|
|
23
|
+
* `duration`. In this case, the rotation angles will grow with `velocity`. If
|
|
24
|
+
* `duration` is null, then rotation duration will continue indefinitely until
|
|
25
|
+
* the animation is cancelled.
|
|
26
|
+
*
|
|
27
|
+
* @extends OBJ_ElementAnimationStep
|
|
28
|
+
*
|
|
29
|
+
* @property {number} [start] start rotation - current
|
|
30
|
+
* rotation used if undefined
|
|
31
|
+
* @property {number} [target] target rotation
|
|
32
|
+
* @property {number} [delta] a delta rotation that can be
|
|
33
|
+
* used to define `target` if `target` is undefined
|
|
34
|
+
* @property {null | number} [velocity] velocity of
|
|
35
|
+
* rotation can either define the `duration` of a rotation if `target` or
|
|
36
|
+
* `delta` is defined, or can define the `target` of a rotation if `duration`
|
|
37
|
+
* is defined. If `duration` is null, then velocity determines the change in
|
|
38
|
+
* rotation over time (`null`)
|
|
39
|
+
* @property {number | null} [maxDuration] maximum duration to clip animation
|
|
40
|
+
* to where `null` is unlimited (`null`)
|
|
41
|
+
*
|
|
42
|
+
* @see {@link RotationAnimationStep} for description and examples
|
|
43
|
+
* @interface
|
|
44
|
+
* @group Misc Animation
|
|
45
|
+
*/
|
|
46
|
+
export type OBJ_RotationAnimationStep = {
|
|
47
|
+
start?: number;
|
|
48
|
+
target?: number;
|
|
49
|
+
delta?: number;
|
|
50
|
+
velocity?: number | null;
|
|
51
|
+
maxDuration?: number | null;
|
|
52
|
+
} & OBJ_ElementAnimationStep;
|
|
53
|
+
/**
|
|
54
|
+
* Rotation animation step
|
|
55
|
+
*
|
|
56
|
+
* 
|
|
57
|
+
*
|
|
58
|
+
* The rotation animation step animates the first {@link Rotation} transform
|
|
59
|
+
* in the {@link FigureElement}'s {@link Transform}.
|
|
60
|
+
*
|
|
61
|
+
* By default, the rotation will start with the element's current rotation.
|
|
62
|
+
*
|
|
63
|
+
* Use either `delta` or `target` to define it's end point
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
* @extends ElementAnimationStep
|
|
67
|
+
* @param {OBJ_RotationAnimationStep} options
|
|
68
|
+
*
|
|
69
|
+
*
|
|
70
|
+
* @see To test examples, append them to the
|
|
71
|
+
* <a href="#animation-boilerplate">boilerplate</a>
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Using duration
|
|
75
|
+
* p.animations.new()
|
|
76
|
+
* .rotation({ target: Math.PI, duration: 2 })
|
|
77
|
+
* .start();
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // Using velocity
|
|
81
|
+
* p.animations.new()
|
|
82
|
+
* .rotation({ target: Math.PI, velocity: Math.PI / 2 })
|
|
83
|
+
* .start();
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* // Different ways to create a stand-alone step
|
|
87
|
+
* const step1 = p.animations.rotation({ target: Math.PI, duration: 2 });
|
|
88
|
+
* const step2 = new Fig.Animation.RotationAnimationStep({
|
|
89
|
+
* element: p,
|
|
90
|
+
* target: 0,
|
|
91
|
+
* duration: 2,
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* p.animations.new()
|
|
95
|
+
* .then(step1)
|
|
96
|
+
* .then(step2)
|
|
97
|
+
* .start();
|
|
98
|
+
* @group Animation
|
|
99
|
+
*/
|
|
100
|
+
export default class RotationAnimationStep extends ElementAnimationStep {
|
|
101
|
+
rotation: {
|
|
102
|
+
start: number;
|
|
103
|
+
delta: number;
|
|
104
|
+
target: number;
|
|
105
|
+
velocity: number;
|
|
106
|
+
maxDuration: number | null | undefined;
|
|
107
|
+
clipTo: '0to360' | '-180to180' | null;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* @hideconstructor
|
|
111
|
+
*/
|
|
112
|
+
constructor(...optionsIn: Array<OBJ_RotationAnimationStep>);
|
|
113
|
+
_getStateProperties(): string[];
|
|
114
|
+
_getStateName(): string;
|
|
115
|
+
start(startTime?: AnimationStartTime | null): void;
|
|
116
|
+
setFrame(deltaTime: number): void;
|
|
117
|
+
setToEnd(): void;
|
|
118
|
+
_dup(): RotationAnimationStep;
|
|
119
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Point } from '../../../../tools/g2';
|
|
2
|
+
import type { OBJ_ElementAnimationStep } from '../ElementAnimationStep';
|
|
3
|
+
import ElementAnimationStep from '../ElementAnimationStep';
|
|
4
|
+
import type { AnimationStartTime } from '../../AnimationManager';
|
|
5
|
+
/**
|
|
6
|
+
* {@link ScaleAnimationStep} options object
|
|
7
|
+
*
|
|
8
|
+
* @extends OBJ_ElementAnimationStep
|
|
9
|
+
*
|
|
10
|
+
* @property {TypeParsablePoint | number} [start]
|
|
11
|
+
* @property {TypeParsablePoint | number} [target]
|
|
12
|
+
* @property {TypeParsablePoint | number} [delta]
|
|
13
|
+
* @property {null | TypeParsablePoint | number} [velocity] velocity of scale
|
|
14
|
+
* overrides `duration` - `null` to use `duration` (`null`)
|
|
15
|
+
* @property {number | null} [maxDuration] maximum duration to clip animation
|
|
16
|
+
* to where `null` is unlimited (`null`)
|
|
17
|
+
* @interface
|
|
18
|
+
* @group Misc Animation
|
|
19
|
+
*/
|
|
20
|
+
export type OBJ_ScaleAnimationStep = {
|
|
21
|
+
start?: Point | number;
|
|
22
|
+
target?: Point | number;
|
|
23
|
+
delta?: Point | number;
|
|
24
|
+
velocity?: Point | number;
|
|
25
|
+
maxDuration?: number | null | undefined;
|
|
26
|
+
} & OBJ_ElementAnimationStep;
|
|
27
|
+
/**
|
|
28
|
+
* Scale Animation Step
|
|
29
|
+
*
|
|
30
|
+
* 
|
|
31
|
+
*
|
|
32
|
+
* The scale animation step animates the first {@link Scale} transform
|
|
33
|
+
* in the {@link FigureElement}'s {@link Transform}.
|
|
34
|
+
*
|
|
35
|
+
* By default, the scale will start with the element's current scale.
|
|
36
|
+
*
|
|
37
|
+
* Use either `delta` or `target` to define it's end point.
|
|
38
|
+
*
|
|
39
|
+
* Scale can be defined as either a point or number. If number,
|
|
40
|
+
* both x and y scale terms will be the same.
|
|
41
|
+
*
|
|
42
|
+
* @extends ElementAnimationStep
|
|
43
|
+
* @param {OBJ_ScaleAnimationStep} options
|
|
44
|
+
*
|
|
45
|
+
* @see To test examples, append them to the
|
|
46
|
+
* <a href="#animation-boilerplate">boilerplate</a>
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Using duration
|
|
50
|
+
* p.animations.new()
|
|
51
|
+
* .scale({ target: 2, duration: 2 })
|
|
52
|
+
* .start();
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Using velocity
|
|
56
|
+
* p.animations.new()
|
|
57
|
+
* .scale({ target: 2, velocity: 0.5 })
|
|
58
|
+
* .start();
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Different ways to create a stand-alone step
|
|
62
|
+
* const step1 = p.animations.scale({ target: 1.5, duration: 2 });
|
|
63
|
+
* const step2 = new Fig.Animation.ScaleAnimationStep({
|
|
64
|
+
* element: p,
|
|
65
|
+
* target: 1,
|
|
66
|
+
* duration: 2,
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* p.animations.new()
|
|
70
|
+
* .then(step1)
|
|
71
|
+
* .then(step2)
|
|
72
|
+
* .start();
|
|
73
|
+
* @group Animation
|
|
74
|
+
*/
|
|
75
|
+
export default class ScaleAnimationStep extends ElementAnimationStep {
|
|
76
|
+
scale: {
|
|
77
|
+
start: Point | null | undefined;
|
|
78
|
+
delta: Point | null | undefined;
|
|
79
|
+
target: Point | null | undefined;
|
|
80
|
+
velocity: Point | null | undefined;
|
|
81
|
+
maxDuration: number | null | undefined;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* @hideconstructor
|
|
85
|
+
*/
|
|
86
|
+
constructor(...optionsIn: Array<OBJ_ScaleAnimationStep>);
|
|
87
|
+
_getStateProperties(): string[];
|
|
88
|
+
_getStateName(): string;
|
|
89
|
+
start(startTime?: AnimationStartTime | null): void;
|
|
90
|
+
setFrame(deltaTime: number): void;
|
|
91
|
+
setToEnd(): void;
|
|
92
|
+
_dup(): ScaleAnimationStep;
|
|
93
|
+
}
|
package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Transform } from '../../../../tools/g2';
|
|
2
|
+
import type { OBJ_TranslationPath, TypeParsableTransform, TypeParsablePoint } from '../../../../tools/g2';
|
|
3
|
+
import type { OBJ_ElementAnimationStep, AnimationProgression } from '../ElementAnimationStep';
|
|
4
|
+
import { ParallelAnimationStep } from '../ParallelAnimationStep';
|
|
5
|
+
import type { FigureElement, OBJ_Scenario } from '../../../Element';
|
|
6
|
+
import type { AnimationStartTime } from '../../AnimationManager';
|
|
7
|
+
import type { TypeColor } from '../../../../tools/types';
|
|
8
|
+
/**
|
|
9
|
+
* Transform, color and visbility scenario definition
|
|
10
|
+
*
|
|
11
|
+
* `translation` will overwirte `position`, and `translation, `position`,
|
|
12
|
+
* rotation` and `scale` overwrite the first equivalent transforms in
|
|
13
|
+
* `transform`
|
|
14
|
+
*
|
|
15
|
+
* @property {TypeParsablePoint} [position]
|
|
16
|
+
* @property {TypeParsablePoint} [translation]
|
|
17
|
+
* @property {TypeParsablePoint | number} [scale]
|
|
18
|
+
* @property {number} [rotation]
|
|
19
|
+
* @property {TypeParsableTransform} [transform]
|
|
20
|
+
* @property {TypeColor} [color]
|
|
21
|
+
* @property {number} [opacity]
|
|
22
|
+
* @interface
|
|
23
|
+
* @group Misc Animation
|
|
24
|
+
*/
|
|
25
|
+
export type OBJ_ScenarioVelocity = {
|
|
26
|
+
position?: TypeParsablePoint | number;
|
|
27
|
+
translation?: TypeParsablePoint | number;
|
|
28
|
+
rotation?: number;
|
|
29
|
+
scale?: TypeParsablePoint | number;
|
|
30
|
+
transform?: TypeParsableTransform;
|
|
31
|
+
color?: number;
|
|
32
|
+
opacity?: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* {@link ScenarioAnimationStep} options object
|
|
36
|
+
*
|
|
37
|
+
* @extends OBJ_ElementAnimationStep
|
|
38
|
+
*
|
|
39
|
+
* @property {string | OBJ_Scenario} [start]
|
|
40
|
+
* @property {string | OBJ_Scenario} [target]
|
|
41
|
+
* @property {null | string | OBJ_ScenarioVelocity} [velocity] velocity
|
|
42
|
+
* will override duration with a calculated duration based on
|
|
43
|
+
* the `start`, `target` and `velocity`. If `null` is used
|
|
44
|
+
* then `duration` will not be overriden. Any scenario velocity elements that
|
|
45
|
+
* are undefined will default to 1 (`null`)
|
|
46
|
+
* @property {number | null} [maxDuration] maximum duration to clip animation
|
|
47
|
+
* to where `null` is unlimited (`null`)
|
|
48
|
+
* @property {number} [zeroDurationThreshold] value considered 0 to stop
|
|
49
|
+
* animation - this is useful when numbers get very small and rounding problems
|
|
50
|
+
* with javascripts floating point implementation arise
|
|
51
|
+
* @property {OBJ_TranslationPath} [path] translation path style and options
|
|
52
|
+
* (`{ style: 'linear' }`)
|
|
53
|
+
* @property {0 | 1 | -1 | 2} [rotDirection] where `0` is quickest direction,
|
|
54
|
+
* `1` is positive of CCW direction, `-1` is negative of CW direction and `2` is
|
|
55
|
+
* whichever direction doesn't pass through angle 0.
|
|
56
|
+
* @property {'0to360' | '-180to180' | null} [clipRotationTo]
|
|
57
|
+
* @property {'linear' | 'easeinout' | 'easein' | 'easeout' | AnimationProgression} [progression]
|
|
58
|
+
* (`'easeinout'`)
|
|
59
|
+
* @interface
|
|
60
|
+
* @group Misc Animation
|
|
61
|
+
*/
|
|
62
|
+
export type OBJ_ScenarioAnimationStep = {
|
|
63
|
+
start?: string | OBJ_Scenario;
|
|
64
|
+
target?: string | OBJ_Scenario;
|
|
65
|
+
velocity?: OBJ_ScenarioVelocity;
|
|
66
|
+
maxDuration?: number;
|
|
67
|
+
zeroDurationThreshold?: number;
|
|
68
|
+
allDurationsSame?: boolean;
|
|
69
|
+
path?: OBJ_TranslationPath;
|
|
70
|
+
rotDirection: 0 | 1 | -1 | 2;
|
|
71
|
+
clipRotationTo: '0to360' | '-180to180' | null;
|
|
72
|
+
progression: 'linear' | 'easeinout' | 'easein' | 'easeout' | AnimationProgression;
|
|
73
|
+
} & OBJ_ElementAnimationStep;
|
|
74
|
+
/**
|
|
75
|
+
* {@link ScenarioAnimationStep} options object
|
|
76
|
+
*
|
|
77
|
+
* @extends OBJ_ElementAnimationStep
|
|
78
|
+
*
|
|
79
|
+
* @property {string} [target]
|
|
80
|
+
* @property {null | string | OBJ_ScenarioVelocity} [velocity] velocity
|
|
81
|
+
* will override duration with a calculated duration based on
|
|
82
|
+
* the `start`, `target` and `velocity`. If `null` is used
|
|
83
|
+
* then `duration` will not be overriden. Any scenario velocity elements that
|
|
84
|
+
* are undefined will default to 1 (`null`)
|
|
85
|
+
* @property {number | null} [maxDuration] maximum duration to clip animation
|
|
86
|
+
* to where `null` is unlimited (`null`)
|
|
87
|
+
* @property {number} [zeroDurationThreshold] value considered 0 to stop
|
|
88
|
+
* animation - this is useful when numbers get very small and rounding problems
|
|
89
|
+
* with javascripts floating point implementation arise
|
|
90
|
+
* @property {OBJ_TranslationPath} [path] translation path style and options
|
|
91
|
+
* (`{ style: 'linear' }`)
|
|
92
|
+
* @property {0 | 1 | -1 | 2} [rotDirection] where `0` is quickest direction,
|
|
93
|
+
* `1` is positive of CCW direction, `-1` is negative of CW direction and `2` is
|
|
94
|
+
* whichever direction doesn't pass through angle 0.
|
|
95
|
+
* @property {'0to360' | '-180to180' | null} [clipRotationTo]
|
|
96
|
+
* @property {'linear' | 'easeinout' | 'easein' | 'easeout' | AnimationProgression} [progression]
|
|
97
|
+
* (`'easeinout'`)
|
|
98
|
+
* @interface
|
|
99
|
+
* @group Misc Animation
|
|
100
|
+
*/
|
|
101
|
+
export type OBJ_ScenariosAnimationStep = {
|
|
102
|
+
target?: string;
|
|
103
|
+
velocity?: OBJ_ScenarioVelocity;
|
|
104
|
+
maxDuration?: number;
|
|
105
|
+
zeroDurationThreshold?: number;
|
|
106
|
+
allDurationsSame?: boolean;
|
|
107
|
+
path?: OBJ_TranslationPath;
|
|
108
|
+
rotDirection: 0 | 1 | -1 | 2;
|
|
109
|
+
clipRotationTo: '0to360' | '-180to180' | null;
|
|
110
|
+
progression: 'linear' | 'easeinout' | 'easein' | 'easeout' | AnimationProgression;
|
|
111
|
+
} & OBJ_ElementAnimationStep;
|
|
112
|
+
/**
|
|
113
|
+
* Scenario Animation Step
|
|
114
|
+
*
|
|
115
|
+
* 
|
|
116
|
+
*
|
|
117
|
+
* A scenario defines an element's transform and color and can be used to make
|
|
118
|
+
* code more readable and reusable.
|
|
119
|
+
*
|
|
120
|
+
* By default, the scenario will start with the element's current transform and
|
|
121
|
+
* color.
|
|
122
|
+
*
|
|
123
|
+
* @extends ElementAnimationStep
|
|
124
|
+
* @param {OBJ_ScenarioAnimationStep} options
|
|
125
|
+
*
|
|
126
|
+
* @see To test examples, append them to the
|
|
127
|
+
* <a href="#animation-boilerplate">boilerplate</a>
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* // NOTE - use these scenario definitions for all examples below
|
|
131
|
+
* p.scenarios['center'] = { position: [0, 0], scale: [1, 1], color: [1, 0, 0, 1] };
|
|
132
|
+
* p.scenarios['right'] = { position: [1, 0], scale: [2, 1], color: [0, 0, 1, 1] };
|
|
133
|
+
* p.scenarios['bottom'] = { position: [0, -0.5], scale: [0.5, 1], color: [0, 0.5, 0, 1] };
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* // Using duration
|
|
137
|
+
* p.animations.new()
|
|
138
|
+
* .scenario({ target: 'right', duration: 2 })
|
|
139
|
+
* .scenario({ target: 'bottom', duration: 2 })
|
|
140
|
+
* .scenario({ target: 'center', duration: 2 })
|
|
141
|
+
* .start();
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* // Using velocity
|
|
145
|
+
* p.animations.new()
|
|
146
|
+
* .scenario({
|
|
147
|
+
* target: 'right',
|
|
148
|
+
* velocity: { position: 0.5, scale: 0.2 },
|
|
149
|
+
* })
|
|
150
|
+
* .scenario({ target: 'bottom', velocity: { position: 0.5 } })
|
|
151
|
+
* .scenario({ target: 'center', velocity: { color: 0.2 } })
|
|
152
|
+
* .start();
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* // Different ways to create a stand-alone step
|
|
156
|
+
* const step1 = p.animations.scenario({
|
|
157
|
+
* target: 'right',
|
|
158
|
+
* duration: 2,
|
|
159
|
+
* });
|
|
160
|
+
* const step2 = new Fig.Animation.ScenarioAnimationStep({
|
|
161
|
+
* element: p,
|
|
162
|
+
* target: 'bottom',
|
|
163
|
+
* duration: 2,
|
|
164
|
+
* });
|
|
165
|
+
*
|
|
166
|
+
* p.animations.new()
|
|
167
|
+
* .then(step1)
|
|
168
|
+
* .then(step2)
|
|
169
|
+
* .start();
|
|
170
|
+
* @group Animation
|
|
171
|
+
*/
|
|
172
|
+
export default class ScenarioAnimationStep extends ParallelAnimationStep {
|
|
173
|
+
element: FigureElement | null | undefined;
|
|
174
|
+
scenario: {
|
|
175
|
+
start: (string | OBJ_Scenario) | null | undefined;
|
|
176
|
+
target: (string | OBJ_Scenario) | null | undefined;
|
|
177
|
+
rotDirection: 0 | 1 | -1 | 2;
|
|
178
|
+
path: OBJ_TranslationPath;
|
|
179
|
+
velocity: OBJ_ScenarioVelocity | null | undefined;
|
|
180
|
+
maxDuration: number | null | undefined;
|
|
181
|
+
allDurationsSame: boolean;
|
|
182
|
+
zeroDurationThreshold: number;
|
|
183
|
+
clipRotationTo: '0to360' | '-180to180' | null;
|
|
184
|
+
progression: 'linear' | 'easeinout' | 'easein' | 'easeout' | AnimationProgression;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* @hideconstructor
|
|
188
|
+
*/
|
|
189
|
+
constructor(...optionsIn: Array<OBJ_ScenarioAnimationStep>);
|
|
190
|
+
_getStateProperties(): string[];
|
|
191
|
+
_getStateName(): string;
|
|
192
|
+
getDuration(start: {
|
|
193
|
+
transform?: Transform;
|
|
194
|
+
color?: TypeColor;
|
|
195
|
+
isShown?: boolean;
|
|
196
|
+
opacity?: number;
|
|
197
|
+
}, target: {
|
|
198
|
+
transform?: Transform;
|
|
199
|
+
color?: TypeColor;
|
|
200
|
+
isShown?: boolean;
|
|
201
|
+
}): number[];
|
|
202
|
+
start(startTime?: AnimationStartTime): void;
|
|
203
|
+
_dup(): ScenarioAnimationStep;
|
|
204
|
+
}
|