figureone 0.15.10 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/figureone.min.js +1 -1
  2. package/index.js +79170 -0
  3. package/llms.txt +548 -0
  4. package/package.json +16 -1
  5. package/types/index.d.ts +128 -0
  6. package/types/js/figure/Animation/Animation.d.ts +36 -0
  7. package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
  8. package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
  9. package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
  10. package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
  11. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
  12. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
  13. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
  14. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
  15. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
  16. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
  17. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
  18. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
  19. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
  20. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
  21. package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
  22. package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
  23. package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
  24. package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
  25. package/types/js/figure/DrawContext2D.d.ts +9 -0
  26. package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
  27. package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
  28. package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
  29. package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
  30. package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
  31. package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
  32. package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
  33. package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
  34. package/types/js/figure/Element.d.ts +1212 -0
  35. package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
  36. package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
  37. package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
  38. package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
  39. package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
  40. package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
  41. package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
  42. package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
  43. package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
  44. package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
  45. package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
  46. package/types/js/figure/Equation/Equation.d.ts +984 -0
  47. package/types/js/figure/Equation/EquationForm.d.ts +139 -0
  48. package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
  49. package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
  50. package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
  51. package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
  52. package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
  53. package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
  54. package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
  55. package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
  56. package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
  57. package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
  58. package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
  59. package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
  60. package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
  61. package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
  62. package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
  63. package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
  64. package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
  65. package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
  66. package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
  67. package/types/js/figure/Figure.d.ts +711 -0
  68. package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
  69. package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
  70. package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
  71. package/types/js/figure/FigureCollections/Button.d.ts +195 -0
  72. package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
  73. package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
  74. package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
  75. package/types/js/figure/FigureCollections/Line.d.ts +587 -0
  76. package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
  77. package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
  78. package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
  79. package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
  80. package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
  81. package/types/js/figure/FigureCollections/Text.d.ts +307 -0
  82. package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
  83. package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
  84. package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
  85. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
  86. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
  87. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
  88. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
  89. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
  90. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
  91. package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
  92. package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
  93. package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
  94. package/types/js/figure/FontManager.d.ts +113 -0
  95. package/types/js/figure/Gesture.d.ts +39 -0
  96. package/types/js/figure/Recorder/Recorder.d.ts +291 -0
  97. package/types/js/figure/Recorder/parseState.d.ts +3 -0
  98. package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
  99. package/types/js/figure/Recorder/state.d.ts +7 -0
  100. package/types/js/figure/SlideNavigator.d.ts +606 -0
  101. package/types/js/figure/TimeKeeper.d.ts +174 -0
  102. package/types/js/figure/geometries/arc.d.ts +18 -0
  103. package/types/js/figure/geometries/arrow.d.ts +215 -0
  104. package/types/js/figure/geometries/buffer.d.ts +4 -0
  105. package/types/js/figure/geometries/copy/copy.d.ts +178 -0
  106. package/types/js/figure/geometries/ellipse.d.ts +17 -0
  107. package/types/js/figure/geometries/line.d.ts +13 -0
  108. package/types/js/figure/geometries/lines/corners.d.ts +7 -0
  109. package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
  110. package/types/js/figure/geometries/lines/lines.d.ts +31 -0
  111. package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
  112. package/types/js/figure/geometries/rectangle.d.ts +19 -0
  113. package/types/js/figure/geometries/triangle.d.ts +27 -0
  114. package/types/js/figure/webgl/Atlas.d.ts +42 -0
  115. package/types/js/figure/webgl/shaders.d.ts +143 -0
  116. package/types/js/figure/webgl/target.d.ts +9 -0
  117. package/types/js/figure/webgl/webgl.d.ts +54 -0
  118. package/types/js/tools/FunctionMap.d.ts +69 -0
  119. package/types/js/tools/color.d.ts +11 -0
  120. package/types/js/tools/colorNames.d.ts +2 -0
  121. package/types/js/tools/d2/polygon.d.ts +60 -0
  122. package/types/js/tools/d2/triangles.d.ts +0 -0
  123. package/types/js/tools/d3/cone.d.ts +57 -0
  124. package/types/js/tools/d3/cube.d.ts +26 -0
  125. package/types/js/tools/d3/cylinder.d.ts +45 -0
  126. package/types/js/tools/d3/line3.d.ts +55 -0
  127. package/types/js/tools/d3/prism.d.ts +49 -0
  128. package/types/js/tools/d3/revolve.d.ts +87 -0
  129. package/types/js/tools/d3/sphere.d.ts +33 -0
  130. package/types/js/tools/d3/surface.d.ts +47 -0
  131. package/types/js/tools/g2.d.ts +242 -0
  132. package/types/js/tools/geometry/Bounds.d.ts +446 -0
  133. package/types/js/tools/geometry/Line.d.ts +314 -0
  134. package/types/js/tools/geometry/Path.d.ts +67 -0
  135. package/types/js/tools/geometry/Plane.d.ts +201 -0
  136. package/types/js/tools/geometry/Point.d.ts +359 -0
  137. package/types/js/tools/geometry/Rect.d.ts +115 -0
  138. package/types/js/tools/geometry/Transform.d.ts +623 -0
  139. package/types/js/tools/geometry/angle.d.ts +105 -0
  140. package/types/js/tools/geometry/common.d.ts +9 -0
  141. package/types/js/tools/geometry/coordinates.d.ts +30 -0
  142. package/types/js/tools/geometry/deceleration.d.ts +13 -0
  143. package/types/js/tools/geometry/polygon.d.ts +4 -0
  144. package/types/js/tools/geometry/quaternion.d.ts +15 -0
  145. package/types/js/tools/geometry/scene.d.ts +282 -0
  146. package/types/js/tools/geometry/tools.d.ts +8 -0
  147. package/types/js/tools/geometry/types.d.ts +2 -0
  148. package/types/js/tools/getCssColors.d.ts +1 -0
  149. package/types/js/tools/getCssVariables.d.ts +4 -0
  150. package/types/js/tools/getImageData.d.ts +1 -0
  151. package/types/js/tools/getScssColors.d.ts +2 -0
  152. package/types/js/tools/htmlGenerator.d.ts +85 -0
  153. package/types/js/tools/m2.d.ts +24 -0
  154. package/types/js/tools/m3.d.ts +71 -0
  155. package/types/js/tools/math.d.ts +112 -0
  156. package/types/js/tools/morph.d.ts +651 -0
  157. package/types/js/tools/styleSheets.d.ts +3 -0
  158. package/types/js/tools/tools.d.ts +281 -0
  159. package/types/js/tools/types.d.ts +305 -0
  160. package/figureone.worker.js +0 -1
