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,487 @@
|
|
|
1
|
+
import { Point, RangeBounds, RectBounds } from '../../tools/g2';
|
|
2
|
+
import type { OBJ_RangeBounds, OBJ_RectBounds } from '../../tools/geometry/Bounds';
|
|
3
|
+
import type { OBJ_Font } from '../../tools/types';
|
|
4
|
+
import { FigureElementCollection, FigureElementPrimitive } from '../Element';
|
|
5
|
+
import type { COL_Line } from './Line';
|
|
6
|
+
import type { COL_Angle } from './Angle';
|
|
7
|
+
import type FigureCollections from './FigureCollections';
|
|
8
|
+
import type { OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
|
|
9
|
+
import type { OBJ_Polyline, OBJ_Polygon } from '../FigurePrimitives/FigurePrimitiveTypes2D';
|
|
10
|
+
/**
|
|
11
|
+
* Collections Polyline pad addition options.
|
|
12
|
+
*
|
|
13
|
+
* Each pad is associated with a point of the polyline.
|
|
14
|
+
*
|
|
15
|
+
* @extends OBJ_Polygon
|
|
16
|
+
*
|
|
17
|
+
* @property {boolean} [isMovable] `true` allows moving the pad and the
|
|
18
|
+
* associated polyline point (`false`)
|
|
19
|
+
* @property {OBJ_RangeBounds | OBJ_RectBounds | RangeBounds | RectBounds | 'figure'} [boundary]
|
|
20
|
+
* boundary the pad can move within
|
|
21
|
+
* @interface
|
|
22
|
+
* @group Misc Shapes
|
|
23
|
+
*/
|
|
24
|
+
export type OBJ_PolylinePadSingle = {
|
|
25
|
+
isMovable?: boolean;
|
|
26
|
+
boundary?: OBJ_RangeBounds | OBJ_RectBounds | RangeBounds | RectBounds | 'figure';
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @extends OBJ_PolylinePadSingle
|
|
30
|
+
* @extends OBJ_PolylineCustomization
|
|
31
|
+
* @group Misc Shapes
|
|
32
|
+
*/
|
|
33
|
+
export type OBJ_PolylinePad = {};
|
|
34
|
+
/**
|
|
35
|
+
* Polyline side, angle and pad customization options object
|
|
36
|
+
*
|
|
37
|
+
* 
|
|
38
|
+
*
|
|
39
|
+
* 
|
|
40
|
+
*
|
|
41
|
+
* Side annotations, angle annotations and movable pads in an
|
|
42
|
+
* {@link CollectionsPolyline} are defined with the options objects {@link COL_Line},
|
|
43
|
+
* {@link COL_Angle} and ({@link OBJ_Polygon} & {@link OBJ_PolylinePadSingle})
|
|
44
|
+
* respectively.
|
|
45
|
+
*
|
|
46
|
+
* The properties in this object can be used in the side, angle and movable
|
|
47
|
+
* pad object definitions to allow for customization of specific sides,
|
|
48
|
+
* angles and movable pads.
|
|
49
|
+
*
|
|
50
|
+
* Each side, angle and movable pad has an 0 based index associated with it.
|
|
51
|
+
* The zero index pad is associated with the first point of the polyline. The
|
|
52
|
+
* zero index side is between the first and second point of the polyline, and
|
|
53
|
+
* the zero index angle is between the first, second and third point of the
|
|
54
|
+
* polyline.
|
|
55
|
+
*
|
|
56
|
+
* By default, any properties defined for <a href="adv_polyline#pad">pad</a>
|
|
57
|
+
* will be applied to all pads of the polyline. To customize the first pad in
|
|
58
|
+
* the polyline, an object property with name `'0'` can be used with a value
|
|
59
|
+
* that includes the options object properties that should be customized.
|
|
60
|
+
* Similary, for side and angle annotations, keys with the index name can be
|
|
61
|
+
* used in their options objects to customize specific sides and angles.
|
|
62
|
+
*
|
|
63
|
+
* The `show` and `hide` properties can be used to show and hide specific sides
|
|
64
|
+
* and angles.
|
|
65
|
+
*
|
|
66
|
+
* See {@link OBJ_PulseWidthAnimationStep} for pulse angle animation step
|
|
67
|
+
* options.
|
|
68
|
+
*
|
|
69
|
+
* @property {Array<number>} [show] list of indexes to show
|
|
70
|
+
* @property {Array<number>} [hide] list of indexes to hide
|
|
71
|
+
* @property {COL_Angle | COL_Line | OBJ_PolylinePadSingle} [_index]
|
|
72
|
+
* Customizations of annotation or pad by index where `_index` should be an
|
|
73
|
+
* object key name that is the index
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Hide pad 0, and make pad 2 blue and not filled
|
|
77
|
+
* figure.add({
|
|
78
|
+
* name: 'p',
|
|
79
|
+
* make: 'collections.polyline',
|
|
80
|
+
* points: [[0, 0], [2, 0], [2, 2], [-2, 1]],
|
|
81
|
+
* pad: {
|
|
82
|
+
* radius: 0.2, // OBJ_Polygon
|
|
83
|
+
* color: [1, 0, 0, 1], // OBJ_Polygon
|
|
84
|
+
* touchBorder: 0.1, // OBJ_Polygon
|
|
85
|
+
* isMovable: true,
|
|
86
|
+
* hide: [0],
|
|
87
|
+
* 2: { // Custom pad 2 properties
|
|
88
|
+
* color: [0, 0, 1, 1], // Make blue
|
|
89
|
+
* line: { width: 0.01 } // Use an outline instead of a fill
|
|
90
|
+
* },
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* // Customization of side and angle annotations
|
|
96
|
+
* figure.add({
|
|
97
|
+
* name: 'p',
|
|
98
|
+
* make: 'collections.polyline',
|
|
99
|
+
* points: [[0, 0], [1, 0], [1, 1], [0, 1]],
|
|
100
|
+
* close: true,
|
|
101
|
+
* side: {
|
|
102
|
+
* showLine: false,
|
|
103
|
+
* label: {
|
|
104
|
+
* text: null, // By default, sides are length values
|
|
105
|
+
* location: 'negative',
|
|
106
|
+
* },
|
|
107
|
+
* 0: { label: { text: 'a' } }, // Side 0 is 'a' instead of length
|
|
108
|
+
* },
|
|
109
|
+
* angle: {
|
|
110
|
+
* label: {
|
|
111
|
+
* text: '?',
|
|
112
|
+
* offset: 0.05,
|
|
113
|
+
* },
|
|
114
|
+
* curve: {
|
|
115
|
+
* radius: 0.25,
|
|
116
|
+
* },
|
|
117
|
+
* direction: 'negative',
|
|
118
|
+
* show: [2], // Only show angle annotation for angle 2
|
|
119
|
+
* },
|
|
120
|
+
* });
|
|
121
|
+
* @interface
|
|
122
|
+
* @group Misc Shapes
|
|
123
|
+
*/
|
|
124
|
+
export type OBJ_PolylineCustomization = {
|
|
125
|
+
show?: Array<number>;
|
|
126
|
+
hide?: Array<number>;
|
|
127
|
+
_padIndex: OBJ_Polygon;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* When shapes get too small, angle and side annotations can start to draw on
|
|
131
|
+
* each other. This object defines thresholds for when the angle and side
|
|
132
|
+
* annotations should be hidden.
|
|
133
|
+
*
|
|
134
|
+
* @property {null | number} [minAngle]
|
|
135
|
+
* @property {null | number} [maxAngle]
|
|
136
|
+
* @property {null | number} [minSide]
|
|
137
|
+
* @interface
|
|
138
|
+
* @group Misc Shapes
|
|
139
|
+
*/
|
|
140
|
+
export type OBJ_ValidShapeHideThresholds = {
|
|
141
|
+
minAngle?: number | null | undefined;
|
|
142
|
+
maxAngle?: number | null | undefined;
|
|
143
|
+
minSide?: number | null | undefined;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Makes the sides and angles of a closed polyline consistent. Also reverses
|
|
147
|
+
* the point order if angles are on outside of shape instead of inside.
|
|
148
|
+
*
|
|
149
|
+
* Floating point rounding errors will sometimes result in angles
|
|
150
|
+
* and side lengths being slightly larger or smaller than is possible.
|
|
151
|
+
* For instance, for a triangle, there may be a rare case where the three
|
|
152
|
+
* angles add up to 181ª instead of 180ª as a result of rounding the angle
|
|
153
|
+
* labels to no decimal places.
|
|
154
|
+
*
|
|
155
|
+
* Making a shape consistent will go through all the side and angle labels
|
|
156
|
+
* and correct them, displaying a value without rounding error.
|
|
157
|
+
*
|
|
158
|
+
* Currently, only `'triangle'` is supported.
|
|
159
|
+
*
|
|
160
|
+
* In addition, the angle and side annotations can be hidden if minimum
|
|
161
|
+
* or maximum thresholds of angle and side values are crossed. For example,
|
|
162
|
+
* for small triangles angle annotations may start to draw on top of each other
|
|
163
|
+
* being messy.
|
|
164
|
+
*
|
|
165
|
+
* @property {'triangle'} [shape]
|
|
166
|
+
* @property {OBJ_ValidShapeHideThresholds} [hide]
|
|
167
|
+
* @interface
|
|
168
|
+
* @group Misc Shapes
|
|
169
|
+
*/
|
|
170
|
+
export type OBJ_ValidShape = {
|
|
171
|
+
shape?: 'triangle';
|
|
172
|
+
hide?: OBJ_ValidShapeHideThresholds;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* @extends COL_Angle
|
|
176
|
+
* @extends OBJ_PolylineCustomization
|
|
177
|
+
* @interface
|
|
178
|
+
* @group Misc Shapes
|
|
179
|
+
*/
|
|
180
|
+
export type OBJ_PolylineAngle = {};
|
|
181
|
+
/**
|
|
182
|
+
* @extends COL_Line
|
|
183
|
+
* @extends OBJ_PolylineCustomization
|
|
184
|
+
* @interface
|
|
185
|
+
* @group Misc Shapes
|
|
186
|
+
*/
|
|
187
|
+
export type OBJ_PolylineSide = {};
|
|
188
|
+
/**
|
|
189
|
+
* {@link CollectionsPolyline} options object that extends
|
|
190
|
+
* {@link OBJ_Polyline} and {@link OBJ_Collection}
|
|
191
|
+
* options object (without `parent`).
|
|
192
|
+
*
|
|
193
|
+
* The Collections Polyline is a convient and powerful polyline
|
|
194
|
+
* {@link FigureElementCollection} that includes the polyline,
|
|
195
|
+
* angle annotations, side label and arrow annotations, and movable
|
|
196
|
+
* pads on each polyline point for the user to adjust dynamically.
|
|
197
|
+
*
|
|
198
|
+
* The polyline itself is defined with an {@link OBJ_Polyline} options Object.
|
|
199
|
+
*
|
|
200
|
+
* Angle and side annotations can be defined as {@link COL_Angle} and
|
|
201
|
+
* {@link COL_Line}, and movable pads defined with
|
|
202
|
+
* ({@link OBJ_Polygon} & {@link OBJ_PolylinePad}).
|
|
203
|
+
*
|
|
204
|
+
* Angles, sides and pads can all be defined either as an options object
|
|
205
|
+
* or an array of options objects. If an array, then each element in the
|
|
206
|
+
* array will correspond with a pad on the polyline. If there are less
|
|
207
|
+
* elements in the array than pads on the polyline, then the elements
|
|
208
|
+
* will recycle from the start.
|
|
209
|
+
*
|
|
210
|
+
* Using object definitions allows for a definition of all angles, sides and
|
|
211
|
+
* pads. To customize for specific side, angle or pad indexes use =
|
|
212
|
+
* {@link OBJ_PolylineCustomization}.
|
|
213
|
+
*
|
|
214
|
+
* @extends OBJ_Polyline
|
|
215
|
+
* @extends OBJ_Collection
|
|
216
|
+
*
|
|
217
|
+
* @property {boolean} [showLine] `false` will hide the polyline's line (`true`)
|
|
218
|
+
* @property {OBJ_PolylineAngle | Array<COL_Angle>} [angle] angle annotations - leave undefined for no angle annotations
|
|
219
|
+
* @property {OBJ_PolylineSide | Array<COL_Line>} [side]
|
|
220
|
+
* side annotations - leave undefined for no side annotations
|
|
221
|
+
* @property {OBJ_PolylinePad | Array<OBJ_PolylinePadSingle>} [pad]
|
|
222
|
+
* move pad - leave undefined for no move pads
|
|
223
|
+
* @property {null | OBJ_ValidShape} [makeValid] if defined, whenever
|
|
224
|
+
* points are updated the shape will be checked to ensure consistency with
|
|
225
|
+
* displayed labels of angles and sides.
|
|
226
|
+
* @property {OBJ_Font} [font] default font to use for labels
|
|
227
|
+
* @interface
|
|
228
|
+
* @group 2D Shape Collections
|
|
229
|
+
*/
|
|
230
|
+
export type COL_Polyline = {
|
|
231
|
+
showLine?: boolean;
|
|
232
|
+
angle?: OBJ_PolylineAngle | Array<COL_Angle>;
|
|
233
|
+
side?: OBJ_PolylineSide | Array<COL_Line>;
|
|
234
|
+
pad?: OBJ_PolylinePad | Array<OBJ_PolylinePadSingle>;
|
|
235
|
+
makeValid?: OBJ_ValidShape | null | undefined;
|
|
236
|
+
font?: OBJ_Font;
|
|
237
|
+
} & OBJ_Polyline & OBJ_Collection;
|
|
238
|
+
/**
|
|
239
|
+
* `'updatePoints'` subscription published whenever the Collections Polyline
|
|
240
|
+
* points are updated. No payload is passed to subscriber.
|
|
241
|
+
*
|
|
242
|
+
* @typedef SUB_PolylineUpdatePoints
|
|
243
|
+
* @interface
|
|
244
|
+
* @group Misc Shapes
|
|
245
|
+
*/
|
|
246
|
+
export type SUB_PolylineUpdatePoints = [];
|
|
247
|
+
/**
|
|
248
|
+
* {@link FigureElementCollection} representing a polyline.
|
|
249
|
+
*
|
|
250
|
+
* 
|
|
251
|
+
*
|
|
252
|
+
* <p class="inline_gif"><img src="./apiassets/advpolyline_movepolyline.gif" class="inline_gif_image"></p>
|
|
253
|
+
*
|
|
254
|
+
* <p class="inline_gif"><img src="./apiassets/advpolyline_movetri.gif" class="inline_gif_image"></p>
|
|
255
|
+
*
|
|
256
|
+
* This object defines a convient and powerful polyline
|
|
257
|
+
* {@link FigureElementCollection} that includes a solid or dashed,
|
|
258
|
+
* open or closed polyline, arrows, angle annotations for polyline corners,
|
|
259
|
+
* side annotations for straight lines between points and move pads at polyline
|
|
260
|
+
* points to dynamically adjust the polyline.
|
|
261
|
+
*
|
|
262
|
+
* See {@link COL_Polyline} for the options that can be used when creating the
|
|
263
|
+
* line.
|
|
264
|
+
*
|
|
265
|
+
* Available notifications:
|
|
266
|
+
* - `'updatePoints'`: {@link SUB_PolylineUpdatePoints}
|
|
267
|
+
*
|
|
268
|
+
* @see
|
|
269
|
+
* To test examples below, append them to the
|
|
270
|
+
* <a href="#drawing-boilerplate">boilerplate</a>.
|
|
271
|
+
*
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* // Polyline with angle annotations
|
|
275
|
+
* figure.add({
|
|
276
|
+
* name: 'p',
|
|
277
|
+
* make: 'collections.polyline',
|
|
278
|
+
* points: [[1, 0], [0, 0], [0.5, 1], [1.5, 1]],
|
|
279
|
+
* arrow: 'triangle',
|
|
280
|
+
* angle: {
|
|
281
|
+
* label: null,
|
|
282
|
+
* curve: {
|
|
283
|
+
* radius: 0.3,
|
|
284
|
+
* },
|
|
285
|
+
* }
|
|
286
|
+
* });
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* // Triangle with unknown angle
|
|
290
|
+
* figure.add({
|
|
291
|
+
* name: 'p',
|
|
292
|
+
* make: 'collections.polyline',
|
|
293
|
+
* points: [[1, 1], [1, 0], [0, 0]],
|
|
294
|
+
* close: true,
|
|
295
|
+
* side: {
|
|
296
|
+
* label: null,
|
|
297
|
+
* },
|
|
298
|
+
* angle: {
|
|
299
|
+
* label: {
|
|
300
|
+
* text: '?',
|
|
301
|
+
* offset: 0.05,
|
|
302
|
+
* },
|
|
303
|
+
* curve: {
|
|
304
|
+
* radius: 0.4,
|
|
305
|
+
* },
|
|
306
|
+
* show: [1],
|
|
307
|
+
* },
|
|
308
|
+
* });
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* // Dimensioned square
|
|
312
|
+
* figure.add({
|
|
313
|
+
* name: 'p',
|
|
314
|
+
* make: 'collections.polyline',
|
|
315
|
+
* points: [[0, 1], [1, 1], [1, 0], [0, 0]],
|
|
316
|
+
* close: true,
|
|
317
|
+
* side: {
|
|
318
|
+
* showLine: true,
|
|
319
|
+
* offset: 0.2,
|
|
320
|
+
* color: [0, 0, 1, 1],
|
|
321
|
+
* arrow: 'barb',
|
|
322
|
+
* width: 0.01,
|
|
323
|
+
* label: null,
|
|
324
|
+
* dash: [0.05, 0.02],
|
|
325
|
+
* 0: { label: { text: 'a' } }, // Customize side 0
|
|
326
|
+
* },
|
|
327
|
+
* angle: {
|
|
328
|
+
* curve: {
|
|
329
|
+
* autoRightAngle: true,
|
|
330
|
+
* radius: 0.3,
|
|
331
|
+
* },
|
|
332
|
+
* },
|
|
333
|
+
* });
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* // User adjustable polyline
|
|
337
|
+
* figure.add({
|
|
338
|
+
* name: 'p',
|
|
339
|
+
* make: 'collections.polyline',
|
|
340
|
+
* points: [[-0.5, 1], [1, 1], [0, 0], [1, -0.5]],
|
|
341
|
+
* dash: [0.05, 0.02],
|
|
342
|
+
* pad: {
|
|
343
|
+
* radius: 0.2,
|
|
344
|
+
* color: [1, 0, 0, 0.5], // make alpha 0 to hide pad
|
|
345
|
+
* isMovable: true,
|
|
346
|
+
* },
|
|
347
|
+
* });
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* // Annotations that automatically updates as user changes triangle
|
|
351
|
+
* figure.add({
|
|
352
|
+
* name: 'p',
|
|
353
|
+
* make: 'collections.polyline',
|
|
354
|
+
* points: [[-1, 1], [1, 1], [0, 0]],
|
|
355
|
+
* close: true,
|
|
356
|
+
* makeValid: {
|
|
357
|
+
* shape: 'triangle',
|
|
358
|
+
* hide: {
|
|
359
|
+
* minAngle: Math.PI / 8,
|
|
360
|
+
* },
|
|
361
|
+
* },
|
|
362
|
+
* side: {
|
|
363
|
+
* showLine: true,
|
|
364
|
+
* offset: 0.2,
|
|
365
|
+
* color: [0.3, 0.6, 1, 1],
|
|
366
|
+
* arrow: 'barb',
|
|
367
|
+
* width: 0.01,
|
|
368
|
+
* label: {
|
|
369
|
+
* text: null,
|
|
370
|
+
* },
|
|
371
|
+
* },
|
|
372
|
+
* angle: {
|
|
373
|
+
* label: null,
|
|
374
|
+
* curve: { radius: 0.25 },
|
|
375
|
+
* },
|
|
376
|
+
* pad: {
|
|
377
|
+
* radius: 0.4,
|
|
378
|
+
* color: [1, 0, 0, 0.005],
|
|
379
|
+
* isMovable: true,
|
|
380
|
+
* },
|
|
381
|
+
* });
|
|
382
|
+
* @group 2D Shape Collections
|
|
383
|
+
*/
|
|
384
|
+
export default class CollectionsPolyline extends FigureElementCollection {
|
|
385
|
+
collections: FigureCollections;
|
|
386
|
+
animateNextFrame: () => void;
|
|
387
|
+
isTouchDevice: boolean;
|
|
388
|
+
largerTouchBorder: boolean;
|
|
389
|
+
position: Point;
|
|
390
|
+
points: Array<Point>;
|
|
391
|
+
close: boolean;
|
|
392
|
+
_line: FigureElementPrimitive | null | undefined;
|
|
393
|
+
options: COL_Polyline;
|
|
394
|
+
updatePointsCallback: string | (() => void) | null | undefined;
|
|
395
|
+
reverse: boolean;
|
|
396
|
+
makeValid: {
|
|
397
|
+
shape: 'triangle';
|
|
398
|
+
hide: {
|
|
399
|
+
minAngle: number | null | undefined;
|
|
400
|
+
maxAngle: number | null | undefined;
|
|
401
|
+
minSide: number | null | undefined;
|
|
402
|
+
};
|
|
403
|
+
} | null | undefined;
|
|
404
|
+
defaultFont: OBJ_Font;
|
|
405
|
+
/**
|
|
406
|
+
* @hideconstructor
|
|
407
|
+
*/
|
|
408
|
+
constructor(collections: FigureCollections, isTouchDevice: boolean, animateNextFrame: () => void, options?: COL_Polyline);
|
|
409
|
+
addPads(pad: Record<string, any>): void;
|
|
410
|
+
addAngles(angle: Record<string, any>, close: boolean): void;
|
|
411
|
+
addSides(side: Record<string, any>, close: boolean): void;
|
|
412
|
+
_getStateProperties(options: Record<string, any>): string[];
|
|
413
|
+
_fromState(state: Record<string, any>): this;
|
|
414
|
+
updateSideLabels(rotationOffset?: number): void;
|
|
415
|
+
updateAngleLabels(rotationOffset?: number): void;
|
|
416
|
+
/**
|
|
417
|
+
* Update the polyline with new point locations.
|
|
418
|
+
*
|
|
419
|
+
* Will publish {@link SUB_PolylineUpdatePoints} unless
|
|
420
|
+
* `doNotPublishUpdatePoints` is `true`.
|
|
421
|
+
*/
|
|
422
|
+
updatePoints(newPointsIn: Array<Point>, doNotPublishUpdatePoints?: boolean): void;
|
|
423
|
+
updateAngles(): void;
|
|
424
|
+
updateRotation(rotationOffset?: number): void;
|
|
425
|
+
/**
|
|
426
|
+
* Reverse points in the polyline.
|
|
427
|
+
*
|
|
428
|
+
* Will publish {@link SUBSCRIPTION_PolylineUpdatePoints} unless
|
|
429
|
+
* `doNotPublishUpdatePoints` is `true`.
|
|
430
|
+
*
|
|
431
|
+
* @param {boolean} doNotPublishUpdatePoints if `true` the `updatePoints`
|
|
432
|
+
* subscription will not be published.
|
|
433
|
+
*/
|
|
434
|
+
reversePoints(doNotPublishUpdatePoints?: boolean): void;
|
|
435
|
+
/**
|
|
436
|
+
* The Collections Polyline is a {@link FigureElementCollection}, with a
|
|
437
|
+
* transform that includes a translation, or position, transform element.
|
|
438
|
+
*
|
|
439
|
+
* Changing the position element of the transform would normally move
|
|
440
|
+
* everything in the collection. This method instead changes the position
|
|
441
|
+
* without moving everything by updating the polyline points with an
|
|
442
|
+
* offset that is the opposite new position.
|
|
443
|
+
*
|
|
444
|
+
* As an example, if a rotation around the second point of a polyline is
|
|
445
|
+
* desired, then setPositionWithoutMoving at the point before rotating.
|
|
446
|
+
*/
|
|
447
|
+
setPositionWithoutMoving(newPositionPointOrX: Point | number, newPositionY?: number): void;
|
|
448
|
+
/**
|
|
449
|
+
* The Collections Polyline is a {@link FigureElementCollection}, with a
|
|
450
|
+
* transform that includes a rotation transform element.
|
|
451
|
+
*
|
|
452
|
+
* Changing the rotation element of the transform would normally rotate
|
|
453
|
+
* everything in the collection. This method instead changes the rotation
|
|
454
|
+
* without rotating everything by updating the polyline points with a
|
|
455
|
+
* rotation that is the negative of the `newRotation`.
|
|
456
|
+
*/
|
|
457
|
+
setRotationWithoutMoving(newRotation: number): void;
|
|
458
|
+
/**
|
|
459
|
+
* The Collections Polyline is a {@link FigureElementCollection}, with a
|
|
460
|
+
* transform that includes a scale transform element.
|
|
461
|
+
*
|
|
462
|
+
* Changing the scale element of the transform would normally scale
|
|
463
|
+
* everything in the collection. This method instead changes the scale
|
|
464
|
+
* without scaling everything by updating the polyline points with a
|
|
465
|
+
* scale that is the inverse of the new scale.
|
|
466
|
+
*/
|
|
467
|
+
setScaleWithoutMoving(newScalePointOrX: Point | number, newScaleY?: number): void;
|
|
468
|
+
setShow(name: string, show: boolean): void;
|
|
469
|
+
/**
|
|
470
|
+
* Hide all angle annotations.
|
|
471
|
+
*/
|
|
472
|
+
hideAngles(): void;
|
|
473
|
+
/**
|
|
474
|
+
* Hide all side annotations.
|
|
475
|
+
*/
|
|
476
|
+
hideSides(): void;
|
|
477
|
+
/**
|
|
478
|
+
* Show all angle annotations.
|
|
479
|
+
*/
|
|
480
|
+
showAngles(): void;
|
|
481
|
+
/**
|
|
482
|
+
* Hide all side annotations.
|
|
483
|
+
*/
|
|
484
|
+
showSides(): void;
|
|
485
|
+
updateLabels(rotationOffset?: number): void;
|
|
486
|
+
makeValidTriangle(): void;
|
|
487
|
+
}
|