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,359 @@
|
|
|
1
|
+
import type { Type2Components, Type3Components } from './types';
|
|
2
|
+
import type { Type3DMatrix } from '../m3';
|
|
3
|
+
type TypeF1DefPoint = {
|
|
4
|
+
f1Type: 'p';
|
|
5
|
+
state: [number, number, number];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A {@link Point} can be defined in several ways
|
|
9
|
+
* - As an instantiated {@link Point}
|
|
10
|
+
* - As an x, y tuple: [number, number]
|
|
11
|
+
* - As an x, y, z tuple: [number, number, number]
|
|
12
|
+
* - As an x, y string: '[number, number]'
|
|
13
|
+
* - As an x, y, z string: '[number, number, number]'
|
|
14
|
+
* - As a recorder state definition: { f1Type: 'p', state: [number, number, number] }
|
|
15
|
+
* }
|
|
16
|
+
* - A string representation of all options except the first
|
|
17
|
+
*
|
|
18
|
+
* If points are defined with only a `x` and `y` component, then `z` will be
|
|
19
|
+
* set to 0 automatically.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // p1, p2, p3 and p4 are all the same when parsed by `getPoint`
|
|
23
|
+
* p1 = new Fig.Point(2, 3);
|
|
24
|
+
* p2 = [2, 3];
|
|
25
|
+
* p3 = '[2, 3]';
|
|
26
|
+
* p4 = { f1Type: 'p', state: [2, 3] };
|
|
27
|
+
* p5 = [2, 3, 0];
|
|
28
|
+
* @group Geometry
|
|
29
|
+
*/
|
|
30
|
+
export type TypeParsablePoint = Type2Components | Type3Components | Point | string | TypeF1DefPoint;
|
|
31
|
+
declare function parsePoint(pIn: TypeParsablePoint): Point;
|
|
32
|
+
/**
|
|
33
|
+
* Test is a point is parsable
|
|
34
|
+
* @group Misc Geometry
|
|
35
|
+
*/
|
|
36
|
+
declare function isParsablePoint(pIn: any): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Parse a {@link TypeParsablePoint} and return a {@link Point}.
|
|
39
|
+
* @return {Point}
|
|
40
|
+
* @group Misc Geometry
|
|
41
|
+
*/
|
|
42
|
+
declare function getPoint(p: TypeParsablePoint): Point;
|
|
43
|
+
/**
|
|
44
|
+
* Parse an array of parsable point definitions ({@link TypeParsablePoint})
|
|
45
|
+
* returning an array of points.
|
|
46
|
+
* @return {Array<Point>}
|
|
47
|
+
* @group Misc Geometry
|
|
48
|
+
*/
|
|
49
|
+
declare function getPoints(points: TypeParsablePoint | Array<TypeParsablePoint>): Array<Point>;
|
|
50
|
+
/**
|
|
51
|
+
* Parse a scale definition and return a {@link Point} representing the scale
|
|
52
|
+
* in x and y.
|
|
53
|
+
* Scale can either be defined as a {@link TypeParsablePoint} or a `number` if
|
|
54
|
+
* the x and y scale is equal.
|
|
55
|
+
* @return {Point} x and y scale
|
|
56
|
+
* @group Misc Geometry
|
|
57
|
+
*/
|
|
58
|
+
declare function getScale(s: TypeParsablePoint | number): Point;
|
|
59
|
+
/**
|
|
60
|
+
* Object representing a point or vector.
|
|
61
|
+
*
|
|
62
|
+
* Contains methods that makes it convenient to work with points and vectors.
|
|
63
|
+
*
|
|
64
|
+
* @see {@link TypeParsablePoint}, {@link isParsablePoint}
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // get Point from Fig
|
|
68
|
+
* const { Point } = Fig;
|
|
69
|
+
*
|
|
70
|
+
* // define a point at (0, 2)
|
|
71
|
+
* const p = new Point(0, 2);
|
|
72
|
+
*
|
|
73
|
+
* // find the distance to another point (0, 1) which will be 1
|
|
74
|
+
* const d = p.distance([0, 1]);
|
|
75
|
+
*
|
|
76
|
+
* // add to another point (3, 1) which will result in (3, 3)
|
|
77
|
+
* const q = p.add(3, 1);
|
|
78
|
+
* @group Geometry
|
|
79
|
+
*/
|
|
80
|
+
declare class Point {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
z: number;
|
|
84
|
+
_type: 'point';
|
|
85
|
+
constructor(xOrArray: Type3Components | Type2Components | number, y?: number, z?: number);
|
|
86
|
+
/**
|
|
87
|
+
* Return x, y, z components as a length 3 tuple.
|
|
88
|
+
* @return {[number, number, number]}
|
|
89
|
+
*/
|
|
90
|
+
toArray(dimension?: 2 | 3): [number, number, number] | [number, number];
|
|
91
|
+
/**
|
|
92
|
+
* Convert a cartesian point to polar coordiantes (will use x and y
|
|
93
|
+
* components of point only).
|
|
94
|
+
* @return {{ mag: number, angle: number }}
|
|
95
|
+
*/
|
|
96
|
+
toPolar(): {
|
|
97
|
+
mag: number;
|
|
98
|
+
angle: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Convert the cartesian point to spherical coordinates.
|
|
102
|
+
* @return {{ mag: number, theta: number, phi: number }}
|
|
103
|
+
*/
|
|
104
|
+
toSpherical(): {
|
|
105
|
+
mag: number;
|
|
106
|
+
theta: number;
|
|
107
|
+
phi: number;
|
|
108
|
+
};
|
|
109
|
+
_state(options?: {
|
|
110
|
+
precision: number;
|
|
111
|
+
}): {
|
|
112
|
+
f1Type: "p";
|
|
113
|
+
state: [number, number, number];
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Return a duplicate of the {@link Point} object
|
|
117
|
+
* @return {Point}
|
|
118
|
+
*/
|
|
119
|
+
_dup(): Point;
|
|
120
|
+
/**
|
|
121
|
+
* Multiply values of point by scalar
|
|
122
|
+
* @return {Point}
|
|
123
|
+
* @example
|
|
124
|
+
* p = new Point(1, 1, 1);
|
|
125
|
+
* s = p.scale(3);
|
|
126
|
+
* // s = Point{x: 3, y: 3, z: 3}
|
|
127
|
+
*/
|
|
128
|
+
scale(scalar: number): Point;
|
|
129
|
+
/**
|
|
130
|
+
* Return a point with the negative of each component.
|
|
131
|
+
*
|
|
132
|
+
* @return {Point}
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* p = new Point(1, 2, 3);
|
|
136
|
+
* q = p.neg();
|
|
137
|
+
* // q = Point{x: -1, y: -2, z: -3}
|
|
138
|
+
*/
|
|
139
|
+
neg(): Point;
|
|
140
|
+
/**
|
|
141
|
+
* Multiply each corresponding component of two points.
|
|
142
|
+
*
|
|
143
|
+
* @return {Point}
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* p = new Point(2, 3, 4);
|
|
147
|
+
* q = new Point(3, 4, 5);
|
|
148
|
+
* m = p.mul(q);
|
|
149
|
+
* // m = Point{x: 6, y: 12, z: 20}
|
|
150
|
+
*/
|
|
151
|
+
mul(p: TypeParsablePoint): Point;
|
|
152
|
+
/**
|
|
153
|
+
* Complex multiplication.
|
|
154
|
+
*
|
|
155
|
+
* Multiply two 2D points such that x is the real value and
|
|
156
|
+
* y is the imaginary value of a complex number. z is ignored.
|
|
157
|
+
* @return {Point}
|
|
158
|
+
* @example
|
|
159
|
+
* p = new Point(1, 2); // represents 1 + 2i
|
|
160
|
+
* q = new Point(2, 3); // represents 2 + 3i
|
|
161
|
+
* m = p.cmul(q);
|
|
162
|
+
* // m = Point{x: -4, y: 7, z: 0}
|
|
163
|
+
* // which represents the complex value -4 + 7i
|
|
164
|
+
*/
|
|
165
|
+
cmul(complexPoint: TypeParsablePoint): Point;
|
|
166
|
+
/**
|
|
167
|
+
* Complex division.
|
|
168
|
+
*
|
|
169
|
+
* Divide this point by `complexPoint`. Each point represents a complex
|
|
170
|
+
* number where x is the real value and y is the imaginary value.
|
|
171
|
+
* z is ignored.
|
|
172
|
+
* @return {Point}
|
|
173
|
+
* @example
|
|
174
|
+
* p = new Point(-4, 7); // represents -4 + 7i
|
|
175
|
+
* q = new Point(1, 2); // represents 1 + 2i
|
|
176
|
+
* m = p.cdiv(q);
|
|
177
|
+
* // m = Point{x: 2, y: 3, z: 0}
|
|
178
|
+
* // which represents the complex value 2 + 3i
|
|
179
|
+
*/
|
|
180
|
+
cdiv(complexPoint: TypeParsablePoint): Point;
|
|
181
|
+
/**
|
|
182
|
+
* Subtract (x, y, z) values or a {@link Point} and return the difference as a new {@link Point}
|
|
183
|
+
* @return {Point}
|
|
184
|
+
* @example
|
|
185
|
+
* p = new Point(3, 3, 3);
|
|
186
|
+
* d = p.sub(1, 1, 1)
|
|
187
|
+
* // d = Point{x: 2, y: 2, z: 2}
|
|
188
|
+
*
|
|
189
|
+
* p = new Point(3, 3, 3);
|
|
190
|
+
* q = new Point(1, 1, 1);
|
|
191
|
+
* d = p.sub(q)
|
|
192
|
+
* // d = Point{x: 2, y: 2, z: 2}
|
|
193
|
+
*/
|
|
194
|
+
sub(pointOrX: Point | number, y?: number, z?: number): Point;
|
|
195
|
+
/**
|
|
196
|
+
* Add (x, y, z) values or a {@link Point} and return the sum as a new {@link Point}
|
|
197
|
+
* @return {Point}
|
|
198
|
+
* @example
|
|
199
|
+
* p = new Point(3, 3, 3);
|
|
200
|
+
* d = p.add(1, 1, 1)
|
|
201
|
+
* // d = Point{x: 4, y: 4, z: 4}
|
|
202
|
+
*
|
|
203
|
+
* p = new Point(3, 3, 3);
|
|
204
|
+
* q = new Point(1, 1, 1);
|
|
205
|
+
* d = p.add(q)
|
|
206
|
+
* // d = Point{x: 4, y: 4, z: 4}
|
|
207
|
+
*/
|
|
208
|
+
add(pointOrX: Point | number, y?: number, z?: number): Point;
|
|
209
|
+
/**
|
|
210
|
+
* Return the distance between two points (or point and origin if no input
|
|
211
|
+
* supplied)
|
|
212
|
+
* @return {number}
|
|
213
|
+
* @example
|
|
214
|
+
* p = new Point(1, 1, 1);
|
|
215
|
+
* q = new Point(0, 0, 0);
|
|
216
|
+
* d = q.distance(p);
|
|
217
|
+
* // d = 1.7320508075688772
|
|
218
|
+
*
|
|
219
|
+
*/
|
|
220
|
+
distance(toPointIn?: TypeParsablePoint | null): number;
|
|
221
|
+
/**
|
|
222
|
+
* Return the distance between (0, 0, 0) and the point. If the point
|
|
223
|
+
* represents a vector, then it is the length of the vector.
|
|
224
|
+
* @return {number}
|
|
225
|
+
*/
|
|
226
|
+
length(): number;
|
|
227
|
+
/**
|
|
228
|
+
* Dot product this point (vector) with another.
|
|
229
|
+
* @return {number}
|
|
230
|
+
*/
|
|
231
|
+
dotProduct(v: TypeParsablePoint): number;
|
|
232
|
+
/**
|
|
233
|
+
* Cross product of two points (vectors).
|
|
234
|
+
* @return {Point}
|
|
235
|
+
*/
|
|
236
|
+
crossProduct(v: TypeParsablePoint): Point;
|
|
237
|
+
/**
|
|
238
|
+
* Angle between this vector and vector v.
|
|
239
|
+
* @return {number}
|
|
240
|
+
*/
|
|
241
|
+
angleTo(v: TypeParsablePoint): number;
|
|
242
|
+
/**
|
|
243
|
+
* Scalar projection of this vector in direction of vector v.
|
|
244
|
+
* @return {number}
|
|
245
|
+
*/
|
|
246
|
+
projectOn(v: TypeParsablePoint): number;
|
|
247
|
+
/**
|
|
248
|
+
* Return a vector with magnitude of the scalar projection of this vector on
|
|
249
|
+
* v and direction +/- v (depending on the sign of the scalar projection).
|
|
250
|
+
* @return {Point}
|
|
251
|
+
*/
|
|
252
|
+
componentAlong(v: TypeParsablePoint): Point;
|
|
253
|
+
/**
|
|
254
|
+
* Returns `true` if the x, y, z components of the point when rounded
|
|
255
|
+
* with `precision` are zero.
|
|
256
|
+
* @return {boolean}
|
|
257
|
+
*/
|
|
258
|
+
isZero(precision?: number): boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Return a new point with (x, y, z) values rounded to some precision
|
|
261
|
+
* @return {Point}
|
|
262
|
+
* @example
|
|
263
|
+
* p = new Point(1.234, 1.234, 1.234);
|
|
264
|
+
* q = p.round(2);
|
|
265
|
+
* // q = Point{x: 1.23, y: 1.23, z: 1.23}
|
|
266
|
+
*/
|
|
267
|
+
round(precision?: number): Point;
|
|
268
|
+
/**
|
|
269
|
+
* Return a new point that is clipped to min and max values from the origin.
|
|
270
|
+
*
|
|
271
|
+
* Use a point as a parameter to define different (x, y) min/max values,
|
|
272
|
+
* a number to define the same (x, y) min/max values, or null to have no
|
|
273
|
+
* min/max values.
|
|
274
|
+
* @return {Point}
|
|
275
|
+
* @example
|
|
276
|
+
* p = new Point(2, 2);
|
|
277
|
+
* q = p.clip(1, 1);
|
|
278
|
+
* // q = Point{x: 1, y: 1}
|
|
279
|
+
*
|
|
280
|
+
* p = new Point(2, 2);
|
|
281
|
+
* q = p.clip(1, null);
|
|
282
|
+
* // q = Point{x: 1, y: 2}
|
|
283
|
+
*
|
|
284
|
+
* p = new Point(-2, -2);
|
|
285
|
+
* minClip = new Point(-1, -1.5);
|
|
286
|
+
* q = p.clip(minClip, null);
|
|
287
|
+
* // q = Point{x: -1, y: -1.5}
|
|
288
|
+
*/
|
|
289
|
+
clip(min: Point | number | null, max: Point | number | null): Point;
|
|
290
|
+
/**
|
|
291
|
+
* Transform the point with a 4x4 matrix (3 dimensional transform in
|
|
292
|
+
* homogenous coordinates)
|
|
293
|
+
* @return {Point}
|
|
294
|
+
* @example
|
|
295
|
+
* // Transform a point with a (2, 2, 0) translation then 90º z rotation
|
|
296
|
+
* p = new Point(1, 1);
|
|
297
|
+
* m = new Transform3().translate(2, 2, 0).rotate(0, 0, Math.PI / 2).matrix();
|
|
298
|
+
* // m = [0, -1, 0, -2, 1, 0, 0, 2, 0, 0, 0, 1]
|
|
299
|
+
* q = p.transformBy(m)
|
|
300
|
+
* // q = Point{x: -3, y: 3, 0}
|
|
301
|
+
*/
|
|
302
|
+
transformBy(matrix: Type3DMatrix): Point;
|
|
303
|
+
quadraticBezier(p1: Point, p2: Point, t: number): Point;
|
|
304
|
+
/**
|
|
305
|
+
* Rotate a point some angle around a point
|
|
306
|
+
* @param {number} angle - in radians
|
|
307
|
+
* @param center - in radians
|
|
308
|
+
* @return {Point}
|
|
309
|
+
* @example
|
|
310
|
+
* // Rotate a point around the origin
|
|
311
|
+
* p = new Point(1, 0);
|
|
312
|
+
* q = p.rotate(Math.PI)
|
|
313
|
+
* // q = Point{x: -1, y: 0}
|
|
314
|
+
*
|
|
315
|
+
* // Rotate a point around (1, 1)
|
|
316
|
+
* p = new Point(2, 1);
|
|
317
|
+
* q = p.rotate(Math.PI, new Point(1, 1))
|
|
318
|
+
* // q = Point{x: 0, y: 1}
|
|
319
|
+
*/
|
|
320
|
+
rotate(angle: number, center?: TypeParsablePoint, axis?: TypeParsablePoint): Point;
|
|
321
|
+
/**
|
|
322
|
+
* Return the unit vector of the point (the direction vector of length 1
|
|
323
|
+
* from the origin to the point).
|
|
324
|
+
* @return {Point}
|
|
325
|
+
*/
|
|
326
|
+
normalize(): Point;
|
|
327
|
+
/**
|
|
328
|
+
* Compare two points for equality to some precision or delta
|
|
329
|
+
* @param {TypeParsablePoint} p point to compare
|
|
330
|
+
* @param {number} precision precision to compare (`8`)
|
|
331
|
+
* @param {boolean} delta if `true` then precision is the delta value the two
|
|
332
|
+
* points must be within to be equal
|
|
333
|
+
* @return {boolean}
|
|
334
|
+
* @example
|
|
335
|
+
* p = new Point(1.123, 1.123);
|
|
336
|
+
* q = new Point(1.124, 1.124);
|
|
337
|
+
* p.isEqualTo(q)
|
|
338
|
+
* // false
|
|
339
|
+
*
|
|
340
|
+
* p.isEqualTo(q, 2)
|
|
341
|
+
* // true
|
|
342
|
+
*/
|
|
343
|
+
isEqualTo(p: TypeParsablePoint, precision?: number, delta?: boolean): boolean;
|
|
344
|
+
isWithinDelta(p: Point, delta?: number): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Compare two points for unequality to some precision
|
|
347
|
+
* @example
|
|
348
|
+
* p = new Point(1.123, 1.123);
|
|
349
|
+
* q = new Point(1.124, 1.124);
|
|
350
|
+
* p.isNotEqualTo(q)
|
|
351
|
+
* // true
|
|
352
|
+
*
|
|
353
|
+
* p.isNotEqualTo(q, 2)
|
|
354
|
+
* // false
|
|
355
|
+
*/
|
|
356
|
+
isNotEqualTo(p: Point, precision?: number, delta?: boolean): boolean;
|
|
357
|
+
isNotWithinDelta(p: Point, delta?: number): boolean;
|
|
358
|
+
}
|
|
359
|
+
export { isParsablePoint, getPoint, getScale, getPoints, parsePoint, Point, };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Point } from './Point';
|
|
2
|
+
import type { TypeParsablePoint } from './Point';
|
|
3
|
+
import type { TypeParsableLine } from './Line';
|
|
4
|
+
/**
|
|
5
|
+
* An object representing a rectangle.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // get Rect from Fig
|
|
9
|
+
* const { Rect } = Fig;
|
|
10
|
+
*
|
|
11
|
+
* // define a rect centered at origin with width 4 and height 2
|
|
12
|
+
* const r = new Rect(-2, -1, 4, 2);
|
|
13
|
+
* @group Geometry
|
|
14
|
+
*/
|
|
15
|
+
declare class Rect {
|
|
16
|
+
left: number;
|
|
17
|
+
top: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
bottom: number;
|
|
21
|
+
right: number;
|
|
22
|
+
/**
|
|
23
|
+
* Constructor
|
|
24
|
+
* @constructor
|
|
25
|
+
* @param {number} left - left location
|
|
26
|
+
* @param {number} bottom - bottom location
|
|
27
|
+
* @param {number} width - rectangle width
|
|
28
|
+
* @param {number} height - rectangle height
|
|
29
|
+
*/
|
|
30
|
+
constructor(left: number, bottom: number, width: number, height: number);
|
|
31
|
+
/**
|
|
32
|
+
* Return a duplicate rectangle object
|
|
33
|
+
*/
|
|
34
|
+
_dup(): Rect;
|
|
35
|
+
_state(options: {
|
|
36
|
+
precision: number;
|
|
37
|
+
}): TypeF1DefRect;
|
|
38
|
+
/**
|
|
39
|
+
* Returns `true` if `point` is within or on the border of the rectangle
|
|
40
|
+
* @param {TypeParsablePoint} point point to test
|
|
41
|
+
* @param {number} precision precision to test
|
|
42
|
+
* @return {boolean}
|
|
43
|
+
* @example
|
|
44
|
+
* const r = new Rect(-2, -1, 4, 2);
|
|
45
|
+
*
|
|
46
|
+
* // check if point is within the rectangle (will return `true`)
|
|
47
|
+
* const result = r.isPointInside([0, 1]);
|
|
48
|
+
*/
|
|
49
|
+
isPointInside(point: TypeParsablePoint, precision?: number): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Returns a rectangle with coordinates rounded to `precision`
|
|
52
|
+
* @param {number} precision precision to test
|
|
53
|
+
* @return {Rect}
|
|
54
|
+
*/
|
|
55
|
+
round(precision?: number): Rect;
|
|
56
|
+
/**
|
|
57
|
+
* Find the intersect of the line from the center of the rectangle to the
|
|
58
|
+
* point, with the rectangle border.
|
|
59
|
+
* @param {TypeParsablePoint} point
|
|
60
|
+
* @return {Point | null} intersect
|
|
61
|
+
*/
|
|
62
|
+
intersectsWith(point: TypeParsablePoint): Point | null;
|
|
63
|
+
/**
|
|
64
|
+
* Find the intersect(s) between a line and rectangle
|
|
65
|
+
* @param {TypeParsableLine} line
|
|
66
|
+
* @return {Array<Point>}
|
|
67
|
+
*/
|
|
68
|
+
intersectsWithLine(line: TypeParsableLine): Array<Point | undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* The center point of the rectangle
|
|
71
|
+
* @return {Point}
|
|
72
|
+
*/
|
|
73
|
+
center(): Point;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Recorder state definition of a {@link Rect} that represents the left,
|
|
77
|
+
* bottom, width and height of the rectangle.
|
|
78
|
+
*
|
|
79
|
+
* ```
|
|
80
|
+
* {
|
|
81
|
+
* f1Type: 'rect',
|
|
82
|
+
* state: [number, number, number, number],
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
* @group Misc Geometry
|
|
86
|
+
*/
|
|
87
|
+
type TypeF1DefRect = {
|
|
88
|
+
f1Type: 'rect';
|
|
89
|
+
state: [number, number, number, number];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* A {@link Rect} can be defined with either
|
|
93
|
+
* - an instantiated {@link Rect}
|
|
94
|
+
* - an array of left, bottom, width, height values
|
|
95
|
+
* `[number, number, number, number]`
|
|
96
|
+
* - a recorder state definition {@link TypeF1DefRect}
|
|
97
|
+
* - a string representation of all options except the first
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* // All rectangles are the same when parsed by `getRect` and have a lower
|
|
101
|
+
* left corner of `(-2, -1)`, a width of `4`, and a height of `2`
|
|
102
|
+
* const r1 = Fig.getRect([-2, -1, 4, 2]);
|
|
103
|
+
* const r2 = new Fig.Rect(-2, -1, 4, 2);
|
|
104
|
+
* const r3 = Fig.getRect('[-2, -1, 4, 2]');
|
|
105
|
+
* @group Geometry
|
|
106
|
+
*/
|
|
107
|
+
export type TypeParsableRect = [number, number, number, number] | Rect | TypeF1DefRect | string;
|
|
108
|
+
/**
|
|
109
|
+
* Convert a parsable rectangle definition to a {@link Rect}.
|
|
110
|
+
* @param {TypeParsableRect} r parsable rectangle definition
|
|
111
|
+
* @return {Rect} rectangle object
|
|
112
|
+
* @group Misc Geometry
|
|
113
|
+
*/
|
|
114
|
+
declare function getRect(r: TypeParsableRect): Rect;
|
|
115
|
+
export { getRect, Rect, };
|