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.
Files changed (159) hide show
  1. package/figureone.min.js +1 -1
  2. package/index.js +79167 -0
  3. package/package.json +15 -1
  4. package/types/index.d.ts +132 -0
  5. package/types/js/figure/Animation/Animation.d.ts +36 -0
  6. package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
  7. package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
  8. package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
  9. package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
  10. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
  11. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
  12. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
  13. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
  14. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
  15. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
  16. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
  17. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
  18. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
  19. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
  20. package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
  21. package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
  22. package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
  23. package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
  24. package/types/js/figure/DrawContext2D.d.ts +9 -0
  25. package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
  26. package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
  27. package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
  28. package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
  29. package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
  30. package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
  31. package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
  32. package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
  33. package/types/js/figure/Element.d.ts +1212 -0
  34. package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
  35. package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
  36. package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
  37. package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
  38. package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
  39. package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
  40. package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
  41. package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
  42. package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
  43. package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
  44. package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
  45. package/types/js/figure/Equation/Equation.d.ts +984 -0
  46. package/types/js/figure/Equation/EquationForm.d.ts +139 -0
  47. package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
  48. package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
  49. package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
  50. package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
  51. package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
  52. package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
  53. package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
  54. package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
  55. package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
  56. package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
  57. package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
  58. package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
  59. package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
  60. package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
  61. package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
  62. package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
  63. package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
  64. package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
  65. package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
  66. package/types/js/figure/Figure.d.ts +711 -0
  67. package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
  68. package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
  69. package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
  70. package/types/js/figure/FigureCollections/Button.d.ts +195 -0
  71. package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
  72. package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
  73. package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
  74. package/types/js/figure/FigureCollections/Line.d.ts +587 -0
  75. package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
  76. package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
  77. package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
  78. package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
  79. package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
  80. package/types/js/figure/FigureCollections/Text.d.ts +307 -0
  81. package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
  82. package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
  83. package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
  84. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
  85. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
  86. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
  87. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
  88. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
  89. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
  90. package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
  91. package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
  92. package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
  93. package/types/js/figure/FontManager.d.ts +113 -0
  94. package/types/js/figure/Gesture.d.ts +39 -0
  95. package/types/js/figure/Recorder/Recorder.d.ts +291 -0
  96. package/types/js/figure/Recorder/parseState.d.ts +3 -0
  97. package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
  98. package/types/js/figure/Recorder/state.d.ts +7 -0
  99. package/types/js/figure/SlideNavigator.d.ts +606 -0
  100. package/types/js/figure/TimeKeeper.d.ts +174 -0
  101. package/types/js/figure/geometries/arc.d.ts +18 -0
  102. package/types/js/figure/geometries/arrow.d.ts +215 -0
  103. package/types/js/figure/geometries/buffer.d.ts +4 -0
  104. package/types/js/figure/geometries/copy/copy.d.ts +178 -0
  105. package/types/js/figure/geometries/ellipse.d.ts +17 -0
  106. package/types/js/figure/geometries/line.d.ts +13 -0
  107. package/types/js/figure/geometries/lines/corners.d.ts +7 -0
  108. package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
  109. package/types/js/figure/geometries/lines/lines.d.ts +31 -0
  110. package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
  111. package/types/js/figure/geometries/rectangle.d.ts +19 -0
  112. package/types/js/figure/geometries/triangle.d.ts +27 -0
  113. package/types/js/figure/webgl/Atlas.d.ts +42 -0
  114. package/types/js/figure/webgl/shaders.d.ts +143 -0
  115. package/types/js/figure/webgl/target.d.ts +9 -0
  116. package/types/js/figure/webgl/webgl.d.ts +54 -0
  117. package/types/js/tools/FunctionMap.d.ts +69 -0
  118. package/types/js/tools/color.d.ts +11 -0
  119. package/types/js/tools/colorNames.d.ts +2 -0
  120. package/types/js/tools/d2/polygon.d.ts +60 -0
  121. package/types/js/tools/d2/triangles.d.ts +0 -0
  122. package/types/js/tools/d3/cone.d.ts +57 -0
  123. package/types/js/tools/d3/cube.d.ts +26 -0
  124. package/types/js/tools/d3/cylinder.d.ts +45 -0
  125. package/types/js/tools/d3/line3.d.ts +55 -0
  126. package/types/js/tools/d3/prism.d.ts +49 -0
  127. package/types/js/tools/d3/revolve.d.ts +87 -0
  128. package/types/js/tools/d3/sphere.d.ts +33 -0
  129. package/types/js/tools/d3/surface.d.ts +47 -0
  130. package/types/js/tools/g2.d.ts +242 -0
  131. package/types/js/tools/geometry/Bounds.d.ts +446 -0
  132. package/types/js/tools/geometry/Line.d.ts +314 -0
  133. package/types/js/tools/geometry/Path.d.ts +67 -0
  134. package/types/js/tools/geometry/Plane.d.ts +201 -0
  135. package/types/js/tools/geometry/Point.d.ts +359 -0
  136. package/types/js/tools/geometry/Rect.d.ts +115 -0
  137. package/types/js/tools/geometry/Transform.d.ts +623 -0
  138. package/types/js/tools/geometry/angle.d.ts +105 -0
  139. package/types/js/tools/geometry/common.d.ts +9 -0
  140. package/types/js/tools/geometry/coordinates.d.ts +30 -0
  141. package/types/js/tools/geometry/deceleration.d.ts +13 -0
  142. package/types/js/tools/geometry/polygon.d.ts +4 -0
  143. package/types/js/tools/geometry/quaternion.d.ts +15 -0
  144. package/types/js/tools/geometry/scene.d.ts +282 -0
  145. package/types/js/tools/geometry/tools.d.ts +8 -0
  146. package/types/js/tools/geometry/types.d.ts +2 -0
  147. package/types/js/tools/getCssColors.d.ts +1 -0
  148. package/types/js/tools/getCssVariables.d.ts +4 -0
  149. package/types/js/tools/getImageData.d.ts +1 -0
  150. package/types/js/tools/getScssColors.d.ts +2 -0
  151. package/types/js/tools/htmlGenerator.d.ts +85 -0
  152. package/types/js/tools/m2.d.ts +24 -0
  153. package/types/js/tools/m3.d.ts +71 -0
  154. package/types/js/tools/math.d.ts +112 -0
  155. package/types/js/tools/morph.d.ts +651 -0
  156. package/types/js/tools/styleSheets.d.ts +3 -0
  157. package/types/js/tools/tools.d.ts +281 -0
  158. package/types/js/tools/types.d.ts +305 -0
  159. package/figureone.worker.js +0 -1
