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.
- package/figureone.min.js +1 -1
- package/index.js +79167 -0
- package/package.json +15 -1
- package/types/index.d.ts +132 -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,587 @@
|
|
|
1
|
+
import { Transform, Point, Line } from '../../tools/g2';
|
|
2
|
+
import type { TypeParsablePoint, TypeParsableBuffer, TypeBorder, TypeXAlign, TypeYAlign } from '../../tools/g2';
|
|
3
|
+
import { FigureElementCollection, FigureElementPrimitive } from '../Element';
|
|
4
|
+
import EquationLabel from './EquationLabel';
|
|
5
|
+
import type { TypeLabelOrientation, TypeLabelLocation, TypeLabelSubLocation } from './EquationLabel';
|
|
6
|
+
import { Equation } from '../Equation/Equation';
|
|
7
|
+
import type { TypeWhen } from '../TimeKeeper';
|
|
8
|
+
import type { OBJ_LineArrows, OBJ_LineArrow, TypeArrowHead } from '../geometries/arrow';
|
|
9
|
+
import type { OBJ_Pulse, FigureElement } from '../Element';
|
|
10
|
+
import type { EQN_Equation } from '../Equation/Equation';
|
|
11
|
+
import * as animation from '../Animation/Animation';
|
|
12
|
+
import type { OBJ_CustomAnimationStep, OBJ_TriggerAnimationStep } from '../Animation/Animation';
|
|
13
|
+
import type { TypeColor, TypeDash, OBJ_Font } from '../../tools/types';
|
|
14
|
+
import type { OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
|
|
15
|
+
import type FigureCollections from './FigureCollections';
|
|
16
|
+
/**
|
|
17
|
+
* Width pulse options object.
|
|
18
|
+
*
|
|
19
|
+
* @property {number} [line] width scale
|
|
20
|
+
* @property {number | OBJ_Pulse} [label] label pulse options or scale. Use
|
|
21
|
+
* the options object for more control of how the label is pulsed (for example
|
|
22
|
+
* if the label should be pulsed from its bottom rather than its center).
|
|
23
|
+
* @property {number} [arrow] arrow pulse scale
|
|
24
|
+
* @property {function(): void} [done] execute when pulsing is finished
|
|
25
|
+
* @property {number} [duration] pulse duration in seconds
|
|
26
|
+
* @property {number} [frequency] pulse frequency in pulses per second
|
|
27
|
+
* @property {TypeWhen} [when] when to start the pulse (`'nextFrame'`)
|
|
28
|
+
* @interface
|
|
29
|
+
* @group Misc Shapes
|
|
30
|
+
*/
|
|
31
|
+
export type OBJ_PulseWidth = {
|
|
32
|
+
line?: number;
|
|
33
|
+
label?: number | OBJ_Pulse;
|
|
34
|
+
arrow?: number;
|
|
35
|
+
done?: (() => void) | null | undefined;
|
|
36
|
+
duration?: number;
|
|
37
|
+
when?: TypeWhen;
|
|
38
|
+
frequency?: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Collections line label options object.
|
|
42
|
+
*
|
|
43
|
+
* A line can be annotated with a label using the `text` property and can be:
|
|
44
|
+
* - text (`string`, or Array<`string`)
|
|
45
|
+
* - an equation (`Equation`, `EQN_Equation`)
|
|
46
|
+
* - real length of line (`null`)
|
|
47
|
+
*
|
|
48
|
+
* In all cases, an actual {@link Equation} is created as the label. The
|
|
49
|
+
* equation can have multiple forms, which can be set using the `showForm`
|
|
50
|
+
* method.
|
|
51
|
+
*
|
|
52
|
+
* If `text`: `string`, then an equation with a single form named `base` will
|
|
53
|
+
* be created with a single element being the string text.
|
|
54
|
+
*
|
|
55
|
+
* If `text`: `Array<string>`, then an equation with a form for each element
|
|
56
|
+
* of the array is created. Each form is named '0', '1', '2'... corresponding
|
|
57
|
+
* with the index of the array. Each form is has a single element, being the
|
|
58
|
+
* text at that index.
|
|
59
|
+
*
|
|
60
|
+
* Use `text`: `Equation` or `EQN_Equation` to create completely custom
|
|
61
|
+
* equations with any forms desirable.
|
|
62
|
+
*
|
|
63
|
+
* If the label text is the real length of the line (`null`), then the number
|
|
64
|
+
* of decimal places can be selected with `precision`.
|
|
65
|
+
*
|
|
66
|
+
* The space between the line and the label is defined with `offset`. An
|
|
67
|
+
* `offset` of 0 puts the center of the label on the line. Any
|
|
68
|
+
* positive or negative value of offset will move the label so no part of the
|
|
69
|
+
* label overlaps the line, and then the closest part of the label is separated
|
|
70
|
+
* from the line by `offset`.
|
|
71
|
+
*
|
|
72
|
+
* To situate the label on the line, use `linePosition`, `location` and
|
|
73
|
+
* `subLocation`. By default the label will be a percentage `linePosition`
|
|
74
|
+
* along the line. `location` then defines which side of the line the label is
|
|
75
|
+
* on, while `subLocation` defines the backup location for invalid cases of
|
|
76
|
+
* `location`. See {@link TypeLabelLocation} and
|
|
77
|
+
* {@link TypeLabelSubLocation}. `location` can additionaly place the
|
|
78
|
+
* labels off the ends of the line.
|
|
79
|
+
*
|
|
80
|
+
* To automatically update the label location and orientation as the line
|
|
81
|
+
* transform (translation, rotation or scale) changes then use `update: true`.
|
|
82
|
+
*
|
|
83
|
+
* @see {@link COL_Line}
|
|
84
|
+
*
|
|
85
|
+
* @property {null | string | Array<string> | Equation | EQN_Equation } text
|
|
86
|
+
* @property {number} [precision]
|
|
87
|
+
* @property {number} [offset]
|
|
88
|
+
* @property {number} [linePosition]
|
|
89
|
+
* @property {TypeLabelLocation} [location]
|
|
90
|
+
* @property {TypeLabelSubLocation} [subLocation]
|
|
91
|
+
* @property {TypeLabelOrientation} [orientation]
|
|
92
|
+
* @property {boolean} [update] (`false`)
|
|
93
|
+
* @property {number} [scale] size of the label
|
|
94
|
+
* @property {TypeColor} [color]
|
|
95
|
+
* @property {OBJ_Font} [font] default font for label
|
|
96
|
+
* @interface
|
|
97
|
+
* @group Misc Shapes
|
|
98
|
+
*/
|
|
99
|
+
export type OBJ_LineLabel = {
|
|
100
|
+
text: null | string | Array<string> | Equation | EQN_Equation;
|
|
101
|
+
precision?: number;
|
|
102
|
+
offset?: number;
|
|
103
|
+
linePosition?: number;
|
|
104
|
+
location?: TypeLabelLocation;
|
|
105
|
+
subLocation?: TypeLabelSubLocation;
|
|
106
|
+
orientation?: TypeLabelOrientation;
|
|
107
|
+
update?: boolean;
|
|
108
|
+
scale?: number;
|
|
109
|
+
color?: TypeColor;
|
|
110
|
+
font?: OBJ_Font;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Line move options object.
|
|
114
|
+
*
|
|
115
|
+
* The `'centerTranslateEndRotation`' movement will move the line
|
|
116
|
+
* when touched within the `middleLength` percentage of the line
|
|
117
|
+
* and rotate it otherwise.
|
|
118
|
+
*
|
|
119
|
+
* @property {boolean} [movable] `true` to make movable (`true`)
|
|
120
|
+
* @property {'translation' | 'rotation' | 'centerTranslateEndRotation' | 'scale'} [type]
|
|
121
|
+
* @property {number} [middleLength] length of the middle section of line that
|
|
122
|
+
* allows for translation movement in percent of total length (`0.333`)
|
|
123
|
+
* @property {boolean} [includeLabelInTouchBoundary] `true` to include the
|
|
124
|
+
* line's label in the touch boundary for `'centerTranslateEndRotation'`
|
|
125
|
+
* ('false`)
|
|
126
|
+
* @interface
|
|
127
|
+
* @group Misc Shapes
|
|
128
|
+
*/
|
|
129
|
+
export type OBJ_LineMove = {
|
|
130
|
+
type?: 'translation' | 'rotation' | 'centerTranslateEndRotation' | 'scale';
|
|
131
|
+
middleLength?: number;
|
|
132
|
+
includeLabelInTouchBoundary?: boolean;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* setMovable options object for {@link COL_Line}.
|
|
136
|
+
*
|
|
137
|
+
* @extends OBJ_LineMove
|
|
138
|
+
*
|
|
139
|
+
* @property {boolean} [movable] `true` to make movable (`true`)
|
|
140
|
+
* @interface
|
|
141
|
+
* @group Misc Shapes
|
|
142
|
+
*/
|
|
143
|
+
export type OBJ_MovableLine = {
|
|
144
|
+
movable?: boolean;
|
|
145
|
+
} & OBJ_LineMove;
|
|
146
|
+
/**
|
|
147
|
+
* {@link CollectionsLine} options object that extends {@link OBJ_Collection}
|
|
148
|
+
* options object (without `parent`).
|
|
149
|
+
*
|
|
150
|
+
*
|
|
151
|
+
* The Collections Line is a convient and powerful line
|
|
152
|
+
* {@link FigureElementCollection} that includes the line, arrows, a label
|
|
153
|
+
* annotation and some methods to make it convient to use dynamically.
|
|
154
|
+
*
|
|
155
|
+
* A line can either be defined by its two end points (`p1`, `p2`), or a
|
|
156
|
+
* point (`p1`), `length` and `angle`.
|
|
157
|
+
*
|
|
158
|
+
* `offset` can be used to draw the line some offset away from the line
|
|
159
|
+
* definition where a positive offset is on the side of the line that the line
|
|
160
|
+
* rotates toward when rotating in the positive direction. This is especially
|
|
161
|
+
* useful for creating lines that show dimensions of shapes.
|
|
162
|
+
*
|
|
163
|
+
* The line also has a control point which is positioned on the line with the
|
|
164
|
+
* `align` property. The control point is the line's center of rotation, and
|
|
165
|
+
* fixes the point from which the line changes length. This is also the point
|
|
166
|
+
* where the line collection position will be if `getPosition` is called on the
|
|
167
|
+
* element.
|
|
168
|
+
*
|
|
169
|
+
* For instance, setting the control point at `align: 'start'` will mean that
|
|
170
|
+
* if the line can rotate, it will rotate around `p1`, and if the length is
|
|
171
|
+
* changed, then `p1` will remain fixed while `p2` changes.
|
|
172
|
+
*
|
|
173
|
+
* `width` sets the width of the line. Setting the width to 0 will hide the
|
|
174
|
+
* line itself, but if arrows or a label are defined they will still be
|
|
175
|
+
* displayed.
|
|
176
|
+
*
|
|
177
|
+
* Use the `label` property to define and position a label relative to the line.
|
|
178
|
+
* The label can be any string, equation or the actual length of the line and
|
|
179
|
+
* be oriented relative to the line or always be horizontal.
|
|
180
|
+
*
|
|
181
|
+
* Use the `arrow` and `dash` properties to define arrows and the line style.
|
|
182
|
+
*
|
|
183
|
+
* Pulsing this collection normally would pulse both the length and width of
|
|
184
|
+
* the line. If it often desirable to pulse a line without changing its length,
|
|
185
|
+
* and so this collection provides a method `pulseWidth` to allow this. This
|
|
186
|
+
* options object can define the default values for pulseWidth if desired.
|
|
187
|
+
*
|
|
188
|
+
* Default pulse values can then be specified with the `pulse` property.
|
|
189
|
+
*
|
|
190
|
+
* @extends OBJ_Collection
|
|
191
|
+
*
|
|
192
|
+
* @property {TypeParsablePoint} [p1] First point of line
|
|
193
|
+
* @property {TypeParsablePoint} [p2] Will override `length`/`angle` definition
|
|
194
|
+
* @property {number} [angle] line angle
|
|
195
|
+
* @property {number} [length] line length
|
|
196
|
+
* @property {number} [offset] line offset
|
|
197
|
+
* @property {'start' | 'end' | 'center' | number} [align] rotation center of
|
|
198
|
+
* line (only needed if rotating line)
|
|
199
|
+
* @property {number} [width] line width
|
|
200
|
+
* @property {OBJ_LineLabel} [label] label annotation
|
|
201
|
+
* @property {OBJ_LineArrows | TypeArrowHead} [arrow] line arrow(s)
|
|
202
|
+
* @property {TypeDash} [dash] make the line dashed
|
|
203
|
+
* @property {OBJ_PulseWidth} [pulseWidth] default options for pulseWidth pulse
|
|
204
|
+
* @property {OBJ_Pulse} [pulse] default options for normal pulse
|
|
205
|
+
* @property {OBJ_LineMove} [move] line move options
|
|
206
|
+
* @interface
|
|
207
|
+
* @group 2D Shape Collections
|
|
208
|
+
*/
|
|
209
|
+
export type COL_Line = {
|
|
210
|
+
p1?: TypeParsablePoint;
|
|
211
|
+
p2?: TypeParsablePoint;
|
|
212
|
+
length?: number;
|
|
213
|
+
angle?: number;
|
|
214
|
+
offset?: number;
|
|
215
|
+
align?: 'start' | 'end' | 'center' | number;
|
|
216
|
+
width?: number;
|
|
217
|
+
label?: OBJ_LineLabel;
|
|
218
|
+
arrow?: OBJ_LineArrows | TypeArrowHead;
|
|
219
|
+
dash?: TypeDash;
|
|
220
|
+
pulseWidth?: OBJ_PulseWidth;
|
|
221
|
+
pulse?: OBJ_Pulse;
|
|
222
|
+
move?: OBJ_LineMove;
|
|
223
|
+
} & OBJ_Collection;
|
|
224
|
+
declare class LineLabel extends EquationLabel {
|
|
225
|
+
offset: number;
|
|
226
|
+
location: TypeLabelLocation;
|
|
227
|
+
subLocation: TypeLabelSubLocation;
|
|
228
|
+
orientation: TypeLabelOrientation;
|
|
229
|
+
linePosition: number;
|
|
230
|
+
precision: number;
|
|
231
|
+
constructor(collections: FigureCollections, labelText: string | Equation | EQN_Equation | Array<string>, color: TypeColor, offset: number, location: TypeLabelLocation | undefined, subLocation: TypeLabelSubLocation | undefined, orientation: TypeLabelOrientation | undefined, linePosition: number | undefined, // number where 0 is end1, and 1 is end2
|
|
232
|
+
scale: number | undefined, precision: number | undefined, font: OBJ_Font);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Grow line animation step.
|
|
236
|
+
*
|
|
237
|
+
* @property {number} [start] line length to grow from (`current length`)
|
|
238
|
+
* @property {number} [target] line length to grow to (`current length`)
|
|
239
|
+
* @extends OBJ_CustomAnimationStep
|
|
240
|
+
* @interface
|
|
241
|
+
* @group Misc Shapes
|
|
242
|
+
*/
|
|
243
|
+
export type OBJ_LengthAnimationStep = {
|
|
244
|
+
start?: number;
|
|
245
|
+
target?: number;
|
|
246
|
+
} & OBJ_CustomAnimationStep;
|
|
247
|
+
/**
|
|
248
|
+
* Pulse Width animation step.
|
|
249
|
+
*
|
|
250
|
+
*
|
|
251
|
+
* @property {number} [line] width scale
|
|
252
|
+
* @property {number | OBJ_Pulse} [label] label pulse options or scale. Use
|
|
253
|
+
* the options object for more control of how the label is pulsed (for example
|
|
254
|
+
* if the label should be pulsed from its bottom rather than its center).
|
|
255
|
+
* @property {number} [arrow] arrow pulse scale
|
|
256
|
+
* @property {function(): void} [done] execute when pulsing is finished
|
|
257
|
+
* @property {number} [duration] pulse duration in seconds
|
|
258
|
+
* @property {number} [frequency] pulse frequency in pulses per second
|
|
259
|
+
* @extends OBJ_TriggerAnimationStep
|
|
260
|
+
* @interface
|
|
261
|
+
* @group Misc Shapes
|
|
262
|
+
*/
|
|
263
|
+
export type OBJ_PulseWidthAnimationStep = {
|
|
264
|
+
line?: number;
|
|
265
|
+
label?: number | OBJ_Pulse;
|
|
266
|
+
arrow?: number;
|
|
267
|
+
done?: (() => void) | null | undefined;
|
|
268
|
+
duration?: number;
|
|
269
|
+
frequency?: number;
|
|
270
|
+
} & OBJ_TriggerAnimationStep;
|
|
271
|
+
/**
|
|
272
|
+
* {@link FigureElementCollection} representing a line.
|
|
273
|
+
*
|
|
274
|
+
* <p class="inline_gif"><img src="./apiassets/advline_pulse.gif" class="inline_gif_image"></p>
|
|
275
|
+
*
|
|
276
|
+
* <p class="inline_gif"><img src="./apiassets/advline_grow.gif" class="inline_gif_image"></p>
|
|
277
|
+
*
|
|
278
|
+
* <p class="inline_gif"><img src="./apiassets/advline_multimove.gif" class="inline_gif_image"></p>
|
|
279
|
+
*
|
|
280
|
+
* This object defines a convient and powerful line
|
|
281
|
+
* {@link FigureElementCollection} that includes a solid or dashed line,
|
|
282
|
+
* arrows, a label annotation that can self align with line orientation, and
|
|
283
|
+
* some methods to make it convient to use dynamically.
|
|
284
|
+
*
|
|
285
|
+
* See {@link COL_Line} for the options that can be used when creating the line.
|
|
286
|
+
*
|
|
287
|
+
* The object contains a two additional animation steps. `length`
|
|
288
|
+
* animates changing the line length, and `pulseWidth` animates the
|
|
289
|
+
* `pulseWidth` method. The animation steps are available in
|
|
290
|
+
* the animation manager ({@link FigureElement}.animations),
|
|
291
|
+
* and in the animation builder
|
|
292
|
+
* (<a href="#animationmanagernew">animations.new</a>
|
|
293
|
+
* and <a href="#animationmanagerbuilder">animations.builder</a>).
|
|
294
|
+
*
|
|
295
|
+
* Some of the useful methods included in an collections line are:
|
|
296
|
+
* - <a href="#collectionslinepulsewidth">pulseWidth</a> - pulses the line without
|
|
297
|
+
* changing its length
|
|
298
|
+
* - <a href="#collectionslinegrow">grow</a> - starts and animation that executes
|
|
299
|
+
* a single `length` animation
|
|
300
|
+
* step
|
|
301
|
+
* - <a href="#collectionslinesetmovable">grow</a> - overrides
|
|
302
|
+
* <a href="#figureelementsetmovable">FigureElement.setMovable</a> and
|
|
303
|
+
* allowing for more complex move options.
|
|
304
|
+
*
|
|
305
|
+
* @see See {@link OBJ_LengthAnimationStep} for angle animation step options.
|
|
306
|
+
*
|
|
307
|
+
* See {@link OBJ_PulseWidthAnimationStep} for pulse angle animation step
|
|
308
|
+
* options.
|
|
309
|
+
*
|
|
310
|
+
* To test examples below, append them to the
|
|
311
|
+
* <a href="#drawing-boilerplate">boilerplate</a>.
|
|
312
|
+
*
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* // Pulse an annotated line
|
|
316
|
+
* figure.add({
|
|
317
|
+
* name: 'l',
|
|
318
|
+
* make: 'collections.line',
|
|
319
|
+
* p1: [-1, 0],
|
|
320
|
+
* p2: [1, 0],
|
|
321
|
+
* arrow: 'triangle',
|
|
322
|
+
* label: {
|
|
323
|
+
* text: 'length',
|
|
324
|
+
* offset: 0.04,
|
|
325
|
+
* },
|
|
326
|
+
* });
|
|
327
|
+
*
|
|
328
|
+
* figure.elements._l.pulseWidth({ duration: 2 });
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* // Animate growing a line while showing it's length
|
|
332
|
+
* figure.add({
|
|
333
|
+
* name: 'l',
|
|
334
|
+
* make: 'collections.line',
|
|
335
|
+
* p1: [-1, 0],
|
|
336
|
+
* p2: [-0.5, 0],
|
|
337
|
+
* align: 'start',
|
|
338
|
+
* arrow: { end: { head: 'barb', scale: 2 } },
|
|
339
|
+
* label: {
|
|
340
|
+
* text: null,
|
|
341
|
+
* offset: 0.03,
|
|
342
|
+
* precision: 2,
|
|
343
|
+
* location: 'start'
|
|
344
|
+
* },
|
|
345
|
+
* });
|
|
346
|
+
*
|
|
347
|
+
* const l = figure.elements._l;
|
|
348
|
+
* l.animations.new()
|
|
349
|
+
* .length({ start: 0.5, target: 2, duration: 2 })
|
|
350
|
+
* .start();
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* // Example showing dashed line with an equation label that stays horizontal
|
|
354
|
+
* const l = figure.collections.line({
|
|
355
|
+
* p1: [0, 0],
|
|
356
|
+
* p2: [1.4, 0],
|
|
357
|
+
* align: 'start',
|
|
358
|
+
* label: {
|
|
359
|
+
* text: { // label text is an equation
|
|
360
|
+
* elements: {
|
|
361
|
+
* twopi: '2\u03C0',
|
|
362
|
+
* },
|
|
363
|
+
* forms: {
|
|
364
|
+
* base: ['twopi', ' ', { frac: ['a', 'vinculum', 'b'] } ]
|
|
365
|
+
* },
|
|
366
|
+
* },
|
|
367
|
+
* offset: 0.03,
|
|
368
|
+
* orientation: 'horizontal', // keep label horizontal
|
|
369
|
+
* location: 'top', // keep label on top of line
|
|
370
|
+
* },
|
|
371
|
+
* dash: [0.08, 0.02, 0.02, 0.02],
|
|
372
|
+
* });
|
|
373
|
+
* figure.add('l', l);
|
|
374
|
+
* l.setMovable({ type: 'centerTranslateEndRotation'})
|
|
375
|
+
* l.setAutoUpdate();
|
|
376
|
+
*
|
|
377
|
+
* @group 2D Shape Collections
|
|
378
|
+
*/
|
|
379
|
+
export default class CollectionsLine extends FigureElementCollection {
|
|
380
|
+
_line: FigureElementPrimitive | null | undefined;
|
|
381
|
+
_movePad: FigureElementPrimitive | null | undefined;
|
|
382
|
+
_rotPad: FigureElementPrimitive | null | undefined;
|
|
383
|
+
_startPad: FigureElementPrimitive | null | undefined;
|
|
384
|
+
_arrow1: FigureElementPrimitive | null | undefined;
|
|
385
|
+
_arrow2: FigureElementPrimitive | null | undefined;
|
|
386
|
+
_label: null | {
|
|
387
|
+
_base: FigureElementPrimitive;
|
|
388
|
+
} & FigureElementCollection;
|
|
389
|
+
label: LineLabel | null | undefined;
|
|
390
|
+
arrow1: {
|
|
391
|
+
height: number;
|
|
392
|
+
} | null | undefined;
|
|
393
|
+
arrow2: {
|
|
394
|
+
height: number;
|
|
395
|
+
} | null | undefined;
|
|
396
|
+
line: Line;
|
|
397
|
+
width: number;
|
|
398
|
+
localXPosition: number;
|
|
399
|
+
alignDraw: 'start' | 'end' | 'center' | number;
|
|
400
|
+
dash: TypeDash;
|
|
401
|
+
arrow: {
|
|
402
|
+
start?: OBJ_LineArrow;
|
|
403
|
+
end?: OBJ_LineArrow;
|
|
404
|
+
} | null | undefined;
|
|
405
|
+
showRealLength: boolean;
|
|
406
|
+
autoUpdateSubscriptionId: number;
|
|
407
|
+
shapes: Record<string, any>;
|
|
408
|
+
equation: Record<string, any>;
|
|
409
|
+
isTouchDevice: boolean;
|
|
410
|
+
scaleTransformMethodName: string;
|
|
411
|
+
animateLengthToStepFunctionName: string;
|
|
412
|
+
animateLengthToDoneFunctionName: string;
|
|
413
|
+
pulseWidthDoneCallbackName: string;
|
|
414
|
+
pulseWidthDefaults: {
|
|
415
|
+
line: number;
|
|
416
|
+
label: number;
|
|
417
|
+
arrow: number;
|
|
418
|
+
duration: number;
|
|
419
|
+
frequency: number;
|
|
420
|
+
};
|
|
421
|
+
multiMove: {
|
|
422
|
+
midLength: number;
|
|
423
|
+
includeLabelInTouchBoundary: boolean;
|
|
424
|
+
};
|
|
425
|
+
animateLengthToOptions: {
|
|
426
|
+
initialLength: number;
|
|
427
|
+
deltaLength: number;
|
|
428
|
+
callback: string | (() => void) | null | undefined;
|
|
429
|
+
onStepCallback: string | ((p1: number, p2: number) => void) | null | undefined;
|
|
430
|
+
finishOnCancel: boolean;
|
|
431
|
+
};
|
|
432
|
+
pulseWidthOptions: {
|
|
433
|
+
oldCallback: string | (() => void) | null | undefined;
|
|
434
|
+
oldTransformMethod: string | ((p1: number, p2: Point | null | undefined) => Transform) | null | undefined;
|
|
435
|
+
};
|
|
436
|
+
animations: {
|
|
437
|
+
length: (...opt: Array<OBJ_LengthAnimationStep>) => animation.CustomAnimationStep;
|
|
438
|
+
pulseWidth: (...opt: Array<OBJ_PulseWidth>) => animation.TriggerAnimationStep;
|
|
439
|
+
} & animation.AnimationManager;
|
|
440
|
+
lastParentRotationOffset: number;
|
|
441
|
+
/**
|
|
442
|
+
* @hideconstructor
|
|
443
|
+
*/
|
|
444
|
+
constructor(collections: FigureCollections, isTouchDevice: boolean, options?: COL_Line);
|
|
445
|
+
fontUpdated(): void;
|
|
446
|
+
/** A line has:
|
|
447
|
+
* - length
|
|
448
|
+
* - p1, p2
|
|
449
|
+
* - angle
|
|
450
|
+
* - position
|
|
451
|
+
* - reference alignment
|
|
452
|
+
*
|
|
453
|
+
* Two ways to define a line:
|
|
454
|
+
* - p1, p2
|
|
455
|
+
* - position, align, length, angle
|
|
456
|
+
*
|
|
457
|
+
* Line is defined by:
|
|
458
|
+
* - primitive line: full length, angle = 0, aligned in draw space with align
|
|
459
|
+
* - transform.translate: moves align position
|
|
460
|
+
* - transform.rotate: changes angle
|
|
461
|
+
*/
|
|
462
|
+
transformToLine(): void;
|
|
463
|
+
_getStateProperties(options: Record<string, any>): string[];
|
|
464
|
+
_fromState(state: Record<string, any>): this;
|
|
465
|
+
stateSet(): void;
|
|
466
|
+
pulseWidthDone(): void;
|
|
467
|
+
/**
|
|
468
|
+
* Pulse the line so that it's width pulses and its length doesn't change.
|
|
469
|
+
*
|
|
470
|
+
* The pulse scales of the line, label and arrows can all be defined
|
|
471
|
+
* separately.
|
|
472
|
+
*/
|
|
473
|
+
pulseWidth(options?: OBJ_PulseWidth): void;
|
|
474
|
+
addArrow(lineEnd: 'start' | 'end'): void;
|
|
475
|
+
/**
|
|
476
|
+
* Use this method to enable or disable movability of the line.
|
|
477
|
+
*
|
|
478
|
+
* @param {OBJ_MovableLine | boolean} [movableOrOptions] `true` to
|
|
479
|
+
* make movable, `false` to make not movable or use options to
|
|
480
|
+
* set different kinds of movability.
|
|
481
|
+
*/
|
|
482
|
+
setMove(movableOrOptions?: any): void;
|
|
483
|
+
setMultiMovable(middleLengthPercent: number): void;
|
|
484
|
+
moved(value: Point | number): void;
|
|
485
|
+
/**
|
|
486
|
+
* Use this to manually update the rotation of the line collection.
|
|
487
|
+
*/
|
|
488
|
+
updateMoveTransform(t?: Transform): void;
|
|
489
|
+
addLabel(labelText: string | Equation | EQN_Equation | Array<string>, offset: number, location: TypeLabelLocation | undefined, subLocation: TypeLabelSubLocation | undefined, orientation: TypeLabelOrientation | undefined, linePosition: number | undefined, // number where 0 is end1, and 1 is end2
|
|
490
|
+
scale: number | undefined, color: TypeColor | undefined, precision: number | undefined, update: boolean | undefined, font: OBJ_Font, otherOptions?: {
|
|
491
|
+
isTouchable?: boolean;
|
|
492
|
+
touchBorder?: TypeParsableBuffer | TypeBorder;
|
|
493
|
+
onClick?: null | string | (() => void);
|
|
494
|
+
}): void;
|
|
495
|
+
/**
|
|
496
|
+
* Turn on and off auto label location and orientation updates when line
|
|
497
|
+
* transform changes. When a line is created with a label, auto update
|
|
498
|
+
* is turned off by default.
|
|
499
|
+
*/
|
|
500
|
+
setAutoUpdate(update?: boolean): void;
|
|
501
|
+
/**
|
|
502
|
+
* Get line length
|
|
503
|
+
* @return {number}
|
|
504
|
+
*/
|
|
505
|
+
getLength(): number;
|
|
506
|
+
/**
|
|
507
|
+
* Get line angle
|
|
508
|
+
* @param {'deg' | 'rad'} [units]
|
|
509
|
+
* @return {number}
|
|
510
|
+
*/
|
|
511
|
+
getAngle(units?: 'deg' | 'rad'): number;
|
|
512
|
+
/**
|
|
513
|
+
* Change the text of the label
|
|
514
|
+
*/
|
|
515
|
+
setLabel(text: string): void;
|
|
516
|
+
/**
|
|
517
|
+
* Get the text of the label
|
|
518
|
+
*/
|
|
519
|
+
getLabel(): string;
|
|
520
|
+
/**
|
|
521
|
+
* Set the label to be the real length of the line
|
|
522
|
+
*/
|
|
523
|
+
setLabelToRealLength(): void;
|
|
524
|
+
/**
|
|
525
|
+
* Manually update the label orientations with a custom rotation offset.
|
|
526
|
+
*
|
|
527
|
+
* Automatic updating can be done with
|
|
528
|
+
* <a href="collectionsline#setautoupdate">setAutoUpdate</a>
|
|
529
|
+
* @param {number | null} rotationOffset
|
|
530
|
+
*/
|
|
531
|
+
updateLabel(rotationOffset?: number | null): void;
|
|
532
|
+
/**
|
|
533
|
+
* Set the length of the line
|
|
534
|
+
*/
|
|
535
|
+
setLength(length: number, align?: 'start' | 'end' | 'center' | number): void;
|
|
536
|
+
setupLine(): void;
|
|
537
|
+
updateMovePads(): void;
|
|
538
|
+
/**
|
|
539
|
+
* Change the line position, length and angle using end points and an offset.
|
|
540
|
+
*
|
|
541
|
+
* For most lines, an offset of 0 will be desired, as this will position the
|
|
542
|
+
* line ends to be at `p1` and `p2`.
|
|
543
|
+
*
|
|
544
|
+
* A non-positive offset will position the line in parallel with `p1` and `p2`
|
|
545
|
+
* but some offset away. A positive offset will position the line on the side
|
|
546
|
+
* it will rotate toward with positive rotation.
|
|
547
|
+
*/
|
|
548
|
+
setEndPoints(p1: TypeParsablePoint, p2: TypeParsablePoint, offset?: number): void;
|
|
549
|
+
pointFromTo(from: {
|
|
550
|
+
element: FigureElement;
|
|
551
|
+
xAlign: TypeXAlign;
|
|
552
|
+
yAlign: TypeYAlign;
|
|
553
|
+
space: number;
|
|
554
|
+
}, to: {
|
|
555
|
+
element: FigureElement;
|
|
556
|
+
xAlign: TypeXAlign;
|
|
557
|
+
yAlign: TypeYAlign;
|
|
558
|
+
space: number;
|
|
559
|
+
}, autoOutside?: boolean): void;
|
|
560
|
+
/**
|
|
561
|
+
* Create a new animation that executes a single grow animation step.
|
|
562
|
+
*/
|
|
563
|
+
grow(options: OBJ_LengthAnimationStep): void;
|
|
564
|
+
showLineOnly(): void;
|
|
565
|
+
/**
|
|
566
|
+
* Return a geometric {@link Line} object that represents the line
|
|
567
|
+
* @return {Line}
|
|
568
|
+
*/
|
|
569
|
+
getLine(): Line;
|
|
570
|
+
/**
|
|
571
|
+
* Return the start point of the line
|
|
572
|
+
* @return {Point}
|
|
573
|
+
*/
|
|
574
|
+
getP1(): Point;
|
|
575
|
+
/**
|
|
576
|
+
* Return the end point of the line
|
|
577
|
+
* @return {Point}
|
|
578
|
+
*/
|
|
579
|
+
getP2(): Point;
|
|
580
|
+
}
|
|
581
|
+
export type TypeLabelledLine = {
|
|
582
|
+
_line: FigureElementPrimitive;
|
|
583
|
+
_label: {
|
|
584
|
+
_base: FigureElementPrimitive;
|
|
585
|
+
} & Equation;
|
|
586
|
+
} & CollectionsLine;
|
|
587
|
+
export {};
|