figureone 1.0.7 → 1.0.8
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 +1311 -69
- package/package.json +1 -1
- package/types/index.d.ts +2 -0
- package/types/js/figure/Equation/latexToFigureOne.d.ts +50 -0
- package/types/js/figure/Figure.d.ts +5 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +5 -1
- package/types/js/figure/Gesture.d.ts +1 -0
- package/types/js/figure/webgl/target.d.ts +1 -0
- package/types/js/figure/webgl/webgl.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "figureone",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Draw, animate and interact with shapes, text, plots and equations in Javascript. Create interactive slide shows, and interactive videos.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
package/types/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ import CollectionsPolyline from './js/figure/FigureCollections/PolyLine';
|
|
|
27
27
|
import EquationLabel from './js/figure/FigureCollections/EquationLabel';
|
|
28
28
|
import { Equation } from './js/figure/Equation/Equation';
|
|
29
29
|
import EquationForm from './js/figure/Equation/EquationForm';
|
|
30
|
+
import { latexToFigureOne } from './js/figure/Equation/latexToFigureOne';
|
|
30
31
|
import SlideNavigator from './js/figure/SlideNavigator';
|
|
31
32
|
import type { TypeRotationDirection, TypeParsablePoint } from './js/tools/g2';
|
|
32
33
|
import type { COL_Line, OBJ_LineLabel, TypeLabelledLine } from './js/figure/FigureCollections/Line';
|
|
@@ -72,6 +73,7 @@ declare const Fig: {
|
|
|
72
73
|
EquationForm: typeof EquationForm;
|
|
73
74
|
Equation: typeof Equation;
|
|
74
75
|
HTMLEquation: typeof HTMLEquation;
|
|
76
|
+
latexToFigureOne: typeof latexToFigureOne;
|
|
75
77
|
Animation: typeof anim;
|
|
76
78
|
Scene: typeof Scene;
|
|
77
79
|
Point: typeof g2.Point;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LaTeX to FigureOne equation form converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts a LaTeX math expression string into FigureOne `elements` and `form`
|
|
5
|
+
* objects that can be passed directly to `figure.add({ make: 'equation', ... })`.
|
|
6
|
+
*
|
|
7
|
+
* Supported LaTeX constructs:
|
|
8
|
+
* - Fractions: \frac{a}{b}
|
|
9
|
+
* - Superscripts / subscripts: x^2, x_{ij}, x_i^2
|
|
10
|
+
* - Square roots: \sqrt{x}, \sqrt[n]{x}
|
|
11
|
+
* - Integrals: \int, \int_{a}^{b} f(x)\,dx
|
|
12
|
+
* - Sums / products: \sum_{i=1}^{n}, \prod_{k=0}^{n}
|
|
13
|
+
* - Brackets: \left( ... \right), \left[ ... \right], \left\{ ... \right\}
|
|
14
|
+
* - Overline / underline: \overline{x}, \underline{x}
|
|
15
|
+
* - Accents: \hat{x}, \tilde{x}, \dot{x}, \vec{x}
|
|
16
|
+
* - Greek letters: \alpha, \Beta, etc.
|
|
17
|
+
* - Operators: \sin, \cos, \lim, \log, etc.
|
|
18
|
+
* - Symbols: \cdot, \times, \pm, \infty, \to, \partial, etc.
|
|
19
|
+
* - Spacing: \, \; \quad \qquad
|
|
20
|
+
* - Text mode: \text{...}, \mathrm{...}
|
|
21
|
+
*
|
|
22
|
+
* @module latexToFigureOne
|
|
23
|
+
*/
|
|
24
|
+
/** Result of converting a LaTeX expression to FigureOne form. */
|
|
25
|
+
export interface LatexResult {
|
|
26
|
+
/**
|
|
27
|
+
* Element definitions to pass as `elements` in the equation options.
|
|
28
|
+
* Contains only symbols and elements that need explicit configuration;
|
|
29
|
+
* simple text elements are auto-created by FigureOne.
|
|
30
|
+
*/
|
|
31
|
+
elements: Record<string, any>;
|
|
32
|
+
/**
|
|
33
|
+
* The form content (a {@link TypeEquationPhrase}) to use in a form
|
|
34
|
+
* definition, e.g. `forms: { 0: result.form }`.
|
|
35
|
+
*/
|
|
36
|
+
form: any;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Convert a LaTeX math expression into a FigureOne equation form.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const { elements, form } = Fig.latexToFigureOne('\\frac{a}{b} = c');
|
|
43
|
+
* figure.add({
|
|
44
|
+
* make: 'equation',
|
|
45
|
+
* elements,
|
|
46
|
+
* forms: { base: form },
|
|
47
|
+
* });
|
|
48
|
+
*/
|
|
49
|
+
export declare function latexToFigureOne(latex: string): LatexResult;
|
|
50
|
+
export default latexToFigureOne;
|
|
@@ -271,6 +271,11 @@ declare class Figure {
|
|
|
271
271
|
preparingToSetState: boolean;
|
|
272
272
|
};
|
|
273
273
|
ext: any;
|
|
274
|
+
_boundResize: EventListener;
|
|
275
|
+
_boundFocusGained: EventListener;
|
|
276
|
+
_boundFocusLost: EventListener;
|
|
277
|
+
_boundContextLost: EventListener;
|
|
278
|
+
_boundContextRestored: EventListener;
|
|
274
279
|
constructor(options?: OBJ_Figure);
|
|
275
280
|
fontsLoaded(): void;
|
|
276
281
|
/**
|
|
@@ -369,7 +369,10 @@ export default class FigureElementPrimitiveGesture extends FigureElementPrimitiv
|
|
|
369
369
|
mousePixelPosition: Point;
|
|
370
370
|
onlyWhenTouched: boolean;
|
|
371
371
|
relativeScene: null | Scene;
|
|
372
|
-
notificationIDs: Array<
|
|
372
|
+
notificationIDs: Array<{
|
|
373
|
+
event: string;
|
|
374
|
+
id: number;
|
|
375
|
+
}>;
|
|
373
376
|
changeScene: Scene;
|
|
374
377
|
constructor(drawingObject: DrawingObject, transform: Transform, color: TypeColor, parent: FigureElement | null, name: string, timeKeeper: TimeKeeper);
|
|
375
378
|
_getStateProperties(options: {
|
|
@@ -499,6 +502,7 @@ export default class FigureElementPrimitiveGesture extends FigureElementPrimitiv
|
|
|
499
502
|
setPanOffset(offset: Point): void;
|
|
500
503
|
setFigure(figure: OBJ_FigureForElement): void;
|
|
501
504
|
cleanupIDs(): void;
|
|
505
|
+
cleanup(): void;
|
|
502
506
|
}
|
|
503
507
|
/**
|
|
504
508
|
A zoom pan can be defined as:
|
|
@@ -24,6 +24,7 @@ declare class Gesture {
|
|
|
24
24
|
addEvent(event: string, method: any, flag: boolean): void;
|
|
25
25
|
addWindowEvent(event: string, method: any, flag: boolean): void;
|
|
26
26
|
removeEvent(event: string, method: any, flag: boolean): void;
|
|
27
|
+
removeWindowEvent(event: string, method: any, flag: boolean): void;
|
|
27
28
|
startHandler(point: Point): boolean;
|
|
28
29
|
endHandler(): void;
|
|
29
30
|
moveHandler(event: MouseEvent | TouchEvent, point: Point): void;
|
|
@@ -41,6 +41,7 @@ declare class WebGLInstance {
|
|
|
41
41
|
recreateAtlases(): void;
|
|
42
42
|
deleteTexture(id: string): void;
|
|
43
43
|
contextLost(): void;
|
|
44
|
+
cleanup(): void;
|
|
44
45
|
setTextureData(id: string, image: Record<string, any> | TypeColor, // image data
|
|
45
46
|
repeat?: boolean): boolean;
|
|
46
47
|
onLoad(id: string): void;
|