@@ -0,0 +1,173 @@
1
+ import { Point } from '../../tools/g2';
2
+ import type { TypeParsablePoint } from '../../tools/g2';
3
+ import { FigureElementPrimitive } from '../Element';
4
+ import WebGLInstance from '../webgl/webgl';
5
+ import DrawContext2D from '../DrawContext2D';
6
+ import FigureElementPrimitiveMorph from './FigureElementPrimitiveMorph';
7
+ import FigureElementPrimitiveGLText from './FigureElementPrimitiveGLText';
8
+ import type { TypeColor, OBJ_Font } from '../../tools/types';
9
+ import type TimeKeeper from '../TimeKeeper';
10
+ import type { Recorder } from '../Recorder/Recorder';
11
+ import Scene from '../../tools/geometry/scene';
12
+ import FigureElementPrimitiveGesture from './FigureElementPrimitiveGesture';
13
+ import type { OBJ_Gesture } from './FigureElementPrimitiveGesture';
14
+ import type { OBJ_LineStyleSimple, OBJ_GenericGL, OBJ_Morph, OBJ_Text } from './FigurePrimitiveTypes';
15
+ import type { OBJ_Generic, OBJ_Polyline, OBJ_Polygon, OBJ_Polygon_Defined, OBJ_Star, OBJ_Rectangle, OBJ_Ellipse, OBJ_Arc, OBJ_Triangle, OBJ_Line, OBJ_Grid, OBJ_Arrow } from './FigurePrimitiveTypes2D';
16
+ import type { OBJ_Generic3, OBJ_Sphere, OBJ_Cube, OBJ_Cylinder, OBJ_Cone, OBJ_Revolve, OBJ_Surface, OBJ_Line3, OBJ_CameraControl, OBJ_Prism } from './FigurePrimitiveTypes3D';
17
+ type OBJ_PolyLineTris = OBJ_LineStyleSimple & {
18
+ drawBorderBuffer: number | Array<Array<Point>>;
19
+ };
20
+ /**
21
+ * Built in figure primitives.
22
+ *
23
+ * Including simple shapes, grid and text.
24
+ * @group Misc Figure Element
25
+ */
26
+ export default class FigurePrimitives {
27
+ webgl: Array<WebGLInstance>;
28
+ draw2D: Array<DrawContext2D>;
29
+ htmlCanvas: HTMLElement;
30
+ animateNextFrame: Function;
31
+ draw2DFigures: Record<string, any>;
32
+ defaultColor: Array<number>;
33
+ defaultDimColor: Array<number>;
34
+ defaultFont: OBJ_Font;
35
+ defaultLineWidth: number;
36
+ defaultLength: number;
37
+ timeKeeper: TimeKeeper;
38
+ recorder: Recorder;
39
+ scene: Scene;
40
+ equationScale: number;
41
+ /**
42
+ * @hideconstructor
43
+ */
44
+ constructor(webgl: Array<WebGLInstance> | WebGLInstance, draw2D: Array<DrawContext2D> | DrawContext2D, htmlCanvas: HTMLElement, scene: Scene, animateNextFrame: Function, defaultColor: Array<number>, defaultDimColor: Array<number>, defaultFont: OBJ_Font, defaultLineWidth: number, defaultLength: number, timeKeeper: TimeKeeper, recorder: Recorder, equationScale: number);
45
+ /**
46
+ * {@link FigureElementPrimitive} that draws a generic shape.
47
+ * @see {@link OBJ_Generic} for options and examples.
48
+ */
49
+ gl(...optionsIn: Array<OBJ_GenericGL>): any;
50
+ /**
51
+ * {@link FigureElementPrimitive} that draws a generic shape.
52
+ * @see {@link OBJ_Generic} for options and examples.
53
+ */
54
+ generic3(...optionsIn: Array<OBJ_Generic3>): any;
55
+ generic3DBase(defaultOptions: Record<string, any>, optionsIn: Record<string, any>, getPointsFn: (o: Record<string, any>) => ([Array<Point>, Array<Point>] | [Array<Point>])): any;
56
+ sphere(...optionsIn: Array<OBJ_Sphere>): any;
57
+ cube(...optionsIn: Array<OBJ_Cube>): any;
58
+ prism(...optionsIn: Array<OBJ_Prism>): any;
59
+ cylinder(...optionsIn: Array<OBJ_Cylinder>): any;
60
+ cone(...optionsIn: Array<OBJ_Cone>): any;
61
+ line3(...optionsIn: Array<OBJ_Line3>): any;
62
+ revolve(...optionsIn: Array<OBJ_Revolve>): any;
63
+ surface(...optionsIn: Array<OBJ_Surface>): any;
64
+ /**
65
+ * {@link FigureElementPrimitive} that draws a generic shape.
66
+ * @see {@link FigureElementPrimitiveMorph} and {@link OBJ_Morph} for
67
+ * examples and options.
68
+ */
69
+ morph(...optionsIn: Array<OBJ_Morph>): FigureElementPrimitiveMorph;
70
+ /**
71
+ * {@link FigureElementPrimitive} that draws a generic shape.
72
+ * @see {@link OBJ_Generic} for options and examples.
73
+ */
74
+ generic(...optionsIn: Array<OBJ_Generic>): any;
75
+ getPolylineTris(optionsIn: OBJ_PolyLineTris): any[];
76
+ /**
77
+ * {@link FigureElementPrimitive} that draws a polyline.
78
+ * @see {@link OBJ_Polyline} for options and examples.
79
+ */
80
+ polyline(...optionsIn: Array<OBJ_Polyline>): any;
81
+ getPolygonBorder(optionsIn: OBJ_Polygon_Defined): (string | Point[] | Point[][] | OBJ_Polygon_Defined)[];
82
+ genericBase(name: string, defaultOptions: Record<string, any>, optionsIn: Record<string, any>): any;
83
+ /**
84
+ * {@link FigureElementPrimitive} that draws a regular polygon.
85
+ * @see {@link OBJ_Polygon} for options and examples.
86
+ */
87
+ polygon(...options: Array<OBJ_Polygon>): any;
88
+ /**
89
+ * {@link FigureElementPrimitive} that draws a star.
90
+ * @see {@link OBJ_Star} for options and examples.
91
+ */
92
+ star(...options: Array<OBJ_Star>): any;
93
+ /**
94
+ * {@link FigureElementPrimitive} that draws a rectangle.
95
+ * @see {@link OBJ_Rectangle} for options and examples.
96
+ */
97
+ rectangle(...options: Array<OBJ_Rectangle>): any;
98
+ text(...options: Array<OBJ_Text>): FigureElementPrimitive | FigureElementPrimitiveGLText;
99
+ glText(...options: Array<OBJ_Text>): FigureElementPrimitiveGLText;
100
+ elementSetup(element: FigureElementPrimitive, options: Record<string, any>): FigureElementPrimitive;
101
+ text2d(...options: Array<OBJ_Text>): FigureElementPrimitive;
102
+ gesture(...options: Array<OBJ_Gesture>): FigureElementPrimitiveGesture;
103
+ /**
104
+ * {@link FigureElementPrimitive} that can control camera position.
105
+ * @see {@link OBJ_CameraControl} for options and examples.
106
+ */
107
+ cameraControl(...options: Array<OBJ_CameraControl>): any;
108
+ /**
109
+ * {@link FigureElementPrimitive} that draws an ellipse.
110
+ * @see {@link OBJ_Ellipse} for options and examples.
111
+ */
112
+ ellipse(...options: Array<OBJ_Ellipse>): any;
113
+ /**
114
+ * {@link FigureElementPrimitive} that draws an ellipse.
115
+ * @see {@link OBJ_Arc} for options and examples.
116
+ */
117
+ arc(...options: Array<OBJ_Arc>): any;
118
+ /**
119
+ * {@link FigureElementPrimitive} that draws a triangle.
120
+ * @see {@link OBJ_Triangle} for options and examples.
121
+ */
122
+ triangle(...options: Array<OBJ_Triangle>): any;
123
+ /**
124
+ * {@link FigureElementPrimitive} that draws a line.
125
+ * @see {@link OBJ_Arrow} for options and examples.
126
+ */
127
+ arrow(...options: Array<OBJ_Arrow>): any;
128
+ /**
129
+ * {@link FigureElementPrimitive} that draws a grid.
130
+ * @see {@link OBJ_Grid} for options and examples.
131
+ */
132
+ grid(...optionsIn: Array<OBJ_Grid>): any;
133
+ /**
134
+ * {@link FigureElementPrimitive} that draws a line.
135
+ * @see {@link OBJ_Line} for options and examples.
136
+ */
137
+ line(...options: Array<OBJ_Line>): any;
138
+ textGL(options: Record<string, any>): FigureElementPrimitive;
139
+ parseTextOptions(...optionsIn: Record<string, any>[]): any;
140
+ html(optionsIn: {
141
+ element: HTMLElement;
142
+ classes?: string;
143
+ position?: TypeParsablePoint;
144
+ xAlign?: 'left' | 'right' | 'center';
145
+ yAlign?: 'top' | 'bottom' | 'middle';
146
+ wrap?: boolean;
147
+ id?: string;
148
+ }): FigureElementPrimitive;
149
+ htmlElement(elementToAdd: HTMLElement | Array<HTMLElement>, id?: string, classes?: string, location?: Point, yAlign?: 'top' | 'bottom' | 'middle', xAlign?: 'left' | 'right' | 'center'): FigureElementPrimitive;
150
+ htmlImage(...optionsIn: Array<{
151
+ id?: string;
152
+ classes?: string;
153
+ position?: Point;
154
+ yAlign?: 'top' | 'bottom' | 'middle';
155
+ xAlign?: 'left' | 'right' | 'center';
156
+ src?: string;
157
+ color?: TypeColor;
158
+ pulse?: number;
159
+ }>): FigureElementPrimitive;
160
+ htmlText(...optionsIn: Array<{
161
+ textInput?: string;
162
+ id?: string;
163
+ classes?: string;
164
+ position?: Point;
165
+ yAlign?: 'top' | 'bottom' | 'middle';
166
+ xAlign?: 'left' | 'right' | 'center';
167
+ modifiers: Record<string, any>;
168
+ color?: TypeColor;
169
+ pulse?: number;
170
+ }>): FigureElementPrimitive;
171
+ }
172
+ export type TypeFigurePrimitives = FigurePrimitives;
173
+ export {};
@@ -0,0 +1,5 @@
1
+ import { FigureElementPrimitive } from '../Element';
2
+ import { Point, Transform, Rect } from '../../tools/g2';
3
+ import WebGLInstance from '../webgl/webgl';
4
+ import type { TypeColor } from '../../tools/types';
5
+ export default function Generic(webgl: WebGLInstance, color: TypeColor, transformOrLocation: Transform | Point, textureLocation?: string, textureVertexSpace?: Rect, textureCoords?: Rect, textureRepeat?: boolean, onLoad?: (() => void) | null, name?: string): FigureElementPrimitive;
@@ -0,0 +1,17 @@
1
+ import { FigureElementPrimitive } from '../Element';
2
+ import { Point, Transform } from '../../tools/g2';
3
+ import WebGLInstance from '../webgl/webgl';
4
+ type TypeTextInputOptions = {
5
+ text: string | null | undefined;
6
+ size: number | null | undefined;
7
+ family: string | null | undefined;
8
+ weight: number | null | undefined;
9
+ style: 'normal' | 'italic' | null | undefined;
10
+ xAlign: 'left' | 'center' | 'right' | null | undefined;
11
+ yAlign: 'top' | 'bottom' | 'middle' | 'baseline' | null | undefined;
12
+ color: Array<number> | null | undefined;
13
+ transform: Transform | null | undefined;
14
+ position: Point | null | undefined;
15
+ };
16
+ declare function Text(webgl: WebGLInstance, optionsIn: TypeTextInputOptions): FigureElementPrimitive;
17
+ export default Text;
@@ -0,0 +1,113 @@
1
+ import { NotificationManager } from '../tools/tools';
2
+ import { FunctionMap } from '../tools/FunctionMap';
3
+ import { FigureFont } from './DrawingObjects/TextObject/TextObject';
4
+ import { OBJ_Font, TypeFontWeight } from '../tools/types';
5
+ import { FigureElement } from './Element';
6
+ export type OBJ_LoadFontOptions = {
7
+ maxCount?: number;
8
+ timeout?: number;
9
+ callback?: string | (() => void);
10
+ };
11
+ /**
12
+ * Font manager can be used to query if fonts are available, and watch to see
13
+ * when they load or time out.
14
+ *
15
+ * Notifications - The notification manager property `notifications` will
16
+ * publish the following events:
17
+ * - `fontsLoaded`: published when all fonts have been loaded or timed out
18
+ * - `fontLoaded`: published after each font is loaded
19
+ * - `fontUnavailable`: published when loading a font has timed out
20
+ * @group Text
21
+ */
22
+ export default class FontManager {
23
+ fonts: Record<string, any>;
24
+ container: HTMLSpanElement;
25
+ static instance: FontManager;
26
+ canvas: HTMLCanvasElement;
27
+ ctx: CanvasRenderingContext2D;
28
+ loaded: number;
29
+ loading: number;
30
+ fnMap: FunctionMap;
31
+ timedOut: number;
32
+ notifications: NotificationManager;
33
+ checkTimer: ReturnType<typeof setTimeout> | null;
34
+ startTime: number;
35
+ timeout: number;
36
+ animateNextFrameCallbacks: Array<() => void>;
37
+ constructor(fnMap?: FunctionMap, notifications?: NotificationManager);
38
+ addAnimateFrameCallback(animateNextFrame: () => void): void;
39
+ animateNextFrame(): void;
40
+ measureTextID(fontID: string, backupFont?: string): number;
41
+ measureText(family: string, weight: string, style: string, glyphs: string): number;
42
+ showDebugAtlas(fontID: string, fontFamily: string, fontSizePX?: number): void;
43
+ measure(fontID: string, backupName: string, backupFamily: string): void;
44
+ /**
45
+ * Returns `true` if font is available.
46
+ * @param {OBJ_Font} fontDefinition
47
+ * @return {boolean} `true` if available
48
+ */
49
+ isAvailable(fontDefinition: OBJ_Font): boolean;
50
+ /**
51
+ * Check if a font's weights are all available.
52
+ *
53
+ * The weights must all belong to the same font family and style. The glyphs
54
+ * defined in `fontDefinition` will be used to check the weights.
55
+ *
56
+ * This method compares the width of the glyphs for all given weights. If all
57
+ * widths are different, then this method returns `true`.
58
+ *
59
+ * This means only weights that should exist should be input. For example
60
+ * if a font only supports 'normal' and 'bold', but weights 'lighter' and
61
+ * 'bold' are input, then this will return true as 'lighter' will likely
62
+ * fallback to 'normal'.
63
+ * @param {OBJ_Font} fontDefinition
64
+ * @param {Array<TypeFontWeight>} weights
65
+ */
66
+ areWeightsAvailable(fontDefinition: OBJ_Font, weights: Array<TypeFontWeight>): boolean;
67
+ /**
68
+ * Return arrays of weights that produce the same output.
69
+ */
70
+ getWeights(fontDefinition: OBJ_Font): string[][];
71
+ isMinNumWeights(fontID: string, num: number): boolean;
72
+ /**
73
+ * Return arrays of styles that produce the same output.
74
+ *
75
+ * This will usually return [['normal'], ['italic', 'oblique']] meaning that
76
+ * italic and oblique styles are the same, but different to normal. Even if
77
+ * only the normal font is available, often the browser will auto italicize
78
+ * the normal font to get an italic font.
79
+ *
80
+ * In contrast, this will show [['normal', 'italic', 'oblique']] (meaning all
81
+ * three are the same) if only the italic version of a font is available.
82
+ * This is because the browser simply uses the italic version as the normal
83
+ * version if it is requested.
84
+ */
85
+ getStyles(fontDefinition: OBJ_Font): string[][];
86
+ areStylesAvailable(fontDefinition: OBJ_Font, styles: Array<string>): boolean;
87
+ isAvailableID(fontID: string): boolean;
88
+ /**
89
+ * Watch for when a font becomes available, or a timeout is reached.
90
+ *
91
+ * Either a font definition, a {@link FigureFont} object or a
92
+ * {@link FigureElement} can be used to define which font(s) to watch.
93
+ *
94
+ * When a {@link FigureElement} is used, then all the unique fonts associated
95
+ * with that element will be watched, and any callback defined will be
96
+ * executed when each font is loaded or times out.
97
+ *
98
+ * If `weights` is specified, then the font will not be considered loaded
99
+ * until `weights` number of different weights are available.
100
+ *
101
+ * @param {OBJ_Font | FigureFont | FigureElement} fontOrElement
102
+ * @param {OBJ_LoadFontOptions | (() => void) | string} optionsOrCallback
103
+ * options or callback function to be used when font is loaded or times out.
104
+ */
105
+ watch(fontOrElement: OBJ_Font | FigureFont | FigureElement, optionsOrCallback: OBJ_LoadFontOptions | (() => void) | string): any[];
106
+ execCallbacks(fontID: string, available: boolean): void;
107
+ timeoutFonts(): void;
108
+ timedCheck(): void;
109
+ isLoadingFinished(): boolean;
110
+ fontLoaded(fontID: string): void;
111
+ fontTimedOut(fontID: string): void;
112
+ _isFontAvailable(fontID: string): boolean;
113
+ }
@@ -0,0 +1,39 @@
1
+ import { Point } from '../tools/g2';
2
+ import type Figure from './Figure';
3
+ declare class Gesture {
4
+ previousPoint: Point;
5
+ figure: Figure;
6
+ mouseDown: boolean;
7
+ enable: boolean;
8
+ start: (p: Point) => boolean;
9
+ end: (a: boolean, b: boolean) => void;
10
+ move: (prev: Point, curr: Point) => boolean;
11
+ free: (p: Point) => void;
12
+ toggleCursor: () => void;
13
+ wheel: (deltaX: number, deltaY: number, deltaMode: 0x00 | 0x01 | 0x02) => any;
14
+ binds: {
15
+ mouseDownHandler: (e: MouseEvent) => void;
16
+ mouseUpHandler: (e: MouseEvent) => void;
17
+ mouseMoveHandler: (e: MouseEvent) => void;
18
+ touchStartHandler: (e: TouchEvent) => void;
19
+ touchEndHandler: (e: TouchEvent) => void;
20
+ touchMoveHandler: (e: TouchEvent) => void;
21
+ wheelHandler: (e: WheelEvent) => void;
22
+ };
23
+ constructor(figure: Figure);
24
+ addEvent(event: string, method: any, flag: boolean): void;
25
+ addWindowEvent(event: string, method: any, flag: boolean): void;
26
+ removeEvent(event: string, method: any, flag: boolean): void;
27
+ startHandler(point: Point): boolean;
28
+ endHandler(): void;
29
+ moveHandler(event: MouseEvent | TouchEvent, point: Point): void;
30
+ wheelHandler(event: WheelEvent): void;
31
+ touchStartHandler(event: TouchEvent): void;
32
+ mouseDownHandler(event: MouseEvent): void;
33
+ touchMoveHandler(event: TouchEvent): void;
34
+ mouseMoveHandler(event: MouseEvent): void;
35
+ mouseUpHandler(): void;
36
+ touchEndHandler(event: TouchEvent): void;
37
+ destroy(): void;
38
+ }
39
+ export default Gesture;
@@ -0,0 +1,291 @@
1
+ import { Point } from '../../tools/g2';
2
+ import { ObjectTracker, download, NotificationManager } from '../../tools/tools';
3
+ import TimeKeeper from '../TimeKeeper';
4
+ import type Figure from '../Figure';
5
+ import type { OBJ_ScenarioVelocity } from '../Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep';
6
+ type TypeStateDiff = [number, string, Record<string, any>, number];
7
+ type TypeEventPayload = number | string | Record<string, any>;
8
+ type TypeEvent = [
9
+ number,
10
+ Array<TypeEventPayload>,
11
+ number
12
+ ];
13
+ type TypeEvents = Array<TypeEvent>;
14
+ type TypeStateDiffs = Array<TypeStateDiff>;
15
+ export type TypePauseSettings = 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete';
16
+ export type TypePlaySettings = {
17
+ how: 'dissolve' | 'animate' | 'instant';
18
+ duration?: number | {
19
+ dissovlveOut?: number;
20
+ dissovlveIn?: number;
21
+ delay?: number;
22
+ };
23
+ velocity?: OBJ_ScenarioVelocity;
24
+ maxDuration?: number;
25
+ zeroDurationThreshold?: boolean;
26
+ allDurationsSame?: boolean;
27
+ } | 'dissolve' | 'animate' | 'instant';
28
+ declare function getIndexOfEarliestTime(recordedData: TypeEvents | TypeStateDiffs, index: number): number;
29
+ declare function getIndexOfLatestTime(recordedData: TypeEvents | TypeStateDiffs, index: number): number;
30
+ declare function getNextIndexForTime(recordedData: TypeEvents | TypeStateDiffs, time: number, startSearch?: number, endSearch?: number, earliestTime?: boolean): number;
31
+ declare function getPrevIndexForTime(recordedData: TypeEvents | TypeStateDiffs, time: number, startSearch?: number, endSearch?: number, earliestTime?: boolean): number;
32
+ /**
33
+ * The Recorder class provides functionality to record and playback video like
34
+ * experiences. It can:
35
+ *
36
+ * - record and playback events, such as function calls, mouse movements, mouse
37
+ * clicks and slide navigation - these can either be recorded by a user, or
38
+ * programmed for specific times
39
+ * - overlay an audio track on playback
40
+ * - record entire figure state at regular intervals (like 1 second) as seek
41
+ * frames for the video
42
+ * - allow a user to pause video at any time and interact with the figure in its
43
+ * current state - on resuming playback, the figure will revert to its paused
44
+ * state
45
+ *
46
+ * For performance during recording, a separate javascript worker is used to
47
+ * parallelize state encoding. Therefore, in addition to the FigureOne library,
48
+ * a FigureOne worker file will need to be loaded. See the tutorials for
49
+ * examples on how this is done.
50
+ *
51
+ * For tutorials and examples of how to use Recorder, see
52
+ *
53
+ * - <a href="https://github.com/airladon/FigureOne/docs/tutorials/Tutorial%2015%20-%20-Recorder%20Introduction/index.html">Tutorial 15 - Recorder Introduction</a>
54
+ * - [Tutorial 16 - Recording Manual Events](https://github.com/airladon/FigureOne/docs/tutorials/Tutorial%2016%20-%20-Recording%20Manual%20Events/index.html)
55
+ * - [Tutorial 17 - Recording Slides](https://github.com/airladon/FigureOne/docs/tutorials/Tutorial%2017%20-%20-Recording%20Slides/index.html)
56
+ * - [Tutorial 18 - Recording Planned Events](https://github.com/airladon/FigureOne/docs/tutorials/Tutorial%2018%20-%20-Recording%20Planned%20Events/index.html)
57
+ * - [Trig 1 - Trig Functions](https://github.com/airladon/FigureOne/docs/examples/Trig%201%20-%20Trig%20Functions/index.html)
58
+ * - [Trig 2 - Names](https://github.com/airladon/FigureOne/docs/examples/Trig%202%20-%20Names/index.html)
59
+ * - [Trig 3 - Relationships](https://github.com/airladon/FigureOne/docs/examples/Trig%203%20-%20Relationships/index.html)
60
+ *
61
+ * Notifications - The notification manager property `notifications` will
62
+ * publish the following events:
63
+ * - `timeUpdate`: updated at period defined in property `timeUpdates`
64
+ * - `durationUpdated`: updated whenever audio or video are loaded, or when
65
+ * recording goes beyond the current duration
66
+ * - `audioLoaded`
67
+ * - `videoLoaded`
68
+ * - `recordingStarted`
69
+ * - `recordingStopped`
70
+ * - `preparingToPlay`
71
+ * - `playbackStarted`
72
+ * - `preparingToPause`
73
+ * - `playbackStopped`
74
+ * - `seek`
75
+ * - `recordingStatesComplete` - recording completed and recorded states ready
76
+ *
77
+ * @class
78
+ *
79
+ * @property {'recording' | 'playing' | 'idle' | 'preparingToPlay' | 'preparingToPause'} state
80
+ * @property {boolean} isAudioPlaying
81
+ * @property {number} duration in seconds
82
+ * @property {number} stateTimeStep in seconds - change this to change the
83
+ * duration between recorded seek frames
84
+ * @property {number} timeUpdates in seconds - how often to publish the
85
+ * 'timeUpdate' notification
86
+ * @property {NotificationManager} notifications - use to subscribe to
87
+ * notifications
88
+ * @group Interactive Video
89
+ */
90
+ declare class Recorder {
91
+ states: ObjectTracker;
92
+ events: {
93
+ [eventName: string]: {
94
+ setOnSeek: boolean;
95
+ playbackAction: (...args: any[]) => void;
96
+ list: TypeEvents;
97
+ };
98
+ };
99
+ statesCache: ObjectTracker;
100
+ eventsCache: {
101
+ [eventName: string]: {
102
+ list: TypeEvents;
103
+ };
104
+ };
105
+ notifications: NotificationManager;
106
+ eventsToPlay: Array<string>;
107
+ state: 'recording' | 'playing' | 'idle' | 'preparingToPlay' | 'preparingToPause';
108
+ isAudioPlaying: boolean;
109
+ videoToNowDelta: number;
110
+ currentTime: number;
111
+ duration: number;
112
+ precision: number;
113
+ stateIndex: number;
114
+ eventIndex: {
115
+ [eventName: string]: number;
116
+ };
117
+ recordingStates: boolean;
118
+ pauseState: Record<string, any> | null;
119
+ startRecordingTime: number;
120
+ queueSeekId: null | number;
121
+ queueSeekTime: number;
122
+ stateTimeStep: number;
123
+ figure: Figure;
124
+ timeoutID: number | null;
125
+ timeUpdatesTimeoutID: number | null;
126
+ lastRecordTime: number | null;
127
+ lastRecordTimeCount: number;
128
+ audio: HTMLAudioElement | null;
129
+ reference: string;
130
+ referenceIndex: number;
131
+ lastSeekTime: number | null;
132
+ timeUpdates: number;
133
+ settings: {
134
+ pause: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete';
135
+ play: TypePlaySettings;
136
+ };
137
+ worker: any;
138
+ timeKeeper: TimeKeeper;
139
+ audioStartedCallback: (() => void) | null;
140
+ constructor(timeKeeper: TimeKeeper);
141
+ initialize(): void;
142
+ timeStamp(): number;
143
+ now(): number;
144
+ /**
145
+ * Current time in seconds
146
+ * @return {number} seconds
147
+ */
148
+ getCurrentTime(): number;
149
+ getDeltaTime(delta?: number): number;
150
+ setCurrentTime(time: number): void;
151
+ setVideoToNowDeltaTime(videoSeekTime?: number): void;
152
+ calcDuration(cache?: boolean): number;
153
+ reset(): void;
154
+ loadAudioTrack(audio: HTMLAudioElement): void;
155
+ loadEvents(encodedEventsList: Record<string, any> | Array<TypeEvents>, isMinified?: boolean): void;
156
+ loadStates(statesIn: Record<string, any>, isMinified?: boolean, isObjectForm?: boolean): void;
157
+ loadSavedData(combined: Record<string, any>): void;
158
+ encodeEvents(minifyEvents?: boolean): any;
159
+ decodeEvents(lists: Record<string, any>, isMinified?: boolean): any;
160
+ encodeStates(minifyStates?: boolean, asObject?: boolean, precision?: number | null): any;
161
+ decodeStates(statesIn: Record<string, any>, isMinified?: boolean, asObject?: boolean): ObjectTracker;
162
+ clearListOrDiffs(listOrDiffs: TypeEvents | TypeStateDiffs, startTime: number, stopTime: number): any[];
163
+ clear(startTime: number, stopTime: number): void;
164
+ /**
165
+ * Start Recording
166
+ * @param {number} fromTime when to start recording from in seconds (0)
167
+ * @param {Array<string>} whilePlaying events to play while recording ([])
168
+ * @param {boolean} includeStates record states as well as events (`true`)
169
+ */
170
+ startRecording(fromTime?: number, whilePlaying?: Array<string>, includeStates?: boolean): void;
171
+ /**
172
+ * Initiate states recording to generate seek frames. Any existing states
173
+ * will be removed before starting, so the initial state at time 0 must be in
174
+ * place (usually this means only start states recording when the figure is
175
+ * first created and not after any changes to the initial state have been
176
+ * made)
177
+ *
178
+ * @param {number} frameTime time between draw frames in seconds. It can be
179
+ * sometimes be useful to have draw frames happen more frequently than the
180
+ * seek frames [0.1s]
181
+ */
182
+ startStatesRecording(frameTime?: number): void;
183
+ autoFrame(frameTime?: number): void;
184
+ startWorker(): void;
185
+ parseMessage(event: MessageEvent): void;
186
+ addCurrentStateAsReference(): void;
187
+ getCacheStartTime(): number | null;
188
+ getCacheEndTime(): number;
189
+ getMergedCacheArray(eventListOrStatesDiff: TypeEvents | TypeStateDiffs, cacheArray: TypeEvents | TypeStateDiffs): any[];
190
+ mergeEventsCache(): void;
191
+ mergeStatesCache(): void;
192
+ stopTimeouts(): void;
193
+ /**
194
+ * Stop Recording
195
+ */
196
+ stopRecording(): void;
197
+ /**
198
+ * Cancel the states recording.
199
+ *
200
+ * Use this only for cancelling recording as states recording will be
201
+ * automatically stopped if the event and audio duration has been reached.
202
+ */
203
+ stopStatesRecording(): void;
204
+ addEventType(eventName: string, playbackAction: (payload: any) => void, setOnSeek?: boolean): void;
205
+ recordState(state: Record<string, any>, time?: number): void;
206
+ recordCurrentState(time?: number): void;
207
+ recordCurrentStateAsReference(refName: string, basedOn?: string): void;
208
+ recordEvent(eventName: string, payload: Array<string | number | Record<string, any>>, time?: number): void;
209
+ queueRecordState(time?: number): void;
210
+ /**
211
+ * Save events and states to video-track json file
212
+ */
213
+ save(): void;
214
+ show(): void;
215
+ /**
216
+ * Code generator that takes mouse events, and generates code to load them
217
+ * as auto mouse events
218
+ * @param {string} figureName name of figure used in code ('figure')
219
+ * @param {number} precision precision to save cursor positions to (2)
220
+ */
221
+ genAutoMouseEvents(figureName?: string, precision?: number, encodeMove?: boolean): string;
222
+ showEvent(eventName: string, precision?: number, space?: number): string;
223
+ encodeCursorEvent(eventName: string, timePrecision?: number, valuePrecision?: number, minTimeStep?: number): string;
224
+ decodeCursorEvent(eventName: string, eventData: Array<number>, timePrecision?: number, valuePrecision?: number): any[];
225
+ decodeEvent(eventName: string, eventData: Array<number>): any[];
226
+ loadEventData(eventName: string, data: any, decode?: 'cursor' | 'moved' | boolean, timePrecision?: number, valuePrecision?: number): void;
227
+ seekToPercent(percentTime: number): void;
228
+ convertTime(timeIn: string | number): number;
229
+ queueSeek(timeIn: number): void;
230
+ /**
231
+ * Seek to time
232
+ * @param {number} timeIn in seconds
233
+ */
234
+ seek(timeIn: number): void;
235
+ setToTime(timeIn: number, force?: boolean): void;
236
+ setCursor(time: number): void;
237
+ getCursorState(atTime: number): {
238
+ show: boolean;
239
+ up: boolean;
240
+ position: Point;
241
+ } | null;
242
+ getEvents(eventsIn?: Array<string> | null): Array<string>;
243
+ /**
244
+ * Start Playback
245
+ *
246
+ * @param {number} fromTimeIn ib seconds (current time)
247
+ * @param {boolean} allowPauseResume `true` to allow resuming from pause if a
248
+ * pause state exists
249
+ * @param {Array<string>} events list of events to play (all events)
250
+ */
251
+ startPlayback(fromTimeIn?: number, allowPauseResume?: boolean, events?: Array<string> | null): void;
252
+ /**
253
+ * Toggle playback (if not recording)
254
+ */
255
+ togglePlayback(): void;
256
+ getPlaySettings(): Record<string, any>;
257
+ /**
258
+ * Resume playback if paused.
259
+ */
260
+ resumePlayback(): void;
261
+ audioStarted(): void;
262
+ audioEnded(): void;
263
+ startAudioPlayback(fromTime: number, callback?: (() => void) | null): boolean;
264
+ startTimeUpdates(): void;
265
+ startEventsPlayback(fromTime: number): void;
266
+ getNextEvent(): string;
267
+ playbackEvent(eventName: string): void;
268
+ areEventsPlaying(): boolean;
269
+ finishPlaying(): boolean;
270
+ stop(): void;
271
+ /**
272
+ * Pause playback
273
+ * @param {'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete'} how
274
+ * how any animations currently playing should be stopped
275
+ */
276
+ pausePlayback(how?: 'freeze' | 'cancel' | 'complete' | 'animateToComplete' | 'dissolveToComplete'): void;
277
+ setEvent(eventName: string, index: number): void;
278
+ /**
279
+ * Fetch and load a video track.
280
+ *
281
+ * When loading is finished, the notification 'videoLoaded' will be published
282
+ *
283
+ * @param {string} path path to load video track from
284
+ * @param {function(): void} callback function to execute when loaded
285
+ */
286
+ loadVideoTrack(path: string, callback?: () => void): void;
287
+ setState(index: number): void;
288
+ getState(index: number): any;
289
+ getStateForTime(timeIn: number): any;
290
+ }
291
+ export { Recorder, getIndexOfEarliestTime, download, getIndexOfLatestTime, getNextIndexForTime, getPrevIndexForTime, };
@@ -0,0 +1,3 @@
1
+ import type Figure from '../Figure';
2
+ declare function parseState(state: any, figure: Figure): any;
3
+ export default parseState;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ declare function getState(obj: Record<string, any>, stateProperties: Array<string>, optionsIn: {
2
+ precision?: number;
3
+ ignoreShown?: boolean;
4
+ min?: boolean;
5
+ }): Record<string, any>;
6
+ declare function setState(obj: Record<string, any>, stateIn: Record<string, any>): void;
7
+ export { setState, getState };