@@ -0,0 +1,105 @@
1
+ import { Point } from './Point';
2
+ declare function deg(angle: number): number;
3
+ /**
4
+ * Get the minimum absolute angle difference between two angles
5
+ *
6
+ * @example
7
+ * const minAngleDiff = Fig.minAngleDiff;
8
+ * const d1 = minAngleDiff(0.1, 0.2);
9
+ * console.log(d1);
10
+ * // -0.1
11
+ *
12
+ * const d2 = minAngleDiff(0.2, 0.1);
13
+ * console.log(d2);
14
+ * // 0.1
15
+ *
16
+ * const d3 = minAngleDiff(0.1, -0.1);
17
+ * console.log(d3);
18
+ * // 0.2
19
+ * @group 2D Geometry Tools
20
+ */
21
+ declare function minAngleDiff(angle1: number, angle2: number): number;
22
+ /**
23
+ * Clip and angle between 0 and 2π (`'0to360'`) or -π to π (`'-180to180'`).
24
+ * `null` will return the angle between -2π to 2π.
25
+ * @example
26
+ * const clipAngle = Fig.clipAngle
27
+ *
28
+ * const a1 = clipAngle(Math.PI / 2 * 5, '0to360');
29
+ * console.log(a1);
30
+ * // 1.5707963267948966
31
+ *
32
+ * const a2 = clipAngle(Math.PI / 4 * 5, '-180to180');
33
+ * console.log(a2);
34
+ * // -2.356194490192345
35
+ *
36
+ * const a3 = clipAngle(-Math.PI / 4 * 10, null);
37
+ * console.log(a3);
38
+ * // -1.5707963267948966
39
+ * @group 2D Geometry Tools
40
+ */
41
+ declare function clipAngle(angleToClip: number, clipTo: '0to360' | '-180to180' | null | '-360to360' | '-360to0'): number;
42
+ /**
43
+ * Normalize angle to between 0 and 2π.
44
+ * @group 2D Geometry Tools
45
+ */
46
+ declare function normAngle(angle: number): number;
47
+ declare function normAngleTo90(angle: number): number;
48
+ /**
49
+ * TypeRotationDirection = 0 | 1 | 2 | -1 | null
50
+ *
51
+ * - 0: quickest direction
52
+ * - 1: positive direction (CCW in 2D)
53
+ * - -1: negative direction (CW in 2D)
54
+ * - 2: not through zero
55
+ * - null: returns numerical delta angle
56
+ * @group Misc Shapes
57
+ */
58
+ export type TypeRotationDirection = 0 | 1 | 2 | -1 | null;
59
+ /**
60
+ * Get angle delta based on direction
61
+ * @group 2D Geometry Tools
62
+ */
63
+ declare function getDeltaAngle(startAngle: number, targetAngle: number, rotDirection?: TypeRotationDirection): number;
64
+ /**
65
+ * Get delta angle of a Point where the x, y, z components are rotations
66
+ * around the x, y, and z axes.
67
+ * @group 2D Geometry Tools
68
+ */
69
+ declare function getDeltaAngle3D(startAngle: Point, targetAngle: Point, rotDirection?: TypeRotationDirection | [TypeRotationDirection, TypeRotationDirection, TypeRotationDirection]): Point;
70
+ /**
71
+ * Returns the angle from the line (p1, p2) to the line (p1, p3) in the positive
72
+ * rotation direction and normalized from 0 to Math.PI * 2.
73
+ *
74
+ * @example
75
+ * const threePointAngle = Fig.threePointAngle;
76
+ * const getPoint = Fig.getPoint;
77
+ *
78
+ * const p1 = threePointAngle(getPoint([1, 0]), getPoint([0, 0]), getPoint([0, 1]));
79
+ * console.log(p1);
80
+ * // 1.5707963267948966
81
+ *
82
+ * const p2 = threePointAngle(getPoint([0, 1]), getPoint([0, 0]), getPoint([1, 0]));
83
+ * console.log(p2);
84
+ * // 4.71238898038469
85
+ * @group 2D Geometry Tools
86
+ */
87
+ declare function threePointAngle(p2: Point, p1: Point, p3: Point): number;
88
+ /**
89
+ * Returns the minimum angle from the line (p1, p2) to the line (p1, p3).
90
+ *
91
+ * @example
92
+ * const threePointAngleMin = Fig.threePointAngleMin;
93
+ * const getPoint = Fig.getPoint;
94
+ *
95
+ * const p1 = threePointAngleMin(getPoint([1, 0]), getPoint([0, 0]), getPoint([0, 1]));
96
+ * console.log(p1);
97
+ // 1.5707963267948966
98
+ *
99
+ * const p2 = threePointAngleMin(getPoint([0, 1]), getPoint([0, 0]), getPoint([1, 0]));
100
+ * console.log(p2);
101
+ * // -1.5707963267948966
102
+ * @group 2D Geometry Tools
103
+ */
104
+ declare function threePointAngleMin(p2: Point, p1: Point, p3: Point): number;
105
+ export { deg, minAngleDiff, getDeltaAngle3D, getDeltaAngle, normAngleTo90, threePointAngle, threePointAngleMin, clipAngle, normAngle, };
@@ -0,0 +1,9 @@
1
+ import type { Type3Components } from './types';
2
+ declare function getPrecision(options?: {
3
+ precision?: number;
4
+ }, defaultPrecision?: number): number;
5
+ declare function dotProduct(a: Type3Components, b: Type3Components): number;
6
+ declare function quadraticBezier(P0: number, P1: number, P2: number, t: number): number;
7
+ declare function cartesianToSpherical(x: number, y?: number, z?: number): [number, number, number];
8
+ declare function sphericalToCartesian(r: number, theta: number, phi: number): [number, number, number];
9
+ export { getPrecision, dotProduct, quadraticBezier, cartesianToSpherical, sphericalToCartesian, };
@@ -0,0 +1,30 @@
1
+ import { Point } from './Point';
2
+ /**
3
+ * Polar coordinates to cartesian coordinates conversion
4
+ *
5
+ * @example
6
+ * const polarToRect = Fig.polarToRect;
7
+ * const p = polarToRect(Math.sqrt(2), Math.PI / 4);
8
+ * console.log(p);
9
+ * // Point {x: 1, y: 1)
10
+ * @group 2D Geometry Tools
11
+ */
12
+ declare function polarToRect(mag: number, angle: number, theta?: number | null): Point;
13
+ /**
14
+ * Cartesian coordinates to polar coordinates conversion
15
+ *
16
+ * @example
17
+ * const rectToPolar = Fig.rectToPolar;
18
+ * const p = rectToPolar(0, 1);
19
+ * console.log(p);
20
+ * // {mag: 1, angle: 1.5707963267948966}
21
+ * @group 2D Geometry Tools
22
+ */
23
+ declare function rectToPolar(x: number | Point, y?: number, z?: number): {
24
+ angle: number;
25
+ mag: number;
26
+ phi: number;
27
+ r: number;
28
+ theta: number;
29
+ };
30
+ export { rectToPolar, polarToRect, };
@@ -0,0 +1,13 @@
1
+ import { Point } from './Point';
2
+ import { RectBounds, RangeBounds, LineBounds } from './Bounds';
3
+ declare function decelerateValue(valueIn: number, velocityIn: number, decelerationIn: number, deltaTimeIn?: number | null, bounds?: null | RangeBounds, bounceLossIn?: number, zeroVelocityThreshold?: number, precision?: number): {
4
+ velocity: number;
5
+ duration: null | number;
6
+ value: number;
7
+ };
8
+ declare function decelerateVector(positionIn: Point, velocityIn: Point, decelerationIn: number, deltaTimeIn?: number | null, bounds?: null | RectBounds | LineBounds, bounceLossIn?: number, zeroVelocityThreshold?: number, precision?: number): {
9
+ velocity: Point;
10
+ position: Point;
11
+ duration: number | null;
12
+ };
13
+ export { decelerateVector, decelerateValue, };
@@ -0,0 +1,4 @@
1
+ import { Point } from './Point';
2
+ declare function isPointInPolygon(point: Point, polygonCorners: Array<Point>): boolean;
3
+ declare function isPointOnPolygon(point: Point, polygonCorners: Array<Point>): boolean;
4
+ export { isPointInPolygon, isPointOnPolygon, };
@@ -0,0 +1,15 @@
1
+ import type { TypeParsablePoint, Point } from './Point';
2
+ export type TypeQuaternion = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ d: number;
7
+ };
8
+ declare function quaternion(a: number, b: number, c: number, d: number): TypeQuaternion;
9
+ declare function quaternionFromPoint(p: TypeParsablePoint): TypeQuaternion;
10
+ declare function quaternionFromAngleAxis(angle: number, x: number, y: number, z: number): TypeQuaternion;
11
+ declare function mul(q1: TypeQuaternion, q2: TypeQuaternion): TypeQuaternion;
12
+ declare function inverse(q: TypeQuaternion): TypeQuaternion;
13
+ declare function transformPoint(p: TypeParsablePoint, q: TypeQuaternion): Point;
14
+ declare function rotatePoint(p: TypeParsablePoint, angleOrRotations: number | Array<[number, TypeParsablePoint]>, axis?: TypeParsablePoint): Point;
15
+ export { quaternion, quaternionFromPoint, quaternionFromAngleAxis, mul, inverse, transformPoint, rotatePoint, };
@@ -0,0 +1,282 @@
1
+ import type { TypeParsablePoint } from './Point';
2
+ import { Point } from './Point';
3
+ import { Plane } from './Plane';
4
+ import type { Type3DMatrix } from '../m3';
5
+ /**
6
+ * @property {'orthographic' | 'perspective' | '2D'} [style]
7
+ * @property {number} [left]
8
+ * @property {number} [right]
9
+ * @property {number} [bottom]
10
+ * @property {number} [top]
11
+ * @property {number} [aspectRatio]
12
+ * @property {number} [fieldOfView]
13
+ * @property {number} [near]
14
+ * @property {number} [far]
15
+ * @interface
16
+ * @group Misc Shapes
17
+ */
18
+ export type OBJ_Projection = {
19
+ style?: 'orthographic' | 'perspective' | '2D';
20
+ left?: number;
21
+ right?: number;
22
+ bottom?: number;
23
+ top?: number;
24
+ aspectRatio?: number;
25
+ fieldOfView?: number;
26
+ near?: number;
27
+ far?: number;
28
+ };
29
+ export type OBJ_CameraDefined = {
30
+ position: TypeParsablePoint;
31
+ lookAt: TypeParsablePoint;
32
+ up: TypeParsablePoint;
33
+ };
34
+ /**
35
+ * @property {TypeParsablePoint} [position]
36
+ * @property {TypeParsablePoint} [lookAt]
37
+ * @property {TypeParsablePoint} [up]
38
+ * @interface
39
+ * @group Misc Shapes
40
+ */
41
+ export type OBJ_Camera = {
42
+ position?: TypeParsablePoint;
43
+ lookAt?: TypeParsablePoint;
44
+ up?: TypeParsablePoint;
45
+ };
46
+ /**
47
+ * @property {TypeParsablePoint} [directional]
48
+ * @property {number} [ambient]
49
+ * @property {TypeParsablePoint} [point]
50
+ * @interface
51
+ * @group Misc Shapes
52
+ */
53
+ export type OBJ_Light = {
54
+ directional?: TypeParsablePoint;
55
+ ambient?: number;
56
+ point?: TypeParsablePoint;
57
+ };
58
+ export type OBJ_LightDefined = {
59
+ directional: TypeParsablePoint;
60
+ ambient: number;
61
+ point: TypeParsablePoint;
62
+ };
63
+ /**
64
+ * The Scene options object defines how the elements within the figure are
65
+ * viewed.
66
+ *
67
+ * For 2D figures (`style: '2D'`), `left`, `right`, `bottom`, and `top` are
68
+ * required to define the x-y expanse to view. Any elements or portions of
69
+ * elements outside of this expanse will not be shown (be clipped).
70
+ *
71
+ * For 3D figures, a camera, lighting and the near/far clipping planes also
72
+ * need definition.
73
+ * @interface
74
+ * @group Misc Shapes
75
+ */
76
+ export type OBJ_Scene = {
77
+ style?: '2D' | 'orthographic' | 'perspective';
78
+ left?: number;
79
+ right?: number;
80
+ bottom?: number;
81
+ top?: number;
82
+ near?: number;
83
+ far?: number;
84
+ aspectRatio?: number;
85
+ fieldOfView?: number;
86
+ light?: OBJ_Light;
87
+ camera?: OBJ_Camera;
88
+ zoom?: number;
89
+ pan?: Point;
90
+ };
91
+ /**
92
+ * @property {number} [left]
93
+ * @property {number} [right]
94
+ * @property {number} [bottom]
95
+ * @property {number} [top]
96
+ * @interface
97
+ * @group Misc Shapes
98
+ */
99
+ export type OBJ_2DScene = {
100
+ left?: number;
101
+ right?: number;
102
+ bottom?: number;
103
+ top?: number;
104
+ };
105
+ /**
106
+ * @property {number} [left]
107
+ * @property {number} [right]
108
+ * @property {number} [bottom]
109
+ * @property {number} [top]
110
+ * @property {number} [near]
111
+ * @property {number} [far]
112
+ * @interface
113
+ * @group Misc Shapes
114
+ */
115
+ export type OBJ_OrthographicScene = {
116
+ left?: number;
117
+ right?: number;
118
+ bottom?: number;
119
+ top?: number;
120
+ near?: number;
121
+ far?: number;
122
+ };
123
+ /**
124
+ * @property {aspectRatio} [number]
125
+ * @property {fieldOfView} [number]
126
+ * @property {near} [number]
127
+ * @property {far} [number]
128
+ * @interface
129
+ * @group Misc Shapes
130
+ */
131
+ export type OBJ_PerspectiveScene = {
132
+ aspectRatio?: number;
133
+ fieldOfView?: number;
134
+ near?: number;
135
+ far?: number;
136
+ };
137
+ export type OBJ_SceneDefined = {
138
+ style: '2D' | 'orthographic' | 'perspective';
139
+ left: number;
140
+ right: number;
141
+ bottom: number;
142
+ top: number;
143
+ near: number;
144
+ far: number;
145
+ camera: OBJ_Camera;
146
+ aspectRatio: number;
147
+ fieldOfView: number;
148
+ light: OBJ_Light;
149
+ projectionMatrix: Type3DMatrix;
150
+ viewMatrix: Type3DMatrix;
151
+ };
152
+ /**
153
+ * Scene.
154
+ *
155
+ * @param {OBJ_Scene} options scene definition options
156
+ * @param {null | (() => void)} onUpdate callback if scene is updated
157
+ * @group Misc Shapes
158
+ */
159
+ export default class Scene {
160
+ style: '2D' | 'orthographic' | 'perspective';
161
+ left: number;
162
+ right: number;
163
+ bottom: number;
164
+ top: number;
165
+ near: number;
166
+ far: number;
167
+ camera: OBJ_CameraDefined;
168
+ aspectRatio: number;
169
+ fieldOfView: number;
170
+ light: OBJ_LightDefined;
171
+ projectionMatrix: Type3DMatrix;
172
+ viewMatrix: Type3DMatrix;
173
+ cameraMatrix: Type3DMatrix;
174
+ viewProjectionMatrix: Type3DMatrix;
175
+ onUpdate: null | (() => void);
176
+ cameraPosition: Point;
177
+ cameraVector: Point;
178
+ inverseViewProjectionMatrix: Type3DMatrix;
179
+ rightVector: Point;
180
+ upVector: Point;
181
+ nearCenter: Point;
182
+ farCenter: Point;
183
+ nearPlane: Plane;
184
+ farPlane: Plane;
185
+ heightNear: number;
186
+ heightFar: number;
187
+ widthNear: number;
188
+ widthFar: number;
189
+ zoom: number;
190
+ pan: Point;
191
+ pannedCameraPosition: Point;
192
+ pannedLookAt: Point;
193
+ defaultOptions(): {
194
+ aspectRatio: number;
195
+ bottom: number;
196
+ camera: {
197
+ lookAt: number[] | TypeParsablePoint;
198
+ position: number[] | TypeParsablePoint;
199
+ up: number[] | TypeParsablePoint;
200
+ };
201
+ far: number;
202
+ fieldOfView: number;
203
+ left: number;
204
+ light: {
205
+ ambient: number;
206
+ directional: number[] | TypeParsablePoint;
207
+ point: number[] | TypeParsablePoint;
208
+ };
209
+ near: number;
210
+ right: number;
211
+ style: '2D' | 'orthographic' | 'perspective';
212
+ top: number;
213
+ zoom: number;
214
+ pan: Point;
215
+ };
216
+ constructor(options: OBJ_Scene, onUpdate?: null | (() => void));
217
+ reset(options: OBJ_Scene): void;
218
+ dup(): Scene;
219
+ calcProjectionMatrix(): void;
220
+ calcViewMatrix(): void;
221
+ calcViewProjectionMatrix(): void;
222
+ dupMatrix(matrix: Type3DMatrix): Type3DMatrix;
223
+ /**
224
+ * Set the pan and zoom of the scene.
225
+ *
226
+ * Pan is applied to `camera.position` and `camera.lookAt`, while
227
+ * zoom is applied to
228
+ * `camera.left`/`camera.bottom`/`camera.right`/`camera.top` (for 2D and
229
+ * orthographic) or `camera.fov` (for perspective)
230
+ *
231
+ * The camera and projection variables are not changed by pan and zoom, but
232
+ * the the view and projection matrices are.
233
+ *
234
+ * A pan in the positive direction will move the scene left and down.
235
+ *
236
+ * A zoom greater than 1 will reduce the left/right/bottom/top or fov
237
+ * effectively magnifying the scene.
238
+ *
239
+ * @param {Point} pan
240
+ * @param {number} zoom
241
+ */
242
+ setPanZoom(pan: Point, zoom: number): void;
243
+ /**
244
+ * Set the pan of the scene.
245
+ *
246
+ * Pan is applied to `camera.position` and `camera.lookAt`.
247
+ *
248
+ * The camera is changed by pan and zoom, but the resulting view matrix is.
249
+ *
250
+ * A pan in the positive direction will move the scene left and down.
251
+ *
252
+ * @param {Point} pan
253
+ */
254
+ setPan(pan: Point): void;
255
+ /**
256
+ * Set camera properties.
257
+ */
258
+ setCamera(options: OBJ_Camera): void;
259
+ setCameraProperties(options: OBJ_Camera): void;
260
+ /**
261
+ * Set projection properties.
262
+ */
263
+ setProjection(options: OBJ_Projection): void;
264
+ /**
265
+ * Set a 2D scene.
266
+ */
267
+ set2D(options: OBJ_2DScene): void;
268
+ /**
269
+ * Set an orthographic scene.
270
+ */
271
+ setOrthographic(options: OBJ_OrthographicScene): void;
272
+ /**
273
+ * Set a perspective scene.
274
+ */
275
+ setPerspective(options: OBJ_PerspectiveScene): void;
276
+ /**
277
+ * Set light properties
278
+ */
279
+ setLight(options: OBJ_Light): void;
280
+ figureToGL(figurePoint: TypeParsablePoint): Point;
281
+ glToFigure(glPoint: TypeParsablePoint): Point;
282
+ }
@@ -0,0 +1,8 @@
1
+ import { Point } from './Point';
2
+ declare function pointsToNumbers2(points: Point[]): number[];
3
+ declare function pointsToNumbers(points: Point[], dimension?: 2 | 3): number[];
4
+ declare function numbersToPoints2(numbers: number[]): Point[];
5
+ declare function numbersToPoints(numbers: number[], dimension?: 2 | 3): Point[];
6
+ declare function toNumbers(pointsOrNumbers: Point[] | number[][] | number[], dimension?: 2 | 3): number[];
7
+ declare function toPoints(pointsOrNumbers: Point[] | number[], dimension?: 2 | 3): Point[];
8
+ export { pointsToNumbers2, pointsToNumbers, numbersToPoints, numbersToPoints2, toNumbers, toPoints, };
@@ -0,0 +1,2 @@
1
+ export type Type3Components = [number, number, number];
2
+ export type Type2Components = [number, number];
@@ -0,0 +1 @@
1
+ export default function getCSSColors(customColorNames?: Array<string>): Record<string, any>;
@@ -0,0 +1,4 @@
1
+ declare function searchObject(obj: Record<string, any>, path: string, text: string): string[];
2
+ declare function getDefinedCSSVariables(idOrElement: string | HTMLElement, propertyNames: Array<string>, prefix?: string, makeFlat?: boolean, modifier?: (value: string | number) => string | number): Record<string, any>;
3
+ declare function getCSSVariables(idOrElement: string | HTMLElement, prefix?: string, makeFlat?: boolean): Record<string, any>;
4
+ export { getCSSVariables, getDefinedCSSVariables, searchObject };
@@ -0,0 +1 @@
1
+ export default function getImageData(image: HTMLImageElement): ImageDataArray;
@@ -0,0 +1,2 @@
1
+ declare const getScssColors: (styles: Record<string, string>) => Record<string, number[]>;
2
+ export default getScssColors;
@@ -0,0 +1,85 @@
1
+ import type { TypeColor } from './types';
2
+ declare function withClass(text: (string | Array<string>) | undefined, classText: string): string;
3
+ declare function centerV(text?: string | Array<string>): string;
4
+ declare function centerVH(text?: string | Array<string>): string;
5
+ declare function centerH(text?: string | Array<string>): string;
6
+ declare function style(options?: number | {
7
+ left?: number;
8
+ top?: number;
9
+ line?: number;
10
+ right?: number;
11
+ size?: number;
12
+ className?: string;
13
+ color?: TypeColor;
14
+ centerV?: boolean;
15
+ centerH?: boolean;
16
+ list?: 'ordered' | 'unordered' | null;
17
+ listStyleType?: string;
18
+ id?: string;
19
+ }, text?: string | Array<string>): string;
20
+ declare function itemSelector(items?: Array<string>, classes?: string, selectorIndex?: number): string;
21
+ declare const unit: (deg: string, rad: string) => string;
22
+ declare function toHTML(text?: string, id?: string, classes?: string, color?: TypeColor | null): {
23
+ replacementText: string;
24
+ };
25
+ declare function highlight(classesOrColor?: string | Array<number>): {
26
+ replacementText: (text: string) => {
27
+ replacementText: string;
28
+ };
29
+ };
30
+ declare function link(linkStr: string, colorOrOptions?: Array<number> | {
31
+ color?: Array<number> | null;
32
+ id?: string;
33
+ classes?: string;
34
+ text?: string | null;
35
+ newTab?: boolean | null;
36
+ } | null): {
37
+ replacementText: (textIn: string) => {
38
+ replacementText: string;
39
+ };
40
+ id: () => string;
41
+ };
42
+ declare function highlightWord(text: string, classesOrColor?: string | Array<number>): {
43
+ replacementText: string;
44
+ };
45
+ declare function addClass(classes?: string): {
46
+ replacementText: (text: string) => {
47
+ replacementText: string;
48
+ };
49
+ };
50
+ declare function addId(id?: string): {
51
+ replacementText: (text: string) => {
52
+ replacementText: string;
53
+ };
54
+ };
55
+ declare function click(actionMethod: Function, bind: Array<any>, colorOrOptions?: Array<number> | {
56
+ color?: Array<number> | null;
57
+ interactive?: boolean;
58
+ id?: string;
59
+ classes?: string;
60
+ text?: string | null;
61
+ } | null): {
62
+ replacementText: (textIn: string) => {
63
+ replacementText: string;
64
+ };
65
+ id: () => string;
66
+ actionMethod: Function;
67
+ bind: any[];
68
+ };
69
+ declare function clickW(textToUse: string, actionMethod: Function, bind: Array<any>, color?: TypeColor | null): {
70
+ replacementText: (textIn: string) => {
71
+ replacementText: string;
72
+ };
73
+ id: () => string;
74
+ actionMethod: Function;
75
+ bind: any[];
76
+ };
77
+ declare function actionWord(text: string, id?: string, classesOrColor?: string | Array<number> | null, interactive?: boolean): {
78
+ replacementText: string;
79
+ id: string;
80
+ };
81
+ declare function onClickId(id: string, actionMethod: Function, bind: Array<any>, additionalClassesToAdd?: string): void;
82
+ declare function applyModifiers(text: string, modifiers: Record<string, any>, highlightClass?: string, monochrome?: boolean): string;
83
+ declare function setOnClicks(modifiers: Record<string, any>, additionalClassesToAdd?: string): void;
84
+ declare function setHTML(element: HTMLElement, text: string, modifiers?: Record<string, any>, classesToAdd?: string): void;
85
+ export { actionWord, click, highlight, addClass, addId, onClickId, highlightWord, centerV, centerH, centerVH, toHTML, itemSelector, unit, applyModifiers, setOnClicks, setHTML, withClass, style, clickW, link, };
@@ -0,0 +1,24 @@
1
+ export type Type2DMatrix = [
2
+ number,
3
+ number,
4
+ number,
5
+ number,
6
+ number,
7
+ number,
8
+ number,
9
+ number,
10
+ number
11
+ ];
12
+ declare function mul(a: Type2DMatrix, b: Type2DMatrix): Type2DMatrix;
13
+ declare function t(a: Type2DMatrix): Type2DMatrix;
14
+ declare function identity(): Type2DMatrix;
15
+ declare function copy(a: Type2DMatrix): Type2DMatrix;
16
+ declare function translationMatrix(tx: number, ty: number): Type2DMatrix;
17
+ declare function translate(m: Type2DMatrix, tx: number, ty: number): Type2DMatrix;
18
+ declare function rotationMatrix(angle: number): Type2DMatrix;
19
+ declare function rotate(m: Type2DMatrix, angle: number): Type2DMatrix;
20
+ declare function scaleMatrix(sx: number, sy: number): Type2DMatrix;
21
+ declare function scale(m: Type2DMatrix, sx: number, sy: number): Type2DMatrix;
22
+ declare function transform(m: Type2DMatrix, px: number, py: number): [number, number];
23
+ declare function inverse(m: Type2DMatrix): Type2DMatrix;
24
+ export { mul, identity, t, copy, translate, rotate, transform, scale, inverse, rotationMatrix, translationMatrix, scaleMatrix, };
@@ -0,0 +1,71 @@
1
+ export type Type3DMatrix = [
2
+ number,
3
+ number,
4
+ number,
5
+ number,
6
+ number,
7
+ number,
8
+ number,
9
+ number,
10
+ number,
11
+ number,
12
+ number,
13
+ number,
14
+ number,
15
+ number,
16
+ number,
17
+ number
18
+ ];
19
+ export type Type3Matrix = [
20
+ number,
21
+ number,
22
+ number,
23
+ number,
24
+ number,
25
+ number,
26
+ number,
27
+ number,
28
+ number
29
+ ];
30
+ export type Type2DMatrix = [
31
+ number,
32
+ number,
33
+ number,
34
+ number,
35
+ number,
36
+ number,
37
+ number,
38
+ number,
39
+ number
40
+ ];
41
+ export type Type3Vector = [number, number, number];
42
+ declare function mul(a: Type3DMatrix, b: Type3DMatrix): Type3DMatrix;
43
+ declare function transpose(a: Type3DMatrix): Type3DMatrix;
44
+ declare function identity(): Type3DMatrix;
45
+ declare function copy(a: Type3DMatrix): Type3DMatrix;
46
+ declare function translationMatrix(tx: number, ty: number, tz: number): Type3DMatrix;
47
+ declare function translate(m: Type3DMatrix, tx: number, ty: number, tz: number): Type3DMatrix;
48
+ declare function rotationMatrixX(angle: number): Type3DMatrix;
49
+ declare function rotationMatrixY(angle: number): Type3DMatrix;
50
+ declare function rotationMatrixZ(angle: number): Type3DMatrix;
51
+ declare function rotationMatrixXYZ(rx: number, ry: number, rz: number): Type3DMatrix;
52
+ declare function rotationMatrixUnitAxis(axis: [number, number, number], angle: number): Type3DMatrix;
53
+ declare function rotationMatrixAxis(axis: [number, number, number], angle: number): Type3DMatrix;
54
+ declare function rotationMatrixVectorToVector(fromVector: [number, number, number], toVector: [number, number, number]): Type3DMatrix;
55
+ declare function rotationMatrixDirection(vector: [number, number, number]): Type3DMatrix;
56
+ declare function directionToAxisAngle(vector: [number, number, number], axisIfCollinear?: [number, number, number]): [[number, number, number], number];
57
+ declare function vectorToVectorToAxisAngle(fromVector: [number, number, number], toVector: [number, number, number], axisIfCollinear?: [number, number, number] | null): [[number, number, number], number];
58
+ declare function rotate(m: Type3DMatrix, rx: number, ry: number, rz: number): Type3DMatrix;
59
+ declare function scaleMatrix(sx: number, sy: number, sz: number): Type3DMatrix;
60
+ declare function scale(m: Type3DMatrix, sx: number, sy: number, sz: number): Type3DMatrix;
61
+ declare function transform(m: Type3DMatrix, px: number, py: number, pz: number): [number, number, number];
62
+ declare function transformVectorT(m: Type3DMatrix, v: [number, number, number, number]): [number, number, number, number];
63
+ declare function transformVector(m: Type3DMatrix, v: [number, number, number, number]): [number, number, number, number];
64
+ declare function orthographic(left: number, right: number, bottom: number, top: number, near: number, far: number): Type3DMatrix;
65
+ declare function perspective(fieldOfView: number, aspectRatio: number, near: number, far: number): Type3DMatrix;
66
+ declare function lookAt(cameraPosition: [number, number, number], target: [number, number, number], up: [number, number, number]): Type3DMatrix;
67
+ declare function basisToBasisMatrix(from: [Type3Vector, Type3Vector, Type3Vector], to: [Type3Vector, Type3Vector, Type3Vector]): Type3DMatrix;
68
+ declare function basisMatrix(i: Type3Vector, j: Type3Vector, k: Type3Vector): Type3DMatrix;
69
+ declare function inverse(A: Type3DMatrix): Type3DMatrix;
70
+ declare function dup(A: Type3DMatrix): Type3DMatrix;
71
+ export { mul, identity, transpose, copy, translate, rotate, transform, scale, translationMatrix, scaleMatrix, rotationMatrixX, rotationMatrixY, rotationMatrixZ, basisToBasisMatrix, basisMatrix, rotationMatrixDirection, rotationMatrixXYZ, rotationMatrixAxis, rotationMatrixVectorToVector, rotationMatrixUnitAxis, inverse, orthographic, perspective, lookAt, transformVector, transformVectorT, dup, directionToAxisAngle, vectorToVectorToAxisAngle, };