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,3367 @@
|
|
|
1
|
+
import { Point } from '../../tools/g2';
|
|
2
|
+
import type { TypeParsablePoint } from '../../tools/g2';
|
|
3
|
+
import { FigureElementPrimitive, FigureElementCollection } from '../Element';
|
|
4
|
+
import { Element, Elements } from './Elements/Element';
|
|
5
|
+
import Fraction from './Elements/Fraction';
|
|
6
|
+
import EquationForm from './EquationForm';
|
|
7
|
+
import Matrix from './Elements/Matrix';
|
|
8
|
+
import Lines from './Elements/Lines';
|
|
9
|
+
import Scale from './Elements/Scale';
|
|
10
|
+
import Container from './Elements/Container';
|
|
11
|
+
import BaseAnnotationFunction from './Elements/BaseAnnotationFunction';
|
|
12
|
+
import Offset from './Elements/Offset';
|
|
13
|
+
import Color from './Elements/Color';
|
|
14
|
+
import type { TypeColor } from '../../tools/types';
|
|
15
|
+
export declare function getFigureElement(elementsObject: {
|
|
16
|
+
[key: string]: FigureElementPrimitive | FigureElementCollection;
|
|
17
|
+
} | FigureElementCollection, name: string | FigureElementPrimitive | FigureElementCollection): FigureElementPrimitive | FigureElementCollection | null;
|
|
18
|
+
/**
|
|
19
|
+
* An equation phrase is used to define an equation form and can be any of the
|
|
20
|
+
* below:
|
|
21
|
+
*
|
|
22
|
+
* - `string` (which represents the unique identifier of an equation element)
|
|
23
|
+
* - `{ frac: `{@link EQN_Fraction} `}`
|
|
24
|
+
* - `{ strike: `{@link EQN_Strike} `}`
|
|
25
|
+
* - `{ box: `{@link EQN_Box} `}`
|
|
26
|
+
* - `{ tBox: `{@link EQN_TouchBox} `}`
|
|
27
|
+
* - `{ root: `{@link EQN_Root} `}`
|
|
28
|
+
* - `{ brac: `{@link EQN_Bracket} `}`
|
|
29
|
+
* - `{ sub: `{@link EQN_Subscript} `}`
|
|
30
|
+
* - `{ sup: `{@link EQN_Superscript} `}`
|
|
31
|
+
* - `{ supSub: `{@link EQN_SuperscriptSubscript} `}`
|
|
32
|
+
* - `{ topBar: `{@link EQN_Bar} `}`
|
|
33
|
+
* - `{ bottomBar: `{@link EQN_Bar} `}`
|
|
34
|
+
* - `{ annotate: `{@link EQN_Annotate} `}`
|
|
35
|
+
* - `{ topComment: `{@link EQN_Comment} `}`
|
|
36
|
+
* - `{ bottomComment: `{@link EQN_Comment} `}`
|
|
37
|
+
* - `{ pad: `{@link EQN_Pad} `}`
|
|
38
|
+
* - `{ bar: `{@link EQN_Bar} `}`
|
|
39
|
+
* - `{ scale: `{@link EQN_Scale} `}`
|
|
40
|
+
* - `{ container: `{@link EQN_Container} `}`
|
|
41
|
+
* - `{ offset: `{@link EQN_Offset} `}`
|
|
42
|
+
* - `{ matrix: `{@link EQN_Matrix} `}
|
|
43
|
+
* - `{ lines: `{@link EQN_Lines} `}`
|
|
44
|
+
* - `{ int: `{@link EQN_Integral} `}`
|
|
45
|
+
* - `{ sumOf: `{@link EQN_SumOf} `}`
|
|
46
|
+
* - `{ prodOf: `{@link EQN_ProdOf} `}`
|
|
47
|
+
* - `{ topStrike: `{@link EQN_StrikeComment} `}`
|
|
48
|
+
* - `{ bottomStrike: `{@link EQN_StrikeComment} `}`
|
|
49
|
+
* - `Array<TypeEquationPhrase>`
|
|
50
|
+
*
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* figure.add({
|
|
54
|
+
* name: 'eqn',
|
|
55
|
+
* make: 'equation',
|
|
56
|
+
* elements: { equals: ' = ' },
|
|
57
|
+
* forms: {
|
|
58
|
+
* form1: 'a',
|
|
59
|
+
* form2: ['a', 'equals', 'b'],
|
|
60
|
+
* form3: [{
|
|
61
|
+
* frac: {
|
|
62
|
+
* numerator: 'a',
|
|
63
|
+
* symbol: 'vinculum',
|
|
64
|
+
* denominator: 'c',
|
|
65
|
+
* },
|
|
66
|
+
* }, 'equals', 'b'],
|
|
67
|
+
* form4: { frac: ['a', 'vinculum', 'c'] },
|
|
68
|
+
* },
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* figure.getElement('eqn').animations.new()
|
|
72
|
+
* .goToForm({ target: 'form2', animate: 'move', delay: 1 })
|
|
73
|
+
* .goToForm({ target: 'form3', animate: 'move', delay: 1 })
|
|
74
|
+
* .goToForm({ target: 'form4', animate: 'move', delay: 1 })
|
|
75
|
+
* .start();
|
|
76
|
+
* @group Equations
|
|
77
|
+
*/
|
|
78
|
+
export type TypeEquationPhrase = string | number | {
|
|
79
|
+
frac: EQN_Fraction;
|
|
80
|
+
} | {
|
|
81
|
+
strike: EQN_Strike;
|
|
82
|
+
} | {
|
|
83
|
+
box: EQN_Box;
|
|
84
|
+
} | {
|
|
85
|
+
tBox: EQN_TouchBox;
|
|
86
|
+
} | {
|
|
87
|
+
root: EQN_Root;
|
|
88
|
+
} | {
|
|
89
|
+
brac: EQN_Bracket;
|
|
90
|
+
} | {
|
|
91
|
+
sub: EQN_Subscript;
|
|
92
|
+
} | {
|
|
93
|
+
sup: EQN_Superscript;
|
|
94
|
+
} | {
|
|
95
|
+
supSub: EQN_SuperscriptSubscript;
|
|
96
|
+
} | {
|
|
97
|
+
topBar: EQN_Bar;
|
|
98
|
+
} | {
|
|
99
|
+
bottomBar: EQN_Bar;
|
|
100
|
+
} | {
|
|
101
|
+
annotate: EQN_Annotate;
|
|
102
|
+
} | {
|
|
103
|
+
topComment: EQN_Comment;
|
|
104
|
+
} | {
|
|
105
|
+
bottomComment: EQN_Comment;
|
|
106
|
+
} | {
|
|
107
|
+
pad: EQN_Pad;
|
|
108
|
+
} | {
|
|
109
|
+
bar: EQN_Bar;
|
|
110
|
+
} | {
|
|
111
|
+
scale: EQN_Scale;
|
|
112
|
+
} | {
|
|
113
|
+
container: EQN_Container;
|
|
114
|
+
} | {
|
|
115
|
+
offset: EQN_Offset;
|
|
116
|
+
} | {
|
|
117
|
+
matrix: EQN_Matrix;
|
|
118
|
+
} | {
|
|
119
|
+
matrix: EQN_Lines;
|
|
120
|
+
} | {
|
|
121
|
+
int: EQN_Integral;
|
|
122
|
+
} | {
|
|
123
|
+
sumOf: EQN_SumOf;
|
|
124
|
+
} | {
|
|
125
|
+
prodOf: EQN_ProdOf;
|
|
126
|
+
} | {
|
|
127
|
+
topStrike: EQN_StrikeComment;
|
|
128
|
+
} | {
|
|
129
|
+
bottomStrike: EQN_StrikeComment;
|
|
130
|
+
} | Array<TypeEquationPhrase> | FigureElementPrimitive | FigureElementCollection | Elements | Element | BaseAnnotationFunction;
|
|
131
|
+
/**
|
|
132
|
+
* Equation container options
|
|
133
|
+
*
|
|
134
|
+
* 
|
|
135
|
+
*
|
|
136
|
+
* A container is useful to fix spacing around content as it changes between
|
|
137
|
+
* equation forms.
|
|
138
|
+
*
|
|
139
|
+
* Options can be an object, or an array in the property order below
|
|
140
|
+
*
|
|
141
|
+
* @property {TypeEquationPhrase} content
|
|
142
|
+
* @property {number} [width] (`null`)
|
|
143
|
+
* @property {boolean} [inSize] (`true)
|
|
144
|
+
* @property {number} [descent] (`null`)
|
|
145
|
+
* @property {number} [ascent] (`null`)
|
|
146
|
+
* @property {'left' | 'center' | 'right' | number} [xAlign] (`'center'`)
|
|
147
|
+
* @property {'bottom' | 'middle' | 'top' | 'baseline' | number} [yAlign] (`'baseline'`)
|
|
148
|
+
* @property {'width' | 'height' | 'contain'} [fit] - fit width,
|
|
149
|
+
* ascent and descent to either match width, height or fully contain the content (`null`)
|
|
150
|
+
* @property {number} [scale] - (`1`)
|
|
151
|
+
* @property {boolean} [fullContentBounds] - (`false`)
|
|
152
|
+
* @property {boolean} [showContent] - if `false`, a container will be created
|
|
153
|
+
* around the content, but the content will not be shown (`true`)
|
|
154
|
+
*
|
|
155
|
+
* @see To test examples, append them to the
|
|
156
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* // Example showing the difference between with and without container
|
|
160
|
+
* figure.add({
|
|
161
|
+
* name: 'eqn',
|
|
162
|
+
* make: 'equation',
|
|
163
|
+
* forms: {
|
|
164
|
+
* // Container object definition
|
|
165
|
+
* 1: [
|
|
166
|
+
* 'length',
|
|
167
|
+
* {
|
|
168
|
+
* container: {
|
|
169
|
+
* content: 'width',
|
|
170
|
+
* width: 0.5,
|
|
171
|
+
* },
|
|
172
|
+
* },
|
|
173
|
+
* 'height',
|
|
174
|
+
* ],
|
|
175
|
+
* // Container array definition
|
|
176
|
+
* 2: ['length', { container: ['w', 0.5] }, 'height'],
|
|
177
|
+
* // No container
|
|
178
|
+
* 3: ['length', ' ', 'w', ' ', 'height']
|
|
179
|
+
* },
|
|
180
|
+
* formSeries: ['1', '2', '3'],
|
|
181
|
+
* });
|
|
182
|
+
* const eqn = figure.elements._eqn;
|
|
183
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
184
|
+
* eqn.setTouchable();
|
|
185
|
+
* eqn.showForm('1');
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* // Create equation object then add to figure
|
|
189
|
+
* const eqn = figure.collections.equation({
|
|
190
|
+
* forms: {
|
|
191
|
+
* 1: [
|
|
192
|
+
* 'length',
|
|
193
|
+
* { container: { content: 'width', width: 0.5 } },
|
|
194
|
+
* 'height',
|
|
195
|
+
* ],
|
|
196
|
+
* 2: ['length', { container: ['w', 0.5] }, 'height'],
|
|
197
|
+
* 3: ['length', ' ', 'w', ' ', 'height']
|
|
198
|
+
* },
|
|
199
|
+
* formSeries: ['1', '2', '3'],
|
|
200
|
+
* });
|
|
201
|
+
* figure.add('eqn', eqn);
|
|
202
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
203
|
+
* eqn.setTouchable();
|
|
204
|
+
* eqn.showForm('1');
|
|
205
|
+
* @interface
|
|
206
|
+
* @group Equation Layout
|
|
207
|
+
*/
|
|
208
|
+
export type EQN_Container = {
|
|
209
|
+
content: TypeEquationPhrase;
|
|
210
|
+
width?: number;
|
|
211
|
+
inSize?: boolean;
|
|
212
|
+
descent?: number;
|
|
213
|
+
ascent?: number;
|
|
214
|
+
xAlign?: 'left' | 'center' | 'right' | number;
|
|
215
|
+
yAlign?: 'bottom' | 'middle' | 'top' | 'baseline' | number;
|
|
216
|
+
fit?: 'width' | 'height' | 'contain';
|
|
217
|
+
scale?: number;
|
|
218
|
+
fullContentBounds?: boolean;
|
|
219
|
+
showContent?: boolean;
|
|
220
|
+
} | [
|
|
221
|
+
TypeEquationPhrase,
|
|
222
|
+
(number | null | undefined),
|
|
223
|
+
(boolean | null | undefined),
|
|
224
|
+
(number | null | undefined),
|
|
225
|
+
(number | null | undefined),
|
|
226
|
+
('left' | 'center' | 'right' | number | null | undefined),
|
|
227
|
+
('bottom' | 'middle' | 'top' | 'baseline' | number | null | undefined),
|
|
228
|
+
('width' | 'height' | 'contain' | null | undefined),
|
|
229
|
+
(number | null | undefined),
|
|
230
|
+
(boolean | null | undefined),
|
|
231
|
+
(boolean | null | undefined)
|
|
232
|
+
];
|
|
233
|
+
/**
|
|
234
|
+
* Equation offset options
|
|
235
|
+
*
|
|
236
|
+
* 
|
|
237
|
+
*
|
|
238
|
+
* Offset a phrase from the position it would normally be.
|
|
239
|
+
* An offest phrase will not contribute to layout of subsequent equation
|
|
240
|
+
* elements and phrases.
|
|
241
|
+
*
|
|
242
|
+
* Options can be an object, or an array in the property order below
|
|
243
|
+
*
|
|
244
|
+
* @property {TypeEquationPhrase} content
|
|
245
|
+
* @property {TypeParsablePoint} [offset] (`[0, 0]`)
|
|
246
|
+
* @property {boolean} [fullContentBounds] - (`false`)
|
|
247
|
+
*
|
|
248
|
+
* @see To test examples, append them to the
|
|
249
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* figure.add([
|
|
253
|
+
* {
|
|
254
|
+
* name: 'rect1',
|
|
255
|
+
* make: 'equation',
|
|
256
|
+
* forms: {
|
|
257
|
+
* 0: [
|
|
258
|
+
* 'a', '_ = ', 'n',
|
|
259
|
+
* { offset: ['for a > 0', [0.3, 0]] },
|
|
260
|
+
* ],
|
|
261
|
+
* },
|
|
262
|
+
* },
|
|
263
|
+
* ]);
|
|
264
|
+
* @interface
|
|
265
|
+
* @group Equation Layout
|
|
266
|
+
*/
|
|
267
|
+
export type EQN_Offset = {
|
|
268
|
+
content: TypeEquationPhrase;
|
|
269
|
+
offset?: TypeParsablePoint;
|
|
270
|
+
inSize?: boolean;
|
|
271
|
+
fullContentBounds?: boolean;
|
|
272
|
+
} | [
|
|
273
|
+
TypeEquationPhrase,
|
|
274
|
+
(TypeParsablePoint | null | undefined),
|
|
275
|
+
(boolean | null | undefined),
|
|
276
|
+
(boolean | null | undefined)
|
|
277
|
+
];
|
|
278
|
+
/**
|
|
279
|
+
* Equation fraction options
|
|
280
|
+
*
|
|
281
|
+
* 
|
|
282
|
+
*
|
|
283
|
+
* A fraction has a numerator and denominator separated by a vinculum
|
|
284
|
+
* symbol {@link EQN_VinculumSymbol}.
|
|
285
|
+
*
|
|
286
|
+
* Options can be an object, or an array in the property order below
|
|
287
|
+
*
|
|
288
|
+
* @property {TypeEquationPhrase} numerator
|
|
289
|
+
* @property {string} symbol - Vinculum symbol
|
|
290
|
+
* @property {TypeEquationPhrase} denominator
|
|
291
|
+
* @property {number} [scale] (`1`)
|
|
292
|
+
* @property {number} [numeratorSpace] (`0.05`)
|
|
293
|
+
* @property {number} [denominatorSpace] (`0.05`)
|
|
294
|
+
* @property {number} [overhang] Vinculum extends beyond the content
|
|
295
|
+
* horizontally by the this amount (`0.05`)
|
|
296
|
+
* @property {number} [offsetY] Offset fraction in y (`0.07`)
|
|
297
|
+
* @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
|
|
298
|
+
*
|
|
299
|
+
* @see To test examples, append them to the
|
|
300
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* // Simple
|
|
304
|
+
* figure.add({
|
|
305
|
+
* name: 'eqn',
|
|
306
|
+
* make: 'equation',
|
|
307
|
+
* forms: {
|
|
308
|
+
* 1: { frac: ['a', 'vinculum', 'b'] },
|
|
309
|
+
* },
|
|
310
|
+
* });
|
|
311
|
+
* figure.elements._eqn.showForm('1');
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* // Example showing object and array fraction definitions, and nesting
|
|
315
|
+
* figure.add({
|
|
316
|
+
* name: 'eqn',
|
|
317
|
+
* make: 'equation',
|
|
318
|
+
* elements: {
|
|
319
|
+
* v1: { symbol: 'vinculum' },
|
|
320
|
+
* v2: { symbol: 'vinculum' },
|
|
321
|
+
* plus: ' + ',
|
|
322
|
+
* },
|
|
323
|
+
* forms: {
|
|
324
|
+
* // Fraction object form
|
|
325
|
+
* 1: {
|
|
326
|
+
* frac: {
|
|
327
|
+
* numerator: 'a',
|
|
328
|
+
* denominator: 'b',
|
|
329
|
+
* symbol: 'v1',
|
|
330
|
+
* },
|
|
331
|
+
* },
|
|
332
|
+
* // Fraction array form
|
|
333
|
+
* 2: { frac: ['a', 'v1', 'd'] },
|
|
334
|
+
* // Nested
|
|
335
|
+
* 3: {
|
|
336
|
+
* frac: {
|
|
337
|
+
* numerator: [{ frac: ['a', 'v1', 'd', 0.7] }, 'plus', '_1'],
|
|
338
|
+
* symbol: 'v2',
|
|
339
|
+
* denominator: 'b',
|
|
340
|
+
* }
|
|
341
|
+
* },
|
|
342
|
+
* },
|
|
343
|
+
* formSeries: ['1', '2', '3'],
|
|
344
|
+
* });
|
|
345
|
+
* const eqn = figure.elements._eqn;
|
|
346
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
347
|
+
* eqn.setTouchable();
|
|
348
|
+
* eqn.showForm('1');
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* // Create equation object then add to figure
|
|
352
|
+
* const eqn = figure.collections.equation({
|
|
353
|
+
* elements: {
|
|
354
|
+
* v1: { symbol: 'vinculum' },
|
|
355
|
+
* v2: { symbol: 'vinculum' },
|
|
356
|
+
* plus: ' + ',
|
|
357
|
+
* },
|
|
358
|
+
* forms: {
|
|
359
|
+
* 1: {
|
|
360
|
+
* frac: {
|
|
361
|
+
* numerator: 'a',
|
|
362
|
+
* denominator: 'b',
|
|
363
|
+
* symbol: 'v1',
|
|
364
|
+
* },
|
|
365
|
+
* },
|
|
366
|
+
* 2: { frac: ['a', 'v1', 'd'] },
|
|
367
|
+
* 3: {
|
|
368
|
+
* frac: {
|
|
369
|
+
* numerator: [{ frac: ['a', 'v1', 'd', 0.7] }, 'plus', '_1'],
|
|
370
|
+
* symbol: 'v2',
|
|
371
|
+
* denominator: 'b',
|
|
372
|
+
* }
|
|
373
|
+
* },
|
|
374
|
+
* },
|
|
375
|
+
* formSeries: ['1', '2', '3'],
|
|
376
|
+
* });
|
|
377
|
+
* figure.add('eqn', eqn);
|
|
378
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
379
|
+
* eqn.setTouchable();
|
|
380
|
+
* eqn.showForm('1');
|
|
381
|
+
* @interface
|
|
382
|
+
* @group Equation Layout
|
|
383
|
+
*/
|
|
384
|
+
export type EQN_Fraction = {
|
|
385
|
+
numerator: TypeEquationPhrase;
|
|
386
|
+
symbol: string;
|
|
387
|
+
denominator: TypeEquationPhrase;
|
|
388
|
+
scale?: number;
|
|
389
|
+
numeratorSpace?: number;
|
|
390
|
+
denominatorSpace?: number;
|
|
391
|
+
overhang?: number;
|
|
392
|
+
offsetY?: number;
|
|
393
|
+
baseline?: 'numerator' | 'denominator' | 'vinculum';
|
|
394
|
+
fullContentBounds?: boolean;
|
|
395
|
+
} | [
|
|
396
|
+
TypeEquationPhrase,
|
|
397
|
+
string,
|
|
398
|
+
TypeEquationPhrase,
|
|
399
|
+
(number | null | undefined),
|
|
400
|
+
(number | null | undefined),
|
|
401
|
+
(number | null | undefined),
|
|
402
|
+
(number | null | undefined),
|
|
403
|
+
(number | null | undefined),
|
|
404
|
+
(('numerator' | 'denominator' | 'vinculum') | null | undefined),
|
|
405
|
+
(boolean | null | undefined)
|
|
406
|
+
];
|
|
407
|
+
/**
|
|
408
|
+
* Equation scale
|
|
409
|
+
*
|
|
410
|
+
* 
|
|
411
|
+
*
|
|
412
|
+
* Scale an equation phrase
|
|
413
|
+
*
|
|
414
|
+
* Options can be an object, or an array in the property order below
|
|
415
|
+
*
|
|
416
|
+
* @property {TypeEquationPhrase} content
|
|
417
|
+
* @property {number} [scale] - (`1`)
|
|
418
|
+
* @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
|
|
419
|
+
*
|
|
420
|
+
* @see To test examples, append them to the
|
|
421
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* // Simple
|
|
425
|
+
* figure.add({
|
|
426
|
+
* name: 'eqn',
|
|
427
|
+
* make: 'equation',
|
|
428
|
+
* forms: {
|
|
429
|
+
* 2: ['a', { scale: ['b', 2] }, 'c'],
|
|
430
|
+
* },
|
|
431
|
+
* });
|
|
432
|
+
* figure.elements._eqn.showForm('1');
|
|
433
|
+
*
|
|
434
|
+
* // Some different bracket examples
|
|
435
|
+
* figure.add({
|
|
436
|
+
* name: 'eqn',
|
|
437
|
+
* make: 'equation',
|
|
438
|
+
* forms: {
|
|
439
|
+
* // Default
|
|
440
|
+
* 1: ['a', 'b', 'c'],
|
|
441
|
+
* // Array definition magnify
|
|
442
|
+
* 2: ['a', { scale: ['b', 2] }, 'c'],
|
|
443
|
+
* // Object definition shrink
|
|
444
|
+
* 3: [
|
|
445
|
+
* 'a',
|
|
446
|
+
* {
|
|
447
|
+
* scale: {
|
|
448
|
+
* content: ['b', 1],
|
|
449
|
+
* scale: 0.5,
|
|
450
|
+
* },
|
|
451
|
+
* },
|
|
452
|
+
* 'c',
|
|
453
|
+
* ],
|
|
454
|
+
* // Back to start
|
|
455
|
+
* 4: ['a', { scale: ['b', 1] }, 'c'],
|
|
456
|
+
* },
|
|
457
|
+
* formSeries: ['1', '2', '3']
|
|
458
|
+
* });
|
|
459
|
+
* const eqn = figure.elements._eqn;
|
|
460
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
461
|
+
* eqn.setTouchable();
|
|
462
|
+
* eqn.showForm('1');
|
|
463
|
+
* @interface
|
|
464
|
+
* @group Equation Layout
|
|
465
|
+
*/
|
|
466
|
+
export type EQN_Scale = {
|
|
467
|
+
content: TypeEquationPhrase;
|
|
468
|
+
scale?: number;
|
|
469
|
+
fullContentBounds?: boolean;
|
|
470
|
+
} | [
|
|
471
|
+
TypeEquationPhrase,
|
|
472
|
+
(number | null | undefined),
|
|
473
|
+
(boolean | null | undefined)
|
|
474
|
+
];
|
|
475
|
+
/**
|
|
476
|
+
* Equation color
|
|
477
|
+
*
|
|
478
|
+
* 
|
|
479
|
+
*
|
|
480
|
+
* Color an equation phrase.
|
|
481
|
+
*
|
|
482
|
+
* Options can be an object, or an array in the property order below
|
|
483
|
+
*
|
|
484
|
+
* @property {TypeEquationPhrase} content
|
|
485
|
+
* @property {TypeColor} color
|
|
486
|
+
* @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
|
|
487
|
+
*
|
|
488
|
+
* @see To test examples, append them to the
|
|
489
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* // Simple Array Definition
|
|
493
|
+
* figure.add({
|
|
494
|
+
* make: 'equation',
|
|
495
|
+
* forms: {
|
|
496
|
+
* 0: ['a', { color: ['b', [0, 0, 1, 1]] }, 'c'],
|
|
497
|
+
* },
|
|
498
|
+
* });
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* // Simple Object Definition
|
|
502
|
+
* figure.add({
|
|
503
|
+
* make: 'equation',
|
|
504
|
+
* forms: {
|
|
505
|
+
* 0: [
|
|
506
|
+
* 'a',
|
|
507
|
+
* {
|
|
508
|
+
* color: {
|
|
509
|
+
* content: 'b',
|
|
510
|
+
* color: [0, 0, 1, 1],
|
|
511
|
+
* },
|
|
512
|
+
* },
|
|
513
|
+
* 'c',
|
|
514
|
+
* ],
|
|
515
|
+
* },
|
|
516
|
+
* });
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* figure.add({
|
|
520
|
+
* make: 'equation',
|
|
521
|
+
* elements: {
|
|
522
|
+
* equals: ' = ',
|
|
523
|
+
* plus: ' + ',
|
|
524
|
+
* brace: { symbol: 'brace', side: 'top' },
|
|
525
|
+
* },
|
|
526
|
+
* forms: {
|
|
527
|
+
* 0: ['2', 'plus', '3', 'equals', 'x'],
|
|
528
|
+
* 1: [
|
|
529
|
+
* {
|
|
530
|
+
* color: {
|
|
531
|
+
* content: { topComment: [['2', 'plus', '3'], '5', 'brace'] },
|
|
532
|
+
* color: [0, 0, 1, 1],
|
|
533
|
+
* },
|
|
534
|
+
* },
|
|
535
|
+
* 'equals', 'x',
|
|
536
|
+
* ],
|
|
537
|
+
* 2: ['5', 'equals', 'x'],
|
|
538
|
+
* },
|
|
539
|
+
* touch: { onClick: e => e.nextForm() },
|
|
540
|
+
* });
|
|
541
|
+
* @interface
|
|
542
|
+
* @group Equation Layout
|
|
543
|
+
*/
|
|
544
|
+
export type EQN_Color = {
|
|
545
|
+
content: TypeEquationPhrase;
|
|
546
|
+
color: TypeColor;
|
|
547
|
+
fullContentBounds?: boolean;
|
|
548
|
+
} | [
|
|
549
|
+
TypeEquationPhrase,
|
|
550
|
+
TypeColor,
|
|
551
|
+
(boolean | null | undefined)
|
|
552
|
+
];
|
|
553
|
+
/**
|
|
554
|
+
* Equation bracket
|
|
555
|
+
*
|
|
556
|
+
* 
|
|
557
|
+
*
|
|
558
|
+
* Surround an equation phrase with brackets.
|
|
559
|
+
*
|
|
560
|
+
* Symbols that can be used with bracket are:
|
|
561
|
+
* - {@link EQN_BarSymbol}
|
|
562
|
+
* - {@link EQN_ArrowSymbol}
|
|
563
|
+
* - {@link EQN_BraceSymbol}
|
|
564
|
+
* - {@link EQN_BracketSymbol}
|
|
565
|
+
* - {@link EQN_SquareBracketSymbol}
|
|
566
|
+
* - {@link EQN_AngleBracketSymbol}
|
|
567
|
+
*
|
|
568
|
+
* Options can be an object, or an array in the property order below
|
|
569
|
+
*
|
|
570
|
+
* @property {string} [left] left bracket symbol
|
|
571
|
+
* @property {TypeEquationPhrase} [content]
|
|
572
|
+
* @property {string} [right] right bracket symbol
|
|
573
|
+
* @property {boolean} [inSize] `false` excludes bracket symbols from
|
|
574
|
+
* size of resulting phrase (`true`)
|
|
575
|
+
* @property {number} [insideSpace] space between brackets and content (`0.03`)
|
|
576
|
+
* @property {number} [outsideSpace] space between brackets and neighboring
|
|
577
|
+
* phrases(`0.03`)
|
|
578
|
+
* @property {number} [topSpace] how far the brackets extend above the content
|
|
579
|
+
* (`0.05`)
|
|
580
|
+
* @property {number} [bottomSpace] how far the brackets extend below the
|
|
581
|
+
* content (`0.05`)
|
|
582
|
+
* @property {number} [minContentHeight] if content height is less than this,
|
|
583
|
+
* then this number will be used when sizing the brackets (unless it is `null`)
|
|
584
|
+
* (`null`)
|
|
585
|
+
* @property {number} [minContentDescent] if content descent is less than this,
|
|
586
|
+
* then this number will be used when sizing the brackets (unless it is `null`)
|
|
587
|
+
* (`null`)
|
|
588
|
+
* @property {number} [height] force height of brackets (`null`)
|
|
589
|
+
* @property {number} [descent] force descent of brackets (`null`)
|
|
590
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
591
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
592
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
593
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
594
|
+
* brackets only surround a portion of the content (`false`)
|
|
595
|
+
*
|
|
596
|
+
* @see To test examples, append them to the
|
|
597
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* // Simple
|
|
601
|
+
* figure.add({
|
|
602
|
+
* make: 'equation',
|
|
603
|
+
* elements: {
|
|
604
|
+
* lb: { symbol: 'bracket', side: 'left' },
|
|
605
|
+
* rb: { symbol: 'bracket', side: 'right' },
|
|
606
|
+
* },
|
|
607
|
+
* forms: {
|
|
608
|
+
* 1: ['a', { brac: ['lb', ['b', '_ + ', 'c'], 'rb'] }],
|
|
609
|
+
* },
|
|
610
|
+
* });
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* // Some different bracket examples
|
|
614
|
+
* figure.add({
|
|
615
|
+
* name: 'eqn',
|
|
616
|
+
* make: 'equation',
|
|
617
|
+
* elements: {
|
|
618
|
+
* lb: { symbol: 'bracket', side: 'left' },
|
|
619
|
+
* rb: { symbol: 'bracket', side: 'right' },
|
|
620
|
+
* lsb: { symbol: 'squareBracket', side: 'left' },
|
|
621
|
+
* rsb: { symbol: 'squareBracket', side: 'right' },
|
|
622
|
+
* leftBrace: { }
|
|
623
|
+
* },
|
|
624
|
+
* forms: {
|
|
625
|
+
* // Array definition
|
|
626
|
+
* 1: ['a', { brac: ['lb', ['b', '_ + ', 'c'], 'rb'] }],
|
|
627
|
+
* // Object definition
|
|
628
|
+
* 2: ['a', {
|
|
629
|
+
* brac: {
|
|
630
|
+
* left: 'lb',
|
|
631
|
+
* content: { frac: ['b', 'vinculum', 'c'] },
|
|
632
|
+
* right: 'rb',
|
|
633
|
+
* },
|
|
634
|
+
* }],
|
|
635
|
+
* // Square brackets
|
|
636
|
+
* 3: ['a', { brac: ['lsb', ['b', '_ + ', 'c'], 'rsb'] }],
|
|
637
|
+
* },
|
|
638
|
+
* formSeries: ['1', '2', '3']
|
|
639
|
+
* });
|
|
640
|
+
* const eqn = figure.elements._eqn;
|
|
641
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
642
|
+
* eqn.setTouchable();
|
|
643
|
+
* @interface
|
|
644
|
+
* @group Equation Layout
|
|
645
|
+
*/
|
|
646
|
+
export type EQN_Bracket = {
|
|
647
|
+
left?: string;
|
|
648
|
+
content: TypeEquationPhrase;
|
|
649
|
+
right?: string;
|
|
650
|
+
inSize?: boolean;
|
|
651
|
+
insideSpace?: number;
|
|
652
|
+
outsideSpace?: number;
|
|
653
|
+
topSpace?: number;
|
|
654
|
+
bottomSpace?: number;
|
|
655
|
+
minContentHeight?: number;
|
|
656
|
+
minContentDescent?: number;
|
|
657
|
+
height?: number;
|
|
658
|
+
descent?: number;
|
|
659
|
+
fullContentBounds?: boolean;
|
|
660
|
+
useFullBounds?: boolean;
|
|
661
|
+
} | [
|
|
662
|
+
string,
|
|
663
|
+
TypeEquationPhrase,
|
|
664
|
+
(string | null | undefined),
|
|
665
|
+
(boolean | null | undefined),
|
|
666
|
+
(number | null | undefined),
|
|
667
|
+
(number | null | undefined),
|
|
668
|
+
(number | null | undefined),
|
|
669
|
+
(number | null | undefined),
|
|
670
|
+
(number | null | undefined),
|
|
671
|
+
(number | null | undefined),
|
|
672
|
+
(number | null | undefined),
|
|
673
|
+
(boolean | null | undefined),
|
|
674
|
+
(boolean | null | undefined)
|
|
675
|
+
];
|
|
676
|
+
/**
|
|
677
|
+
* Equation root
|
|
678
|
+
*
|
|
679
|
+
* 
|
|
680
|
+
*
|
|
681
|
+
* Surround an equation phrase with a radical symbol {@link EQN_RadicalSymbol}
|
|
682
|
+
* and add a custom root if needed
|
|
683
|
+
*
|
|
684
|
+
* Options can be an object, or an array in the property order below.
|
|
685
|
+
*
|
|
686
|
+
* @property {string} symbol radical symbol
|
|
687
|
+
* @property {TypeEquationPhrase} content
|
|
688
|
+
* @property {boolean} [inSize] `false` excludes radical symbol and root (if
|
|
689
|
+
* defined) from size of resulting phrase (`true`)
|
|
690
|
+
* @property {number} [space] (`0.02`) default space between content and
|
|
691
|
+
* radical symbol in left, right, top and bottom directions.
|
|
692
|
+
* @property {number} [topSpace] space between content top and radical symbol
|
|
693
|
+
* horiztonal line (`space`)
|
|
694
|
+
* @property {number} [rightSpace] radical symbol overhang of content on right
|
|
695
|
+
* (`space`)
|
|
696
|
+
* @property {number} [bottomSpace] radical symbol descent below content
|
|
697
|
+
* (`space`)
|
|
698
|
+
* @property {number} [leftSpace] space between radical symbol up stroke and
|
|
699
|
+
* content (`space`)
|
|
700
|
+
* @property {TypeEquationPhrase} [root] custom root
|
|
701
|
+
* @property {number} [rootOffset] custom root offset (`[0, 0.06]`)
|
|
702
|
+
* @property {number} [rootScale] custom root scale (`0.6`)
|
|
703
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
704
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
705
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
706
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
707
|
+
* brackets only surround a portion of the content (`false`)
|
|
708
|
+
*
|
|
709
|
+
* @see To test examples, append them to the
|
|
710
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* // Simple
|
|
714
|
+
* figure.add({
|
|
715
|
+
* name: 'eqn',
|
|
716
|
+
* make: 'equation',
|
|
717
|
+
* forms: {
|
|
718
|
+
* 1: { root: ['radical', 'a'] },
|
|
719
|
+
* },
|
|
720
|
+
* });
|
|
721
|
+
* figure.elements._eqn.showForm('1');
|
|
722
|
+
*
|
|
723
|
+
* @example
|
|
724
|
+
* // Example showing object and array root definitions, and custom roots
|
|
725
|
+
* figure.add({
|
|
726
|
+
* name: 'eqn',
|
|
727
|
+
* make: 'equation',
|
|
728
|
+
* elements: {
|
|
729
|
+
* r: { symbol: 'radical' },
|
|
730
|
+
* plus: ' + ',
|
|
731
|
+
* },
|
|
732
|
+
* formDefaults: { alignment: { fixTo: 'd' } },
|
|
733
|
+
* forms: {
|
|
734
|
+
* // Root object form
|
|
735
|
+
* 1: {
|
|
736
|
+
* root: {
|
|
737
|
+
* symbol: 'r',
|
|
738
|
+
* content: ['a', 'plus', 'd'],
|
|
739
|
+
* },
|
|
740
|
+
* },
|
|
741
|
+
* // Root array form
|
|
742
|
+
* 2: { root: ['r', 'd'] },
|
|
743
|
+
* // Cube root
|
|
744
|
+
* 3: { root: { content: 'd', symbol: 'r', root: '_3' } },
|
|
745
|
+
* },
|
|
746
|
+
* formSeries: ['1', '2', '3'],
|
|
747
|
+
* });
|
|
748
|
+
* const eqn = figure.elements._eqn;
|
|
749
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
750
|
+
* eqn.setTouchable();
|
|
751
|
+
* eqn.showForm('1');
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* // Create equation object then add to figure
|
|
755
|
+
* const eqn = figure.collections.equation({
|
|
756
|
+
* elements: {
|
|
757
|
+
* r: { symbol: 'radical' },
|
|
758
|
+
* plus: ' + ',
|
|
759
|
+
* },
|
|
760
|
+
* formDefaults: {
|
|
761
|
+
* alignment: { fixTo: 'd' },
|
|
762
|
+
* },
|
|
763
|
+
* forms: {
|
|
764
|
+
* 1: {
|
|
765
|
+
* root: {
|
|
766
|
+
* symbol: 'r',
|
|
767
|
+
* content: ['a', 'plus', 'd'],
|
|
768
|
+
* },
|
|
769
|
+
* },
|
|
770
|
+
* 2: { root: ['r', 'd'] },
|
|
771
|
+
* 3: { root: { content: 'd', symbol: 'r', root: '_3' } },
|
|
772
|
+
* },
|
|
773
|
+
* formSeries: ['1', '2', '3'],
|
|
774
|
+
* });
|
|
775
|
+
* figure.add('eqn', eqn);
|
|
776
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
777
|
+
* eqn.setTouchable();
|
|
778
|
+
* eqn.showForm('1');
|
|
779
|
+
* @interface
|
|
780
|
+
* @group Equation Layout
|
|
781
|
+
*/
|
|
782
|
+
export type EQN_Root = {
|
|
783
|
+
symbol: string;
|
|
784
|
+
content: TypeEquationPhrase;
|
|
785
|
+
inSize?: boolean;
|
|
786
|
+
space?: number;
|
|
787
|
+
topSpace?: number;
|
|
788
|
+
rightSpace?: number;
|
|
789
|
+
bottomSpace?: number;
|
|
790
|
+
leftSpace?: number;
|
|
791
|
+
root: TypeEquationPhrase;
|
|
792
|
+
rootOffset?: number;
|
|
793
|
+
rootScale?: number;
|
|
794
|
+
fullContentBounds?: boolean;
|
|
795
|
+
useFullBounds?: boolean;
|
|
796
|
+
} | [
|
|
797
|
+
string,
|
|
798
|
+
TypeEquationPhrase,
|
|
799
|
+
(boolean | null | undefined),
|
|
800
|
+
(number | null | undefined),
|
|
801
|
+
(number | null | undefined),
|
|
802
|
+
(number | null | undefined),
|
|
803
|
+
(number | null | undefined),
|
|
804
|
+
(number | null | undefined),
|
|
805
|
+
(TypeEquationPhrase | null | undefined),
|
|
806
|
+
(number | null | undefined),
|
|
807
|
+
(number | null | undefined),
|
|
808
|
+
(boolean | null | undefined),
|
|
809
|
+
(boolean | null | undefined)
|
|
810
|
+
];
|
|
811
|
+
/**
|
|
812
|
+
* Equation strike-through
|
|
813
|
+
*
|
|
814
|
+
* 
|
|
815
|
+
*
|
|
816
|
+
* Overlay a strike symbol on an equation phrase.
|
|
817
|
+
*
|
|
818
|
+
* Use with {@link EQN_Strike} symbol.
|
|
819
|
+
*
|
|
820
|
+
* Options can be an object, or an array in the property order below
|
|
821
|
+
*
|
|
822
|
+
* @property {TypeEquationPhrase} content
|
|
823
|
+
* @property {string} symbol
|
|
824
|
+
* @property {boolean} [inSize] `false` excludes strike symbol from size of
|
|
825
|
+
* resulting phrase (`false`)
|
|
826
|
+
* @property {number} [space] amount the strike symbol overhangs the content on
|
|
827
|
+
* the left, right, bottom and top sides (`0.02`)
|
|
828
|
+
* @property {number} [topSpace] use when top overhang between content and
|
|
829
|
+
* strike should be different thant `space` property (`space`)
|
|
830
|
+
* @property {number} [rightSpace] use when right overhang between content and
|
|
831
|
+
* strike should be different thant `space` property (`space`)
|
|
832
|
+
* @property {number} [bottomSpace] use when bottom overhang between content and
|
|
833
|
+
* strike should be different thant `space` property (`space`)
|
|
834
|
+
* @property {number} [leftSpace] use when left overhang between content and
|
|
835
|
+
* strike should be different thant `space` property (`space`)
|
|
836
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
837
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
838
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
839
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
840
|
+
* brackets only surround a portion of the content (`false`)
|
|
841
|
+
*
|
|
842
|
+
* @see To test examples, append them to the
|
|
843
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* // Simple
|
|
847
|
+
* figure.add({
|
|
848
|
+
* name: 'eqn',
|
|
849
|
+
* make: 'equation',
|
|
850
|
+
* elements: {
|
|
851
|
+
* x: { symbol: 'strike', color: [0.6, 0.6, 0.6, 1] },
|
|
852
|
+
* },
|
|
853
|
+
* forms: {
|
|
854
|
+
* 1: [{ strike: ['a', 'x']}, ' ', 'b'],
|
|
855
|
+
* },
|
|
856
|
+
* });
|
|
857
|
+
* figure.elements._eqn.showForm('1');
|
|
858
|
+
*
|
|
859
|
+
* @example
|
|
860
|
+
* // Some different strike examples
|
|
861
|
+
* figure.add({
|
|
862
|
+
* name: 'eqn',
|
|
863
|
+
* make: 'equation',
|
|
864
|
+
* elements: {
|
|
865
|
+
* s1: { symbol: 'strike', color: [0.6, 0.6, 0.6, 1] },
|
|
866
|
+
* s2: { symbol: 'strike', style: 'forward', color: [0.6, 0.6, 0.6, 1] },
|
|
867
|
+
* },
|
|
868
|
+
* forms: {
|
|
869
|
+
* // Array definition
|
|
870
|
+
* 1: [{ strike: ['a', 's1']}, ' ', 'b'],
|
|
871
|
+
* // Object definition
|
|
872
|
+
* 2: {
|
|
873
|
+
* strike: {
|
|
874
|
+
* content: ['a', '_ + ', 'b'],
|
|
875
|
+
* symbol: 's1',
|
|
876
|
+
* },
|
|
877
|
+
* },
|
|
878
|
+
* // Additional options to make strike overhang more
|
|
879
|
+
* 3: {
|
|
880
|
+
* strike: {
|
|
881
|
+
* content: ['a', 'b'],
|
|
882
|
+
* symbol: 's1',
|
|
883
|
+
* topSpace: 0.2,
|
|
884
|
+
* rightSpace: 0.2,
|
|
885
|
+
* leftSpace: 0.2,
|
|
886
|
+
* bottomSpace: 0.2,
|
|
887
|
+
* },
|
|
888
|
+
* },
|
|
889
|
+
* // Forward strike
|
|
890
|
+
* 4: { strike: [['a', '_ +', 'b'], 's2'] },
|
|
891
|
+
* },
|
|
892
|
+
* formSeries: ['1', '2', '3', '4']
|
|
893
|
+
* });
|
|
894
|
+
* const eqn = figure.elements._eqn;
|
|
895
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
896
|
+
* eqn.setTouchable();
|
|
897
|
+
* eqn.showForm('1');
|
|
898
|
+
* @interface
|
|
899
|
+
* @group Equation Layout
|
|
900
|
+
*/
|
|
901
|
+
export type EQN_Strike = {
|
|
902
|
+
content: TypeEquationPhrase;
|
|
903
|
+
symbol: string;
|
|
904
|
+
inSize?: boolean;
|
|
905
|
+
space?: number;
|
|
906
|
+
topSpace?: number;
|
|
907
|
+
rightSpace?: number;
|
|
908
|
+
bottomSpace?: number;
|
|
909
|
+
leftSpace?: number;
|
|
910
|
+
fullContentBounds?: boolean;
|
|
911
|
+
useFullBounds?: boolean;
|
|
912
|
+
} | [
|
|
913
|
+
TypeEquationPhrase,
|
|
914
|
+
string,
|
|
915
|
+
(boolean | null | undefined),
|
|
916
|
+
(number | null | undefined),
|
|
917
|
+
(number | null | undefined),
|
|
918
|
+
(number | null | undefined),
|
|
919
|
+
(number | null | undefined),
|
|
920
|
+
(number | null | undefined),
|
|
921
|
+
(boolean | null | undefined),
|
|
922
|
+
(boolean | null | undefined)
|
|
923
|
+
];
|
|
924
|
+
/**
|
|
925
|
+
* Equation box
|
|
926
|
+
*
|
|
927
|
+
* 
|
|
928
|
+
*
|
|
929
|
+
* Place a {@link EQN_BoxSymbol} around an equation phrase
|
|
930
|
+
*
|
|
931
|
+
*
|
|
932
|
+
* Options can be an object, or an array in the property order below
|
|
933
|
+
*
|
|
934
|
+
* @property {TypeEquationPhrase} content
|
|
935
|
+
* @property {string} symbol
|
|
936
|
+
* @property {boolean} [inSize] `false` excludes box symbol from size of
|
|
937
|
+
* resulting phrase (`false`)
|
|
938
|
+
* @property {number} [space] space between box symbol and content on
|
|
939
|
+
* the left, right, bottom and top sides (`0`)
|
|
940
|
+
* @property {number} [topSpace] use when top space between content and
|
|
941
|
+
* box should be different thant `space` property (`space`)
|
|
942
|
+
* @property {number} [rightSpace] use when right space between content and
|
|
943
|
+
* box should be different thant `space` property (`space`)
|
|
944
|
+
* @property {number} [bottomSpace] use when bottom space between content and
|
|
945
|
+
* box should be different thant `space` property (`space`)
|
|
946
|
+
* @property {number} [leftSpace] use when left space between content and
|
|
947
|
+
* box should be different thant `space` property (`space`)
|
|
948
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
949
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
950
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
951
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
952
|
+
* brackets only surround a portion of the content (`false`)
|
|
953
|
+
*
|
|
954
|
+
*
|
|
955
|
+
* @see To test examples, append them to the
|
|
956
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* // Simple
|
|
960
|
+
* figure.add({
|
|
961
|
+
* name: 'eqn',
|
|
962
|
+
* make: 'equation',
|
|
963
|
+
* forms: {
|
|
964
|
+
* 1: { box: ['a', 'box', true, 0.1] },
|
|
965
|
+
* },
|
|
966
|
+
* });
|
|
967
|
+
* figure.elements._eqn.showForm('1');
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* // Some different box examples
|
|
971
|
+
* figure.add({
|
|
972
|
+
* name: 'eqn',
|
|
973
|
+
* make: 'equation',
|
|
974
|
+
* elements: {
|
|
975
|
+
* box: { symbol: 'box' },
|
|
976
|
+
* },
|
|
977
|
+
* forms: {
|
|
978
|
+
* // Array equation
|
|
979
|
+
* 1: ['a', { box: ['b', 'box'] }, 'c'],
|
|
980
|
+
* // Object definition
|
|
981
|
+
* 2: {
|
|
982
|
+
* box: {
|
|
983
|
+
* content: ['a', 'b', 'c'],
|
|
984
|
+
* symbol: 'box',
|
|
985
|
+
* },
|
|
986
|
+
* },
|
|
987
|
+
* // Additional options for layout
|
|
988
|
+
* 3: {
|
|
989
|
+
* box: {
|
|
990
|
+
* content: ['a', 'b', 'c'],
|
|
991
|
+
* symbol: 'box',
|
|
992
|
+
* space: 0.2,
|
|
993
|
+
* },
|
|
994
|
+
* },
|
|
995
|
+
* // Box is included in the layout spacing
|
|
996
|
+
* 4: [
|
|
997
|
+
* 'a',
|
|
998
|
+
* {
|
|
999
|
+
* box: {
|
|
1000
|
+
* content: 'b',
|
|
1001
|
+
* symbol: 'box',
|
|
1002
|
+
* space: 0.2,
|
|
1003
|
+
* inSize: true,
|
|
1004
|
+
* },
|
|
1005
|
+
* },
|
|
1006
|
+
* 'c'
|
|
1007
|
+
* ],
|
|
1008
|
+
* },
|
|
1009
|
+
* formSeries: ['1', '2', '3', '4']
|
|
1010
|
+
* });
|
|
1011
|
+
* const eqn = figure.elements._eqn;
|
|
1012
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1013
|
+
* eqn.setTouchable();
|
|
1014
|
+
* eqn.showForm('1');
|
|
1015
|
+
* @interface
|
|
1016
|
+
* @group Equation Layout
|
|
1017
|
+
*/
|
|
1018
|
+
export type EQN_Box = {
|
|
1019
|
+
content: TypeEquationPhrase;
|
|
1020
|
+
symbol: string;
|
|
1021
|
+
inSize?: boolean;
|
|
1022
|
+
space?: number;
|
|
1023
|
+
topSpace?: number;
|
|
1024
|
+
rightSpace?: number;
|
|
1025
|
+
bottomSpace?: number;
|
|
1026
|
+
leftSpace?: number;
|
|
1027
|
+
fullContentBounds?: boolean;
|
|
1028
|
+
useFullBounds?: boolean;
|
|
1029
|
+
} | [
|
|
1030
|
+
TypeEquationPhrase,
|
|
1031
|
+
string,
|
|
1032
|
+
(boolean | null | undefined),
|
|
1033
|
+
(number | null | undefined),
|
|
1034
|
+
(number | null | undefined),
|
|
1035
|
+
(number | null | undefined),
|
|
1036
|
+
(number | null | undefined),
|
|
1037
|
+
(number | null | undefined),
|
|
1038
|
+
(boolean | null | undefined),
|
|
1039
|
+
(boolean | null | undefined)
|
|
1040
|
+
];
|
|
1041
|
+
/**
|
|
1042
|
+
* Equation touch box
|
|
1043
|
+
*
|
|
1044
|
+
* Place a box symbol around an equation phrase
|
|
1045
|
+
*
|
|
1046
|
+
* Options can be an object, or an array in the property order below
|
|
1047
|
+
*
|
|
1048
|
+
* @property {TypeEquationPhrase} content
|
|
1049
|
+
* @property {string} symbol
|
|
1050
|
+
* @property {number} [space] space between box symbol and content on
|
|
1051
|
+
* the left, right, bottom and top sides (`0`)
|
|
1052
|
+
* @property {number} [topSpace] use when top space between content and
|
|
1053
|
+
* box should be different thant `space` property (`space`)
|
|
1054
|
+
* @property {number} [rightSpace] use when right space between content and
|
|
1055
|
+
* box should be different thant `space` property (`space`)
|
|
1056
|
+
* @property {number} [bottomSpace] use when bottom space between content and
|
|
1057
|
+
* box should be different thant `space` property (`space`)
|
|
1058
|
+
* @property {number} [leftSpace] use when left space between content and
|
|
1059
|
+
* box should be different thant `space` property (`space`)
|
|
1060
|
+
*
|
|
1061
|
+
*
|
|
1062
|
+
* @see To test examples, append them to the
|
|
1063
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1064
|
+
*
|
|
1065
|
+
* @interface
|
|
1066
|
+
* @group Equation Layout
|
|
1067
|
+
*/
|
|
1068
|
+
export type EQN_TouchBox = {
|
|
1069
|
+
content: TypeEquationPhrase;
|
|
1070
|
+
symbol: string;
|
|
1071
|
+
space?: number;
|
|
1072
|
+
topSpace?: number;
|
|
1073
|
+
rightSpace?: number;
|
|
1074
|
+
bottomSpace?: number;
|
|
1075
|
+
leftSpace?: number;
|
|
1076
|
+
} | [
|
|
1077
|
+
TypeEquationPhrase,
|
|
1078
|
+
string,
|
|
1079
|
+
(number | null | undefined),
|
|
1080
|
+
(number | null | undefined),
|
|
1081
|
+
(number | null | undefined),
|
|
1082
|
+
(number | null | undefined),
|
|
1083
|
+
(number | null | undefined)
|
|
1084
|
+
];
|
|
1085
|
+
/**
|
|
1086
|
+
* Equation bar
|
|
1087
|
+
*
|
|
1088
|
+
* 
|
|
1089
|
+
*
|
|
1090
|
+
* Place a bar (or bracket) symbol to the side of an equation phrase.
|
|
1091
|
+
*
|
|
1092
|
+
* Symbols that can be used with bar are:
|
|
1093
|
+
* - {@link EQN_BarSymbol}
|
|
1094
|
+
* - {@link EQN_ArrowSymbol}
|
|
1095
|
+
* - {@link EQN_BraceSymbol}
|
|
1096
|
+
* - {@link EQN_BracketSymbol}
|
|
1097
|
+
* - {@link EQN_SquareBracketSymbol}
|
|
1098
|
+
* - {@link EQN_AngleBracketSymbol}
|
|
1099
|
+
*
|
|
1100
|
+
* Options can be an object, or an array in the property order below
|
|
1101
|
+
*
|
|
1102
|
+
* @property {TypeEquationPhrase} content
|
|
1103
|
+
* @property {string} symbol
|
|
1104
|
+
* @property {boolean} [inSize] `false` excludes box symbol from size of
|
|
1105
|
+
* resulting phrase (`true`)
|
|
1106
|
+
* @property {number} [space] space between content and the symbol (`0.03`)
|
|
1107
|
+
* @property {number} [overhang] amount symbol extends beyond content (`0`)
|
|
1108
|
+
* @property {number} [length] total length of symbol (overrides `overhang`)
|
|
1109
|
+
* @property {number} [left] amount symbol extends beyond content to the left
|
|
1110
|
+
* (overrides `overhang` and `length`, and only for side `'top'` or `'bottom'`)
|
|
1111
|
+
* @property {number} [right] amount symbol extends beyond content to the right
|
|
1112
|
+
* (overrides `overhang` and `length`, and only for side `'top'` or `'bottom'`)
|
|
1113
|
+
* @property {number} [top] amount symbol extends beyond content to the top
|
|
1114
|
+
* (overrides `overhang` and `length`, and only for side `'left'` or `'right'`)
|
|
1115
|
+
* @property {number} [bottom] amount symbol extends beyond content to the
|
|
1116
|
+
* bottom (overrides `overhang` and `length`, and only for side `'left'` or
|
|
1117
|
+
* `'right'`)
|
|
1118
|
+
* @property {'left' | 'right' | 'top' | 'bottom'} [side] (`top`)
|
|
1119
|
+
* @property {number} [minContentHeight] custom min content height for auto
|
|
1120
|
+
* symbol sizing when side is `'top'` or `'bottom'`
|
|
1121
|
+
* @property {number} [minContentDescent] custom min content descent for auto
|
|
1122
|
+
* symbol sizing when side is `'top'` or `'bottom'`
|
|
1123
|
+
* @property {number} [minContentAscent] custom min content ascent for auto
|
|
1124
|
+
* symbol sizing when side is `'top'` or `'bottom'`
|
|
1125
|
+
* @property {number} [descent] force descent of symbol when side is `'top'` or
|
|
1126
|
+
* `'bottom'` - height is forced with `length` property
|
|
1127
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
1128
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
1129
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
1130
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
1131
|
+
* brackets only surround a portion of the content (`false`)
|
|
1132
|
+
*
|
|
1133
|
+
* @see To test examples, append them to the
|
|
1134
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1135
|
+
*
|
|
1136
|
+
* @example
|
|
1137
|
+
* // Simple
|
|
1138
|
+
* figure.add({
|
|
1139
|
+
* name: 'eqn',
|
|
1140
|
+
* make: 'equation',
|
|
1141
|
+
* elements: {
|
|
1142
|
+
* bar: { symbol: 'bar', side: 'top' },
|
|
1143
|
+
* },
|
|
1144
|
+
* forms: {
|
|
1145
|
+
* 1: { bar: ['a', 'bar', 'top'] },
|
|
1146
|
+
* },
|
|
1147
|
+
* });
|
|
1148
|
+
* figure.elements._eqn.showForm('1');
|
|
1149
|
+
*
|
|
1150
|
+
* @example
|
|
1151
|
+
* // Some different bar examples
|
|
1152
|
+
* figure.add({
|
|
1153
|
+
* name: 'eqn',
|
|
1154
|
+
* make: 'equation',
|
|
1155
|
+
* elements: {
|
|
1156
|
+
* hBar: { symbol: 'bar', side: 'top' },
|
|
1157
|
+
* vBar: { symbol: 'bar', side: 'right' },
|
|
1158
|
+
* hArrow: { symbol: 'arrow', direction: 'right' },
|
|
1159
|
+
* },
|
|
1160
|
+
* forms: {
|
|
1161
|
+
* // Array equation
|
|
1162
|
+
* 1: { bar: [['a', 'b'], 'hBar', 'top'] },
|
|
1163
|
+
* // Object definition
|
|
1164
|
+
* 2: {
|
|
1165
|
+
* bar: {
|
|
1166
|
+
* content: ['a', 'b'],
|
|
1167
|
+
* symbol: 'hBar',
|
|
1168
|
+
* side: 'bottom',
|
|
1169
|
+
* },
|
|
1170
|
+
* },
|
|
1171
|
+
* // Additional options for layout
|
|
1172
|
+
* 3: {
|
|
1173
|
+
* bar: {
|
|
1174
|
+
* content: ['a', 'b'],
|
|
1175
|
+
* symbol: 'vBar',
|
|
1176
|
+
* side: 'right',
|
|
1177
|
+
* overhang: 0.1,
|
|
1178
|
+
* },
|
|
1179
|
+
* },
|
|
1180
|
+
* // Vector arrow
|
|
1181
|
+
* 4: {
|
|
1182
|
+
* bar: {
|
|
1183
|
+
* content: ['a', 'b'],
|
|
1184
|
+
* symbol: 'hArrow',
|
|
1185
|
+
* side: 'top',
|
|
1186
|
+
* },
|
|
1187
|
+
* },
|
|
1188
|
+
* },
|
|
1189
|
+
* formSeries: ['1', '2', '3', '4']
|
|
1190
|
+
* });
|
|
1191
|
+
* const eqn = figure.elements._eqn;
|
|
1192
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1193
|
+
* eqn.setTouchable();
|
|
1194
|
+
* eqn.showForm('1');
|
|
1195
|
+
* @interface
|
|
1196
|
+
* @group Equation Layout
|
|
1197
|
+
*/
|
|
1198
|
+
export type EQN_Bar = {
|
|
1199
|
+
content: TypeEquationPhrase;
|
|
1200
|
+
symbol?: string;
|
|
1201
|
+
inSize?: boolean;
|
|
1202
|
+
space?: number;
|
|
1203
|
+
overhang?: number;
|
|
1204
|
+
length?: number;
|
|
1205
|
+
left?: number;
|
|
1206
|
+
right?: number;
|
|
1207
|
+
top?: number;
|
|
1208
|
+
bottom?: number;
|
|
1209
|
+
side?: 'left' | 'right' | 'top' | 'bottom';
|
|
1210
|
+
minContentHeight?: number;
|
|
1211
|
+
minContentDescent?: number;
|
|
1212
|
+
minContentAscent?: number;
|
|
1213
|
+
descent?: number;
|
|
1214
|
+
fullContentBounds?: boolean;
|
|
1215
|
+
useFullBounds?: boolean;
|
|
1216
|
+
} | [
|
|
1217
|
+
TypeEquationPhrase,
|
|
1218
|
+
(string | null | undefined),
|
|
1219
|
+
(boolean | null | undefined),
|
|
1220
|
+
(number | null | undefined),
|
|
1221
|
+
(number | null | undefined),
|
|
1222
|
+
(number | null | undefined),
|
|
1223
|
+
(number | null | undefined),
|
|
1224
|
+
(number | null | undefined),
|
|
1225
|
+
(number | null | undefined),
|
|
1226
|
+
(number | null | undefined),
|
|
1227
|
+
('left' | 'right' | 'top' | 'bottom' | null | undefined),
|
|
1228
|
+
(number | null | undefined),
|
|
1229
|
+
(number | null | undefined),
|
|
1230
|
+
(number | null | undefined),
|
|
1231
|
+
(number | null | undefined),
|
|
1232
|
+
(boolean | null | undefined),
|
|
1233
|
+
(boolean | null | undefined)
|
|
1234
|
+
];
|
|
1235
|
+
/**
|
|
1236
|
+
* Equation integral
|
|
1237
|
+
*
|
|
1238
|
+
* 
|
|
1239
|
+
*
|
|
1240
|
+
* Place an integral (with optional limits) before an equation phrase
|
|
1241
|
+
*
|
|
1242
|
+
* Use with a {@link EQN_IntegralSymbol} symbol.
|
|
1243
|
+
*
|
|
1244
|
+
* Options can be an object, or an array in the property order below.
|
|
1245
|
+
*
|
|
1246
|
+
* @property {string} symbol
|
|
1247
|
+
* @property {TypeEquationPhrase} content
|
|
1248
|
+
* @property {TypeEquationPhrase} [from] bottom limit
|
|
1249
|
+
* @property {TypeEquationPhrase} [to] top limit
|
|
1250
|
+
* @property {boolean} [inSize] `false` excludes box symbol from size of
|
|
1251
|
+
* resulting phrase (`true`)
|
|
1252
|
+
* @property {number} [space] horizontal space between symbol and content (`0.05`)
|
|
1253
|
+
* @property {number} [topSpace] space between content top and symbol top (`0.1`)
|
|
1254
|
+
* @property {number} [bottomSpace] space between content bottom and symbol bottom (`0.1`)
|
|
1255
|
+
* @property {number} [height] force height of symbol
|
|
1256
|
+
* @property {number} [yOffset] y offset of symbol (`0`)
|
|
1257
|
+
* @property {number} [scale] content scale (`1`)
|
|
1258
|
+
* @property {number} [fromScale] scale of *from* (bottom) limit (`0.5`)
|
|
1259
|
+
* @property {number} [toScale] scale of *to* (top) limit (`0.5`)
|
|
1260
|
+
* @property {TypeParsablePoint} [fromOffset] from limit offest ( `side`:
|
|
1261
|
+
* `[0, 0]`, `topBottom`: `[0, -0.04]`, `topBottomCenter`: `[0, -0.04]`)
|
|
1262
|
+
* @property {TypeParsablePoint} [toOffset] to limit offest (`side`: `[0, 0]`
|
|
1263
|
+
* `topBottom`: `[0, 0.04]`, `topBottomCenter`: `[0, 0.04]`)
|
|
1264
|
+
* @property {'side' | 'topBottom' | 'topBottomCenter'} [limitsPosition] limits
|
|
1265
|
+
* relative to symbol. `side` is to the right of the symbol ends, `topBottom`
|
|
1266
|
+
* is above and below the symbol ends and `topBottomCenter` is above and below
|
|
1267
|
+
* the integral mid point (`'side'`)
|
|
1268
|
+
* @property {boolean} [limitsAroundContent] `false` means content left is
|
|
1269
|
+
* aligned with furthest right of limits
|
|
1270
|
+
* @property {'left' | 'center' | 'right' | number} [fromXPosition] x position
|
|
1271
|
+
* of limit relative to the symbol (`side`: `0.5`, `topBottom`: `0.1`,
|
|
1272
|
+
* `topBottomCenter`: `'center'`)
|
|
1273
|
+
* @property {'bottom' | 'top' | 'middle' | 'baseline' | number} [fromYPositio]
|
|
1274
|
+
* y position of the limit relavite to the symbol (`'bottom'`)
|
|
1275
|
+
* @property {'left' | 'center' | 'right' | number} [fromXAlign] limit x
|
|
1276
|
+
* alignment (`side`: `'left'`, `topBottom`: `center`,
|
|
1277
|
+
* `topBottomCenter`: `'center'`)
|
|
1278
|
+
* @property {'bottom' | 'top' | 'middle' | 'baseline' | number} [fromYAlign]
|
|
1279
|
+
* limit y alignment (`side`: `'middle'`, `topBottom`: `'top'`,
|
|
1280
|
+
* `topBottomCenter`: `'top'`)
|
|
1281
|
+
* @property {'left' | 'center' | 'right' | number} [toXPosition] x position
|
|
1282
|
+
* of limit relative to the symbol (`side`: `'right'`, `topBottom`: `0.9`,
|
|
1283
|
+
* `topBottomCenter`: `'center'`)
|
|
1284
|
+
* @property {'bottom' | 'top' | 'middle' | 'baseline' | number} [toYPosition]
|
|
1285
|
+
* y position of the limit relavite to the symbol (`side`: `'top'`,
|
|
1286
|
+
* `topBottom`: `top`, `topBottomCenter`: `'top'`)
|
|
1287
|
+
* @property {'left' | 'center' | 'right' | number} [toXAlign] limit x
|
|
1288
|
+
* alignment (`side`: `'left'`, `topBottom`: `center`,
|
|
1289
|
+
* `topBottomCenter`: `'center'`)
|
|
1290
|
+
* @property {'bottom' | 'top' | 'middle' | 'baseline' | number} [toYAlign]
|
|
1291
|
+
* limit y alignment (`side`: `'middle'`, `topBottom`: `bottom`,
|
|
1292
|
+
* `topBottomCenter`: `'bottom'`)
|
|
1293
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
1294
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
1295
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
1296
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
1297
|
+
* brackets only surround a portion of the content (`false`)
|
|
1298
|
+
*
|
|
1299
|
+
* @see To test examples, append them to the
|
|
1300
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1301
|
+
*
|
|
1302
|
+
* @example
|
|
1303
|
+
* // Simple
|
|
1304
|
+
* figure.add({
|
|
1305
|
+
* name: 'eqn',
|
|
1306
|
+
* make: 'equation',
|
|
1307
|
+
* forms: {
|
|
1308
|
+
* 1: { int: ['int', 'x dx', 'a', 'b'] },
|
|
1309
|
+
* },
|
|
1310
|
+
* });
|
|
1311
|
+
* figure.elements._eqn.showForm('1');
|
|
1312
|
+
*
|
|
1313
|
+
* @example
|
|
1314
|
+
* // Example showing different integral options
|
|
1315
|
+
* figure.add({
|
|
1316
|
+
* name: 'eqn',
|
|
1317
|
+
* make: 'equation',
|
|
1318
|
+
* elements: {
|
|
1319
|
+
* i: { symbol: 'int' },
|
|
1320
|
+
* // ic: { symbol: 'int', num: 1, type: 'line' },
|
|
1321
|
+
* },
|
|
1322
|
+
* formDefaults: { alignment: { fixTo: 'x' } },
|
|
1323
|
+
* forms: {
|
|
1324
|
+
* // Root object form
|
|
1325
|
+
* 1: {
|
|
1326
|
+
* int: {
|
|
1327
|
+
* symbol: 'i',
|
|
1328
|
+
* content: ['x', ' ', 'dx'],
|
|
1329
|
+
* from: 'a',
|
|
1330
|
+
* to: 'b',
|
|
1331
|
+
* },
|
|
1332
|
+
* },
|
|
1333
|
+
* // Root array form
|
|
1334
|
+
* 2: { int: ['i', ['x', ' ', '+', ' ', '_1', ' ', 'dx'], 'a', 'b'] },
|
|
1335
|
+
* // Indefinite tripple integral
|
|
1336
|
+
* 3: { int: ['i', ['x', ' ', '+', ' ', '_1', ' ', 'dx']] },
|
|
1337
|
+
* // Custom spacing
|
|
1338
|
+
* 4: {
|
|
1339
|
+
* int: {
|
|
1340
|
+
* symbol: 'i',
|
|
1341
|
+
* content: ['x', ' ', '+', ' ', '_1', ' ', 'dx'],
|
|
1342
|
+
* to: 'b',
|
|
1343
|
+
* from: { frac: ['a', 'vinculum', 'd + 2'] },
|
|
1344
|
+
* topSpace: 0.2,
|
|
1345
|
+
* bottomSpace: 0.2,
|
|
1346
|
+
* limitsAroundContent: false,
|
|
1347
|
+
* },
|
|
1348
|
+
* },
|
|
1349
|
+
* },
|
|
1350
|
+
* formSeries: ['1', '2', '3', '4'],
|
|
1351
|
+
* });
|
|
1352
|
+
* const eqn = figure.elements._eqn;
|
|
1353
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1354
|
+
* eqn.setTouchable();
|
|
1355
|
+
* eqn.showForm('1');
|
|
1356
|
+
* @interface
|
|
1357
|
+
* @group Equation Layout
|
|
1358
|
+
*/
|
|
1359
|
+
export type EQN_Integral = {
|
|
1360
|
+
symbol?: string;
|
|
1361
|
+
content?: TypeEquationPhrase;
|
|
1362
|
+
from?: TypeEquationPhrase;
|
|
1363
|
+
to?: TypeEquationPhrase;
|
|
1364
|
+
inSize?: boolean;
|
|
1365
|
+
space?: number;
|
|
1366
|
+
topSpace?: number;
|
|
1367
|
+
bottomSpace?: number;
|
|
1368
|
+
height?: number;
|
|
1369
|
+
yOffset?: number;
|
|
1370
|
+
scale?: number;
|
|
1371
|
+
fromScale?: number;
|
|
1372
|
+
toScale?: number;
|
|
1373
|
+
fromOffset?: TypeParsablePoint;
|
|
1374
|
+
toOffset?: TypeParsablePoint;
|
|
1375
|
+
limitsPosition?: 'side' | 'topBottom' | 'topBottomCenter';
|
|
1376
|
+
limitsAroundContent?: boolean;
|
|
1377
|
+
fromXPosition?: 'left' | 'center' | 'right' | number;
|
|
1378
|
+
fromYPosition?: 'bottom' | 'top' | 'middle' | 'baseline' | number;
|
|
1379
|
+
fromXAlign?: 'left' | 'center' | 'right' | number;
|
|
1380
|
+
fromYAlign?: 'bottom' | 'top' | 'middle' | 'baseline' | number;
|
|
1381
|
+
toXPosition?: 'left' | 'center' | 'right' | number;
|
|
1382
|
+
toYPosition?: 'bottom' | 'top' | 'middle' | 'baseline' | number;
|
|
1383
|
+
toXAlign?: 'left' | 'center' | 'right' | number;
|
|
1384
|
+
toYAlign?: 'bottom' | 'top' | 'middle' | 'baseline' | number;
|
|
1385
|
+
fullBoundsContent?: boolean;
|
|
1386
|
+
useFullBounds?: boolean;
|
|
1387
|
+
} | [
|
|
1388
|
+
(string | null | undefined),
|
|
1389
|
+
(TypeEquationPhrase | null | undefined),
|
|
1390
|
+
(TypeEquationPhrase | null | undefined),
|
|
1391
|
+
(TypeEquationPhrase | null | undefined),
|
|
1392
|
+
(boolean | null | undefined),
|
|
1393
|
+
(number | null | undefined),
|
|
1394
|
+
(number | null | undefined),
|
|
1395
|
+
(number | null | undefined),
|
|
1396
|
+
(number | null | undefined),
|
|
1397
|
+
(number | null | undefined),
|
|
1398
|
+
(number | null | undefined),
|
|
1399
|
+
(number | null | undefined),
|
|
1400
|
+
(number | null | undefined),
|
|
1401
|
+
(TypeParsablePoint | null | undefined),
|
|
1402
|
+
(TypeParsablePoint | null | undefined),
|
|
1403
|
+
('side' | 'topBottom' | 'topBottomCenter' | null | undefined),
|
|
1404
|
+
(boolean | null | undefined),
|
|
1405
|
+
('left' | 'center' | 'right' | number | null | undefined),
|
|
1406
|
+
('bottom' | 'top' | 'middle' | 'baseline' | number | null | undefined),
|
|
1407
|
+
('left' | 'center' | 'right' | number | null | undefined),
|
|
1408
|
+
('bottom' | 'top' | 'middle' | 'baseline' | number | null | undefined),
|
|
1409
|
+
('left' | 'center' | 'right' | number | null | undefined),
|
|
1410
|
+
('bottom' | 'top' | 'middle' | 'baseline' | number | null | undefined),
|
|
1411
|
+
('left' | 'center' | 'right' | number | null | undefined),
|
|
1412
|
+
('bottom' | 'top' | 'middle' | 'baseline' | number | null | undefined),
|
|
1413
|
+
(boolean | null | undefined),
|
|
1414
|
+
(boolean | null | undefined)
|
|
1415
|
+
];
|
|
1416
|
+
/**
|
|
1417
|
+
* Equation sum of
|
|
1418
|
+
*
|
|
1419
|
+
* 
|
|
1420
|
+
*
|
|
1421
|
+
* Place an equation phrase in a sum of operation with the symbol
|
|
1422
|
+
* {@link EQN_SumSymbol}.
|
|
1423
|
+
*
|
|
1424
|
+
* Options can be an object, or an array in the property order below
|
|
1425
|
+
*
|
|
1426
|
+
* @property {string} symbol
|
|
1427
|
+
* @property {TypeEquationPhrase} content
|
|
1428
|
+
* @property {TypeEquationPhrase} [from]
|
|
1429
|
+
* @property {TypeEquationPhrase} [to]
|
|
1430
|
+
* @property {boolean} [inSize] `false` excludes sum of operator from size of
|
|
1431
|
+
* resulting phrase (`true`)
|
|
1432
|
+
* @property {number} [space] horiztonaly space between symbol and content (`0.1`)
|
|
1433
|
+
* @property {number} [topSpace] space symbol extends above content top (`0.07`)
|
|
1434
|
+
* @property {number} [bottomSpace] space symbol extends below content bottom (`0.07`)
|
|
1435
|
+
* @property {number} [height] force height of symbol overwriting `topSpace`
|
|
1436
|
+
* @property {number} [yOffset] offset of symbol in y (`0`)
|
|
1437
|
+
* @property {number} [scale] content scale (`1`)
|
|
1438
|
+
* @property {number} [fromScale] scale of *from* phrase (`0.5`)
|
|
1439
|
+
* @property {number} [toScale] scale of *to* phrase (`0.5`)
|
|
1440
|
+
* @property {number} [fromSpace] space between symbol and `from` phrase
|
|
1441
|
+
* (`0.04`)
|
|
1442
|
+
* @property {number} [toSpace] space between symbol and `to` phrase (`0.04`)
|
|
1443
|
+
* @property {TypeParsablePoint} [fromOffset] offset of `from` phrase (`[0, 0]`)
|
|
1444
|
+
* @property {TypeParsablePoint} [toOffset] offset of `to` phrase (`[0, 0]`)
|
|
1445
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
1446
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
1447
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
1448
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
1449
|
+
* brackets only surround a portion of the content (`false`)
|
|
1450
|
+
*
|
|
1451
|
+
* @see To test examples, append them to the
|
|
1452
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1453
|
+
*
|
|
1454
|
+
* @example
|
|
1455
|
+
* // Simple
|
|
1456
|
+
* figure.add({
|
|
1457
|
+
* name: 'eqn',
|
|
1458
|
+
* make: 'equation',
|
|
1459
|
+
* forms: {
|
|
1460
|
+
* 1: { sumOf: ['sum', 'x', 'b', 'a'] },
|
|
1461
|
+
* },
|
|
1462
|
+
* });
|
|
1463
|
+
* figure.elements._eqn.showForm('1');
|
|
1464
|
+
*
|
|
1465
|
+
* @example
|
|
1466
|
+
* // Example showing different options
|
|
1467
|
+
* figure.add({
|
|
1468
|
+
* name: 'eqn',
|
|
1469
|
+
* make: 'equation',
|
|
1470
|
+
* elements: {
|
|
1471
|
+
* s: { symbol: 'sum', draw: 'dynamic' },
|
|
1472
|
+
* inf: '\u221e',
|
|
1473
|
+
* },
|
|
1474
|
+
* forms: {
|
|
1475
|
+
* // Object form
|
|
1476
|
+
* 1: {
|
|
1477
|
+
* sumOf: {
|
|
1478
|
+
* symbol: 's',
|
|
1479
|
+
* content: [{ sup: ['x', 'n'] }],
|
|
1480
|
+
* from: ['n_1', ' ', '=', ' ', '_0'],
|
|
1481
|
+
* to: '_10',
|
|
1482
|
+
* },
|
|
1483
|
+
* },
|
|
1484
|
+
* // Array form
|
|
1485
|
+
* 2: { sumOf: ['s', [{ sup: ['x', 'm'] }], 'm_1', null]},
|
|
1486
|
+
* // Styling with options
|
|
1487
|
+
* 3: {
|
|
1488
|
+
* sumOf: {
|
|
1489
|
+
* symbol: 's',
|
|
1490
|
+
* content: { frac: [['x', ' ', '+', ' ', 'm'], 'vinculum', 'a'] },
|
|
1491
|
+
* from: ['m_1', ' ', '=', ' ', '_0'],
|
|
1492
|
+
* to: 'inf',
|
|
1493
|
+
* fromScale: 0.8,
|
|
1494
|
+
* toScale: 0.8,
|
|
1495
|
+
* },
|
|
1496
|
+
* },
|
|
1497
|
+
* },
|
|
1498
|
+
* formSeries: ['1', '2', '3'],
|
|
1499
|
+
* });
|
|
1500
|
+
* const eqn = figure.elements._eqn;
|
|
1501
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1502
|
+
* eqn.setTouchable();
|
|
1503
|
+
* eqn.showForm('1');
|
|
1504
|
+
* @interface
|
|
1505
|
+
* @group Equation Layout
|
|
1506
|
+
*/
|
|
1507
|
+
export type EQN_SumOf = {
|
|
1508
|
+
symbol?: string;
|
|
1509
|
+
content: TypeEquationPhrase;
|
|
1510
|
+
from?: TypeEquationPhrase;
|
|
1511
|
+
to?: TypeEquationPhrase;
|
|
1512
|
+
inSize?: boolean;
|
|
1513
|
+
space?: number;
|
|
1514
|
+
topSpace?: number;
|
|
1515
|
+
bottomSpace?: number;
|
|
1516
|
+
height?: number;
|
|
1517
|
+
yOffset?: number;
|
|
1518
|
+
scale?: number;
|
|
1519
|
+
fromScale?: number;
|
|
1520
|
+
toScale?: number;
|
|
1521
|
+
fromSpace?: number;
|
|
1522
|
+
toSpace?: number;
|
|
1523
|
+
fromOffset?: TypeParsablePoint;
|
|
1524
|
+
toOffset?: TypeParsablePoint;
|
|
1525
|
+
fullBoundsContent?: boolean;
|
|
1526
|
+
useFullBounds?: boolean;
|
|
1527
|
+
} | [
|
|
1528
|
+
(string | null | undefined),
|
|
1529
|
+
TypeEquationPhrase,
|
|
1530
|
+
(TypeEquationPhrase | null | undefined),
|
|
1531
|
+
(TypeEquationPhrase | null | undefined),
|
|
1532
|
+
(boolean | null | undefined),
|
|
1533
|
+
(number | null | undefined),
|
|
1534
|
+
(number | null | undefined),
|
|
1535
|
+
(number | null | undefined),
|
|
1536
|
+
(number | null | undefined),
|
|
1537
|
+
(number | null | undefined),
|
|
1538
|
+
(number | null | undefined),
|
|
1539
|
+
(number | null | undefined),
|
|
1540
|
+
(number | null | undefined),
|
|
1541
|
+
(number | null | undefined),
|
|
1542
|
+
(number | null | undefined),
|
|
1543
|
+
(TypeParsablePoint | null | undefined),
|
|
1544
|
+
(TypeParsablePoint | null | undefined),
|
|
1545
|
+
(boolean | null | undefined),
|
|
1546
|
+
(boolean | null | undefined)
|
|
1547
|
+
];
|
|
1548
|
+
/**
|
|
1549
|
+
* Place an equation phrase in a product of operation with the symbol
|
|
1550
|
+
* {@link EQN_ProdSymbol}.
|
|
1551
|
+
*
|
|
1552
|
+
* 
|
|
1553
|
+
*
|
|
1554
|
+
* Place an equation phrase in a product of operation
|
|
1555
|
+
*
|
|
1556
|
+
* Options can be an object, or an array in the property order below
|
|
1557
|
+
*
|
|
1558
|
+
* @property {string} symbol
|
|
1559
|
+
* @property {TypeEquationPhrase} content
|
|
1560
|
+
* @property {TypeEquationPhrase} [from]
|
|
1561
|
+
* @property {TypeEquationPhrase} [to]
|
|
1562
|
+
* @property {boolean} [inSize] `false` excludes product of operator from size of
|
|
1563
|
+
* resulting phrase (`true`)
|
|
1564
|
+
* @property {number} [space] horiztonaly space between symbol and content (`0.1`)
|
|
1565
|
+
* @property {number} [topSpace] space symbol extends above content top (`0.07`)
|
|
1566
|
+
* @property {number} [bottomSpace] space symbol extends below content bottom (`0.07`)
|
|
1567
|
+
* @property {number} [height] force height of symbol overwriting `topSpace`
|
|
1568
|
+
* @property {number} [yOffset] offset of symbol in y (`0`)
|
|
1569
|
+
* @property {number} [scale] content scale (`1`)
|
|
1570
|
+
* @property {number} [fromScale] scale of *from* phrase (`0.5`)
|
|
1571
|
+
* @property {number} [toScale] scale of *to* phrase (`0.5`)
|
|
1572
|
+
* @property {number} [fromSpace] space between symbol and `from` phrase
|
|
1573
|
+
* (`0.04`)
|
|
1574
|
+
* @property {number} [toSpace] space between symbol and `to` phrase (`0.04`)
|
|
1575
|
+
* @property {TypeParsablePoint} [fromOffset] offset of `from` phrase (`[0, 0]`)
|
|
1576
|
+
* @property {TypeParsablePoint} [toOffset] offset of `to` phrase (`[0, 0]`)
|
|
1577
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
1578
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
1579
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
1580
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
1581
|
+
* brackets only surround a portion of the content (`false`)
|
|
1582
|
+
*
|
|
1583
|
+
* @see To test examples, append them to the
|
|
1584
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1585
|
+
*
|
|
1586
|
+
* @example
|
|
1587
|
+
* // Simple
|
|
1588
|
+
* figure.add({
|
|
1589
|
+
* name: 'eqn',
|
|
1590
|
+
* make: 'equation',
|
|
1591
|
+
* forms: {
|
|
1592
|
+
* 1: { prodOf: ['prod', 'x', 'b', 'a'] },
|
|
1593
|
+
* },
|
|
1594
|
+
* });
|
|
1595
|
+
* figure.elements._eqn.showForm('1');
|
|
1596
|
+
*
|
|
1597
|
+
* @example
|
|
1598
|
+
* // Example showing different options
|
|
1599
|
+
* figure.add({
|
|
1600
|
+
* name: 'eqn',
|
|
1601
|
+
* make: 'equation',
|
|
1602
|
+
* elements: {
|
|
1603
|
+
* p: { symbol: 'prod', draw: 'dynamic' },
|
|
1604
|
+
* inf: '\u221e',
|
|
1605
|
+
* },
|
|
1606
|
+
* forms: {
|
|
1607
|
+
* // Object form
|
|
1608
|
+
* 1: {
|
|
1609
|
+
* prodOf: {
|
|
1610
|
+
* symbol: 'p',
|
|
1611
|
+
* content: [{ sup: ['x', 'n'] }],
|
|
1612
|
+
* from: ['n_1', ' ', '=', ' ', '_0'],
|
|
1613
|
+
* to: '_10',
|
|
1614
|
+
* },
|
|
1615
|
+
* },
|
|
1616
|
+
* // Array form
|
|
1617
|
+
* 2: { prodOf: ['p', [{ sup: ['x', 'm'] }], 'm_1', null]},
|
|
1618
|
+
* // Styling with options
|
|
1619
|
+
* 3: {
|
|
1620
|
+
* prodOf: {
|
|
1621
|
+
* symbol: 'p',
|
|
1622
|
+
* content: { frac: [['x', ' ', '+', ' ', 'm'], 'vinculum', 'a'] },
|
|
1623
|
+
* from: ['m_1', ' ', '=', ' ', '_0'],
|
|
1624
|
+
* to: 'inf',
|
|
1625
|
+
* fromScale: 0.8,
|
|
1626
|
+
* toScale: 0.8,
|
|
1627
|
+
* },
|
|
1628
|
+
* },
|
|
1629
|
+
* },
|
|
1630
|
+
* formSeries: ['1', '2', '3'],
|
|
1631
|
+
* });
|
|
1632
|
+
* const eqn = figure.elements._eqn;
|
|
1633
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1634
|
+
* eqn.setTouchable();
|
|
1635
|
+
* eqn.showForm('1');
|
|
1636
|
+
* @interface
|
|
1637
|
+
* @group Equation Layout
|
|
1638
|
+
*/
|
|
1639
|
+
export type EQN_ProdOf = {
|
|
1640
|
+
symbol?: string;
|
|
1641
|
+
content: TypeEquationPhrase;
|
|
1642
|
+
from?: TypeEquationPhrase;
|
|
1643
|
+
to?: TypeEquationPhrase;
|
|
1644
|
+
inSize?: boolean;
|
|
1645
|
+
space?: number;
|
|
1646
|
+
topSpace?: number;
|
|
1647
|
+
bottomSpace?: number;
|
|
1648
|
+
height?: number;
|
|
1649
|
+
yOffset?: number;
|
|
1650
|
+
scale?: number;
|
|
1651
|
+
fromScale?: number;
|
|
1652
|
+
toScale?: number;
|
|
1653
|
+
fromSpace?: number;
|
|
1654
|
+
toSpace?: number;
|
|
1655
|
+
fromOffset?: TypeParsablePoint;
|
|
1656
|
+
toOffset?: TypeParsablePoint;
|
|
1657
|
+
fullBoundsContent?: boolean;
|
|
1658
|
+
useFullBounds?: boolean;
|
|
1659
|
+
} | [
|
|
1660
|
+
(string | null | undefined),
|
|
1661
|
+
TypeEquationPhrase,
|
|
1662
|
+
(TypeEquationPhrase | null | undefined),
|
|
1663
|
+
(TypeEquationPhrase | null | undefined),
|
|
1664
|
+
(boolean | null | undefined),
|
|
1665
|
+
(number | null | undefined),
|
|
1666
|
+
(number | null | undefined),
|
|
1667
|
+
(number | null | undefined),
|
|
1668
|
+
(number | null | undefined),
|
|
1669
|
+
(number | null | undefined),
|
|
1670
|
+
(number | null | undefined),
|
|
1671
|
+
(number | null | undefined),
|
|
1672
|
+
(number | null | undefined),
|
|
1673
|
+
(number | null | undefined),
|
|
1674
|
+
(number | null | undefined),
|
|
1675
|
+
(TypeParsablePoint | null | undefined),
|
|
1676
|
+
(TypeParsablePoint | null | undefined),
|
|
1677
|
+
(boolean | null | undefined),
|
|
1678
|
+
(boolean | null | undefined)
|
|
1679
|
+
];
|
|
1680
|
+
/**
|
|
1681
|
+
* Equation subscript
|
|
1682
|
+
*
|
|
1683
|
+
* 
|
|
1684
|
+
*
|
|
1685
|
+
* Options can be an object, or an array in the property order below
|
|
1686
|
+
*
|
|
1687
|
+
* @property {TypeEquationPhrase} content
|
|
1688
|
+
* @property {TypeEquationPhrase} subscript
|
|
1689
|
+
* @property {number} [scale] scale of subscript (`0.5`)
|
|
1690
|
+
* @property {TypeParsablePoint} [offset] offset of subscript (`[0, 0]`)
|
|
1691
|
+
* @property {boolean} [inSize] `true` excludes subscript from size of
|
|
1692
|
+
* resulting phrase (`true`)
|
|
1693
|
+
*
|
|
1694
|
+
* @see To test examples, append them to the
|
|
1695
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1696
|
+
*
|
|
1697
|
+
* @example
|
|
1698
|
+
* //Simple
|
|
1699
|
+
* figure.add({
|
|
1700
|
+
* name: 'eqn',
|
|
1701
|
+
* make: 'equation',
|
|
1702
|
+
* forms: {
|
|
1703
|
+
* 1: { sub: ['x', '_2'] },
|
|
1704
|
+
* },
|
|
1705
|
+
* });
|
|
1706
|
+
* figure.elements._eqn.showForm('1');
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* // Example showing different subscript options
|
|
1710
|
+
* figure.add({
|
|
1711
|
+
* name: 'eqn',
|
|
1712
|
+
* make: 'equation',
|
|
1713
|
+
* forms: {
|
|
1714
|
+
* // Object form
|
|
1715
|
+
* 1: {
|
|
1716
|
+
* sub: {
|
|
1717
|
+
* content: 'x',
|
|
1718
|
+
* subscript: 'b',
|
|
1719
|
+
* },
|
|
1720
|
+
* },
|
|
1721
|
+
* // Array form
|
|
1722
|
+
* 2: [{ sub: ['x', 'b'] }, ' ', { sub: ['y', 'd'] }],
|
|
1723
|
+
* 3: { sub: ['x', ['b', ' ', '+', ' ', 'd']] },
|
|
1724
|
+
* // Subscript offset to adjust layout to keep animation smooth
|
|
1725
|
+
* 4: {
|
|
1726
|
+
* sub: {
|
|
1727
|
+
* content: 'x',
|
|
1728
|
+
* subscript: { frac: [['b', ' ', '+', ' ', 'd'], 'vinculum', '_2'] },
|
|
1729
|
+
* offset: [-0.025, -0.02],
|
|
1730
|
+
* },
|
|
1731
|
+
* },
|
|
1732
|
+
* },
|
|
1733
|
+
* formSeries: ['1', '2', '3', '4'],
|
|
1734
|
+
* });
|
|
1735
|
+
* const eqn = figure.elements._eqn;
|
|
1736
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1737
|
+
* eqn.setTouchable();
|
|
1738
|
+
* eqn.showForm('1');
|
|
1739
|
+
* @interface
|
|
1740
|
+
* @group Equation Layout
|
|
1741
|
+
*/
|
|
1742
|
+
export type EQN_Subscript = {
|
|
1743
|
+
content: TypeEquationPhrase;
|
|
1744
|
+
subscript: TypeEquationPhrase;
|
|
1745
|
+
scale?: number;
|
|
1746
|
+
offset?: TypeParsablePoint;
|
|
1747
|
+
inSize: boolean;
|
|
1748
|
+
} | [
|
|
1749
|
+
TypeEquationPhrase,
|
|
1750
|
+
TypeEquationPhrase,
|
|
1751
|
+
(number | null | undefined),
|
|
1752
|
+
(TypeParsablePoint | null | undefined),
|
|
1753
|
+
(boolean | null | undefined)
|
|
1754
|
+
];
|
|
1755
|
+
/**
|
|
1756
|
+
* Equation superscript
|
|
1757
|
+
*
|
|
1758
|
+
* 
|
|
1759
|
+
*
|
|
1760
|
+
* Options can be an object, or an array in the property order below
|
|
1761
|
+
*
|
|
1762
|
+
* @property {TypeEquationPhrase} content
|
|
1763
|
+
* @property {TypeEquationPhrase} superscript
|
|
1764
|
+
* @property {number} [scale] scale of superscript (`0.5`)
|
|
1765
|
+
* @property {TypeParsablePoint} [offset] offset of superscript (`[0, 0]`)
|
|
1766
|
+
* @property {boolean} [inSize] `true` excludes superscript from size of
|
|
1767
|
+
* resulting phrase (`true`)
|
|
1768
|
+
*
|
|
1769
|
+
* @see To test examples, append them to the
|
|
1770
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1771
|
+
*
|
|
1772
|
+
* @example
|
|
1773
|
+
* // Simple
|
|
1774
|
+
* figure.add({
|
|
1775
|
+
* name: 'eqn',
|
|
1776
|
+
* make: 'equation',
|
|
1777
|
+
* forms: {
|
|
1778
|
+
* 1: { sup: ['e', 'x'] },
|
|
1779
|
+
* },
|
|
1780
|
+
* });
|
|
1781
|
+
* figure.elements._eqn.showForm('1');
|
|
1782
|
+
*
|
|
1783
|
+
* @example
|
|
1784
|
+
* // Examples of superscript animations
|
|
1785
|
+
* figure.add({
|
|
1786
|
+
* name: 'eqn',
|
|
1787
|
+
* make: 'equation',
|
|
1788
|
+
* forms: {
|
|
1789
|
+
* // Object form
|
|
1790
|
+
* 1: {
|
|
1791
|
+
* sup: {
|
|
1792
|
+
* content: 'e',
|
|
1793
|
+
* superscript: 'x',
|
|
1794
|
+
* },
|
|
1795
|
+
* },
|
|
1796
|
+
* // Array form
|
|
1797
|
+
* 2: [{ sup: ['e', 'x'] }, ' ', { sup: ['e_1', 'y'] }],
|
|
1798
|
+
* 3: { sup: ['e', ['x', ' ', '+', ' ', 'y']] },
|
|
1799
|
+
* },
|
|
1800
|
+
* formSeries: ['1', '2', '3'],
|
|
1801
|
+
* });
|
|
1802
|
+
* const eqn = figure.elements._eqn;
|
|
1803
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1804
|
+
* eqn.setTouchable();
|
|
1805
|
+
* eqn.showForm('1');
|
|
1806
|
+
* @interface
|
|
1807
|
+
* @group Equation Layout
|
|
1808
|
+
*/
|
|
1809
|
+
export type EQN_Superscript = {
|
|
1810
|
+
content: TypeEquationPhrase;
|
|
1811
|
+
superscript: TypeEquationPhrase;
|
|
1812
|
+
scale?: number;
|
|
1813
|
+
offset?: TypeParsablePoint;
|
|
1814
|
+
inSize: boolean;
|
|
1815
|
+
} | [
|
|
1816
|
+
TypeEquationPhrase,
|
|
1817
|
+
TypeEquationPhrase,
|
|
1818
|
+
(number | null | undefined),
|
|
1819
|
+
(TypeParsablePoint | null | undefined),
|
|
1820
|
+
(boolean | null | undefined)
|
|
1821
|
+
];
|
|
1822
|
+
/**
|
|
1823
|
+
* Equation superscript and subscript
|
|
1824
|
+
*
|
|
1825
|
+
* 
|
|
1826
|
+
*
|
|
1827
|
+
* Options can be an object, or an array in the property order below
|
|
1828
|
+
*
|
|
1829
|
+
* @property {TypeEquationPhrase} content
|
|
1830
|
+
* @property {TypeEquationPhrase} superscript
|
|
1831
|
+
* @property {TypeEquationPhrase} subscript
|
|
1832
|
+
* @property {number} [scale] scale of superscript (`0.5`)
|
|
1833
|
+
* @property {TypeParsablePoint} [superscriptOffset] offset of superscript (`[0, 0]`)
|
|
1834
|
+
* @property {TypeParsablePoint} [subscriptOffset] offset of subscript (`[0, 0]`)
|
|
1835
|
+
* @property {boolean} [inSize] `true` excludes superscript from size of
|
|
1836
|
+
* resulting phrase (`true`)
|
|
1837
|
+
*
|
|
1838
|
+
* @see To test examples, append them to the
|
|
1839
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1840
|
+
*
|
|
1841
|
+
* @example
|
|
1842
|
+
* // Simple
|
|
1843
|
+
* figure.add({
|
|
1844
|
+
* make: 'equation',
|
|
1845
|
+
* forms: {
|
|
1846
|
+
* 1: { supSub: ['x', 'b', 'a'] },
|
|
1847
|
+
* },
|
|
1848
|
+
* });
|
|
1849
|
+
*
|
|
1850
|
+
* @example
|
|
1851
|
+
* // Example showing different super-sub script options
|
|
1852
|
+
* figure.add({
|
|
1853
|
+
* name: 'eqn',
|
|
1854
|
+
* make: 'equation',
|
|
1855
|
+
* forms: {
|
|
1856
|
+
* // Object form
|
|
1857
|
+
* 1: {
|
|
1858
|
+
* supSub: {
|
|
1859
|
+
* content: 'x',
|
|
1860
|
+
* superscript: 'b',
|
|
1861
|
+
* subscript: 'a',
|
|
1862
|
+
* },
|
|
1863
|
+
* },
|
|
1864
|
+
* // Array form
|
|
1865
|
+
* 2: [{ supSub: ['x', 'b', 'a'] }, ' ', { supSub: ['x_1', 'c', 'a_1'] }],
|
|
1866
|
+
* 3: { supSub: ['x', ['b', ' ', '+', ' ', 'c'], 'a'] },
|
|
1867
|
+
* },
|
|
1868
|
+
* formSeries: ['1', '2', '3'],
|
|
1869
|
+
* });
|
|
1870
|
+
* const eqn = figure.elements._eqn;
|
|
1871
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1872
|
+
* eqn.setTouchable();
|
|
1873
|
+
* @interface
|
|
1874
|
+
* @group Equation Layout
|
|
1875
|
+
*/
|
|
1876
|
+
export type EQN_SuperscriptSubscript = {
|
|
1877
|
+
content: TypeEquationPhrase;
|
|
1878
|
+
subscript: TypeEquationPhrase;
|
|
1879
|
+
superscript: TypeEquationPhrase;
|
|
1880
|
+
scale?: number;
|
|
1881
|
+
superscriptOffset?: TypeParsablePoint;
|
|
1882
|
+
subscriptOffset?: TypeParsablePoint;
|
|
1883
|
+
inSize?: boolean;
|
|
1884
|
+
} | [
|
|
1885
|
+
TypeEquationPhrase,
|
|
1886
|
+
TypeEquationPhrase,
|
|
1887
|
+
TypeEquationPhrase,
|
|
1888
|
+
(number | null | undefined),
|
|
1889
|
+
(TypeParsablePoint | null | undefined),
|
|
1890
|
+
(TypeParsablePoint | null | undefined),
|
|
1891
|
+
(boolean | null | undefined)
|
|
1892
|
+
];
|
|
1893
|
+
/**
|
|
1894
|
+
* Equation comment options used with `topComment` and `bottomComment`
|
|
1895
|
+
* functions.
|
|
1896
|
+
*
|
|
1897
|
+
* 
|
|
1898
|
+
*
|
|
1899
|
+
* A symbol between the content and comment is optional.
|
|
1900
|
+
*
|
|
1901
|
+
* Options can be an object, or an array in the property order below
|
|
1902
|
+
*
|
|
1903
|
+
* @property {TypeEquationPhrase} content
|
|
1904
|
+
* @property {TypeEquationPhrase} comment
|
|
1905
|
+
* @property {string} [symbol] optional symbol between content and comment
|
|
1906
|
+
* @property {number} [contentSpace] space from content to symbol (`0.03`)
|
|
1907
|
+
* @property {number} [commentSpace] space from symbol to comment (`0.03`)
|
|
1908
|
+
* @property {number} [contentLineSpace] space between a line symbol and
|
|
1909
|
+
* content (`0.03`)
|
|
1910
|
+
* @property {number} [commentLineSpace] space between a line symbol and
|
|
1911
|
+
* comment (`0.03`)
|
|
1912
|
+
* @property {number} [scale] comment scale (`0.6`)
|
|
1913
|
+
* @property {boolean} [inSize] `false` excludes the symbol and comment from
|
|
1914
|
+
* thre resulting size of the equation phrase (`true`)
|
|
1915
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
1916
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
1917
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
1918
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
1919
|
+
* brackets only surround a portion of the content (`false`)
|
|
1920
|
+
*
|
|
1921
|
+
* @see To test examples, append them to the
|
|
1922
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
1923
|
+
*
|
|
1924
|
+
* @example
|
|
1925
|
+
* // Simple
|
|
1926
|
+
* figure.add({
|
|
1927
|
+
* name: 'eqn',
|
|
1928
|
+
* make: 'equation',
|
|
1929
|
+
* forms: {
|
|
1930
|
+
* 1: { topComment: ['radius', 'r = 1'] },
|
|
1931
|
+
* },
|
|
1932
|
+
* });
|
|
1933
|
+
* figure.elements._eqn.showForm('1');
|
|
1934
|
+
*
|
|
1935
|
+
* @example
|
|
1936
|
+
* // Some different comment examples
|
|
1937
|
+
* figure.add({
|
|
1938
|
+
* name: 'eqn',
|
|
1939
|
+
* make: 'equation',
|
|
1940
|
+
* elements: {
|
|
1941
|
+
* bBkt: { symbol: 'bracket', side: 'bottom' },
|
|
1942
|
+
* tBrc: { symbol: 'brace', side: 'top' },
|
|
1943
|
+
* bSqr: { symbol: 'squareBracket', side: 'bottom' },
|
|
1944
|
+
* },
|
|
1945
|
+
* forms: {
|
|
1946
|
+
* // Array equation
|
|
1947
|
+
* 1: { topComment: ['a \u00d7 b \u00d7 c', 'b = 1, c = 1', 'tBrc'] },
|
|
1948
|
+
* // Object definition
|
|
1949
|
+
* 2: {
|
|
1950
|
+
* bottomComment: {
|
|
1951
|
+
* content: 'a \u00d7 b \u00d7 c',
|
|
1952
|
+
* symbol: 'bBkt',
|
|
1953
|
+
* comment: 'b = 1, c = 1',
|
|
1954
|
+
* },
|
|
1955
|
+
* },
|
|
1956
|
+
* // Additional options for layout
|
|
1957
|
+
* 3: {
|
|
1958
|
+
* bottomComment: {
|
|
1959
|
+
* content: 'a \u00d7 b \u00d7 c',
|
|
1960
|
+
* symbol: 'bSqr',
|
|
1961
|
+
* comment: 'b = 1, c = 1',
|
|
1962
|
+
* contentSpace: 0.1,
|
|
1963
|
+
* commentSpace: 0.1,
|
|
1964
|
+
* scale: 0.7,
|
|
1965
|
+
* },
|
|
1966
|
+
* },
|
|
1967
|
+
* // Just comment
|
|
1968
|
+
* 4: {
|
|
1969
|
+
* bottomComment: {
|
|
1970
|
+
* content: 'a \u00d7 b \u00d7 c',
|
|
1971
|
+
* comment: 'for a > 3',
|
|
1972
|
+
* },
|
|
1973
|
+
* },
|
|
1974
|
+
* },
|
|
1975
|
+
* formSeries: ['1', '2', '3', '4']
|
|
1976
|
+
* });
|
|
1977
|
+
* const eqn = figure.elements._eqn;
|
|
1978
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
1979
|
+
* eqn.setTouchable();
|
|
1980
|
+
* eqn.showForm('1');
|
|
1981
|
+
* @interface
|
|
1982
|
+
* @group Equation Layout
|
|
1983
|
+
*/
|
|
1984
|
+
export type EQN_Comment = {
|
|
1985
|
+
content: TypeEquationPhrase;
|
|
1986
|
+
comment: TypeEquationPhrase;
|
|
1987
|
+
symbol?: string;
|
|
1988
|
+
contentSpace?: number;
|
|
1989
|
+
commentSpace?: number;
|
|
1990
|
+
contentLineSpace?: number;
|
|
1991
|
+
commentLineSpace?: number;
|
|
1992
|
+
scale?: number;
|
|
1993
|
+
inSize?: boolean;
|
|
1994
|
+
fullContentBounds?: boolean;
|
|
1995
|
+
useFullBounds?: boolean;
|
|
1996
|
+
} | [
|
|
1997
|
+
TypeEquationPhrase,
|
|
1998
|
+
TypeEquationPhrase,
|
|
1999
|
+
string,
|
|
2000
|
+
(number | null | undefined),
|
|
2001
|
+
(number | null | undefined),
|
|
2002
|
+
(number | null | undefined),
|
|
2003
|
+
(boolean | null | undefined),
|
|
2004
|
+
(boolean | null | undefined),
|
|
2005
|
+
(boolean | null | undefined)
|
|
2006
|
+
];
|
|
2007
|
+
/**
|
|
2008
|
+
* Equation strike with comment options used with `topStrike` and `bottomStrike`
|
|
2009
|
+
* functions.
|
|
2010
|
+
*
|
|
2011
|
+
* 
|
|
2012
|
+
*
|
|
2013
|
+
* Use with {@link EQN_Strike} symbol.
|
|
2014
|
+
*
|
|
2015
|
+
* Options can be an object, or an array in the property order below
|
|
2016
|
+
*
|
|
2017
|
+
* @property {TypeEquationPhrase} content
|
|
2018
|
+
* @property {string} symbol strike symbol
|
|
2019
|
+
* @property {TypeEquationPhrase} comment
|
|
2020
|
+
* @property {boolean} [inSize] `false` excludes the symbol and comment from
|
|
2021
|
+
* thre resulting size of the equation phrase (`true`)
|
|
2022
|
+
* @property {number} [space] top, right, bottom and left extension of symbol
|
|
2023
|
+
* beyond content (`0.03`)
|
|
2024
|
+
* @property {number} [scale] comment scale (`0.6`)
|
|
2025
|
+
* @property {number} [commentSpace] space from symbol to comment (`0.03`)
|
|
2026
|
+
*
|
|
2027
|
+
* @see To test examples, append them to the
|
|
2028
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
2029
|
+
*
|
|
2030
|
+
* @example
|
|
2031
|
+
* // Simple
|
|
2032
|
+
* figure.add({
|
|
2033
|
+
* name: 'eqn',
|
|
2034
|
+
* make: 'equation',
|
|
2035
|
+
* elements: {
|
|
2036
|
+
* x: { symbol: 'strike', color: [0.6, 0.6, 0.6, 1] },
|
|
2037
|
+
* },
|
|
2038
|
+
* forms: {
|
|
2039
|
+
* 1: { topStrike: ['radius', 'x', 'radius = 1'] },
|
|
2040
|
+
* },
|
|
2041
|
+
* });
|
|
2042
|
+
* figure.elements._eqn.showForm('1');
|
|
2043
|
+
*
|
|
2044
|
+
* @example
|
|
2045
|
+
* // Some different strike examples
|
|
2046
|
+
* figure.add({
|
|
2047
|
+
* name: 'eqn',
|
|
2048
|
+
* make: 'equation',
|
|
2049
|
+
* elements: {
|
|
2050
|
+
* s1: { symbol: 'strike', style: 'forward', color: [0.6, 0.6, 0.6, 1] },
|
|
2051
|
+
* },
|
|
2052
|
+
* forms: {
|
|
2053
|
+
* // Array equation
|
|
2054
|
+
* 1: { topStrike: ['radius', 's1', 'radius = 1'] },
|
|
2055
|
+
* // Object definition
|
|
2056
|
+
* 2: {
|
|
2057
|
+
* bottomStrike: {
|
|
2058
|
+
* content: 'radius',
|
|
2059
|
+
* symbol: 's1',
|
|
2060
|
+
* comment: 'radius = 1',
|
|
2061
|
+
* },
|
|
2062
|
+
* },
|
|
2063
|
+
* // Additional options for layout
|
|
2064
|
+
* 3: {
|
|
2065
|
+
* bottomStrike: {
|
|
2066
|
+
* content: 'radius',
|
|
2067
|
+
* comment: 'radius = 1',
|
|
2068
|
+
* symbol: 's1',
|
|
2069
|
+
* scale: 0.8,
|
|
2070
|
+
* space: 0.1,
|
|
2071
|
+
* commentSpace: 0.01,
|
|
2072
|
+
* },
|
|
2073
|
+
* },
|
|
2074
|
+
* },
|
|
2075
|
+
* formSeries: ['1', '2', '3']
|
|
2076
|
+
* });
|
|
2077
|
+
* const eqn = figure.elements._eqn;
|
|
2078
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
2079
|
+
* eqn.setTouchable();
|
|
2080
|
+
* eqn.showForm('1');
|
|
2081
|
+
* @interface
|
|
2082
|
+
* @group Equation Layout
|
|
2083
|
+
*/
|
|
2084
|
+
export type EQN_StrikeComment = {
|
|
2085
|
+
content?: TypeEquationPhrase;
|
|
2086
|
+
symbol?: string;
|
|
2087
|
+
comment?: TypeEquationPhrase;
|
|
2088
|
+
inSize?: boolean;
|
|
2089
|
+
space?: number;
|
|
2090
|
+
scale?: number;
|
|
2091
|
+
commentSpace?: number;
|
|
2092
|
+
} | [
|
|
2093
|
+
(TypeEquationPhrase | null | undefined),
|
|
2094
|
+
(string | null | undefined),
|
|
2095
|
+
(TypeEquationPhrase | null | undefined),
|
|
2096
|
+
(boolean | null | undefined),
|
|
2097
|
+
(number | null | undefined),
|
|
2098
|
+
(number | null | undefined),
|
|
2099
|
+
(number | null | undefined)
|
|
2100
|
+
];
|
|
2101
|
+
/**
|
|
2102
|
+
* Equation padding options.
|
|
2103
|
+
*
|
|
2104
|
+
* 
|
|
2105
|
+
*
|
|
2106
|
+
* Pads the size of the equation phrase with space.
|
|
2107
|
+
*
|
|
2108
|
+
* Options can be an object, or an array in the property order below
|
|
2109
|
+
*
|
|
2110
|
+
* @property {TypeEquationPhrase} content
|
|
2111
|
+
* @property {number} [top] (`0`)
|
|
2112
|
+
* @property {number} [right] (`0`)
|
|
2113
|
+
* @property {number} [bottom] (`0`)
|
|
2114
|
+
* @property {number} [left] (`0`)
|
|
2115
|
+
*
|
|
2116
|
+
* @see To test examples, append them to the
|
|
2117
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
2118
|
+
*
|
|
2119
|
+
* @example
|
|
2120
|
+
* // Simple
|
|
2121
|
+
* figure.add({
|
|
2122
|
+
* name: 'eqn',
|
|
2123
|
+
* make: 'equation',
|
|
2124
|
+
* forms: {
|
|
2125
|
+
* 1: ['a', { pad: ['b', 0.1, 0.1, 0.1, 0.1] }, 'c'],
|
|
2126
|
+
* },
|
|
2127
|
+
* });
|
|
2128
|
+
* figure.elements._eqn.showForm('1');
|
|
2129
|
+
*
|
|
2130
|
+
* @example
|
|
2131
|
+
* // Some different padding examples
|
|
2132
|
+
* figure.add({
|
|
2133
|
+
* name: 'eqn',
|
|
2134
|
+
* make: 'equation',
|
|
2135
|
+
* forms: {
|
|
2136
|
+
* // No padding
|
|
2137
|
+
* 1: ['a', 'b', 'c'],
|
|
2138
|
+
* // Array form
|
|
2139
|
+
* 2: ['a', { pad: ['b', 0.1, 0.1, 0.1, 0.1] }, 'c'],
|
|
2140
|
+
* // Object form
|
|
2141
|
+
* 3: [
|
|
2142
|
+
* 'a',
|
|
2143
|
+
* {
|
|
2144
|
+
* pad: {
|
|
2145
|
+
* content: 'b',
|
|
2146
|
+
* left: 0.3,
|
|
2147
|
+
* right: 0.1,
|
|
2148
|
+
* },
|
|
2149
|
+
* },
|
|
2150
|
+
* 'c',
|
|
2151
|
+
* ],
|
|
2152
|
+
* },
|
|
2153
|
+
* formSeries: ['1', '2', '3'],
|
|
2154
|
+
* });
|
|
2155
|
+
* const eqn = figure.elements._eqn;
|
|
2156
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
2157
|
+
* eqn.setTouchable();
|
|
2158
|
+
* eqn.showForm('1');
|
|
2159
|
+
* @interface
|
|
2160
|
+
* @group Equation Layout
|
|
2161
|
+
*/
|
|
2162
|
+
export type EQN_Pad = {
|
|
2163
|
+
content: TypeEquationPhrase;
|
|
2164
|
+
top?: number;
|
|
2165
|
+
right?: number;
|
|
2166
|
+
bottom?: number;
|
|
2167
|
+
left?: number;
|
|
2168
|
+
} | [
|
|
2169
|
+
TypeEquationPhrase,
|
|
2170
|
+
(number | null | undefined),
|
|
2171
|
+
(number | null | undefined),
|
|
2172
|
+
(number | null | undefined),
|
|
2173
|
+
(number | null | undefined)
|
|
2174
|
+
];
|
|
2175
|
+
/**
|
|
2176
|
+
* Equation matrix
|
|
2177
|
+
*
|
|
2178
|
+
* 
|
|
2179
|
+
*
|
|
2180
|
+
* Options can be an object, or an array in the property order below
|
|
2181
|
+
*
|
|
2182
|
+
* @property {[number, number]} [order] (`[1, length-of-content]`)
|
|
2183
|
+
* @property {string} [left] left bracket symbol
|
|
2184
|
+
* @property {Array<TypeEquationPhrase>} [content] Array of equation phrases
|
|
2185
|
+
* where each element is a matrix element
|
|
2186
|
+
* @property {string} [right] right bracket symbol
|
|
2187
|
+
* @property {number} [scale] scale of matrix elements (`0.7`)
|
|
2188
|
+
* @property {'max' | 'min' | TypeParsablePoint} [fit] cell size -
|
|
2189
|
+
* `min` each cell is a rectangle with width equal to largest width in its
|
|
2190
|
+
* column, and height equal to largest height in its row - `max`
|
|
2191
|
+
* all cells are a square with dimension equal to the largest dimension of the
|
|
2192
|
+
* largest cell - `point` all cells are a rectangle with width as point.x and
|
|
2193
|
+
* height as point.y - note - `max` and `point` only work with
|
|
2194
|
+
* `yAlign`=`'middle'` (`'min'`)
|
|
2195
|
+
* @property {TypeParsablePoint} [space] space between each cell
|
|
2196
|
+
* (`[0.05, 0.05]`)
|
|
2197
|
+
* @property {'baseline' | 'middle'} [yAlign] align cells in a row with the
|
|
2198
|
+
* text baseline, or middle of the cell (`baseline`)
|
|
2199
|
+
* @property {EQN_Bracket} [brac] bracket options not including
|
|
2200
|
+
* the symbols (`{}`)
|
|
2201
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
2202
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
2203
|
+
*
|
|
2204
|
+
* @see To test examples, append them to the
|
|
2205
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
2206
|
+
*
|
|
2207
|
+
* @example
|
|
2208
|
+
* // Simple
|
|
2209
|
+
* figure.add({
|
|
2210
|
+
* name: 'eqn',
|
|
2211
|
+
* make: 'equation',
|
|
2212
|
+
* elements: {
|
|
2213
|
+
* lb: { symbol: 'squareBracket', side: 'left' },
|
|
2214
|
+
* rb: { symbol: 'squareBracket', side: 'right' },
|
|
2215
|
+
* },
|
|
2216
|
+
* forms: {
|
|
2217
|
+
* 1: { matrix: [[2, 2], 'lb', ['a', 'b', 'c', 'd'], 'rb'] },
|
|
2218
|
+
* },
|
|
2219
|
+
* });
|
|
2220
|
+
* figure.elements._eqn.showForm('1');
|
|
2221
|
+
*
|
|
2222
|
+
* @example
|
|
2223
|
+
* // Some different equation examples
|
|
2224
|
+
* figure.add({
|
|
2225
|
+
* name: 'eqn',
|
|
2226
|
+
* make: 'equation',
|
|
2227
|
+
* elements: {
|
|
2228
|
+
* lb: { symbol: 'squareBracket', side: 'left' },
|
|
2229
|
+
* rb: { symbol: 'squareBracket', side: 'right' },
|
|
2230
|
+
* v: { symbol: 'vinculum' },
|
|
2231
|
+
* },
|
|
2232
|
+
* phrases: {
|
|
2233
|
+
* f: { frac: ['a', 'v', 'b'] },
|
|
2234
|
+
* },
|
|
2235
|
+
* forms: {
|
|
2236
|
+
* // Array equation 2x2 matrix
|
|
2237
|
+
* 1: { matrix: [[2, 2], 'lb', ['a', 'b', 'c', 'd'], 'rb'] },
|
|
2238
|
+
* // Object definition vector
|
|
2239
|
+
* 2: {
|
|
2240
|
+
* matrix: {
|
|
2241
|
+
* content: ['a', 'b', 'c', 'd'],
|
|
2242
|
+
* left: 'lb',
|
|
2243
|
+
* right: 'rb',
|
|
2244
|
+
* order: [1, 4],
|
|
2245
|
+
* },
|
|
2246
|
+
* },
|
|
2247
|
+
* // Additional options for layout
|
|
2248
|
+
* 3: {
|
|
2249
|
+
* matrix: {
|
|
2250
|
+
* content: ['f', 'wxyz', 'c', 'd'],
|
|
2251
|
+
* symbol: 'bSqr',
|
|
2252
|
+
* left: 'lb',
|
|
2253
|
+
* right: 'rb',
|
|
2254
|
+
* order: [2, 2],
|
|
2255
|
+
* },
|
|
2256
|
+
* },
|
|
2257
|
+
* // Fixed size matrix cells
|
|
2258
|
+
* 4: {
|
|
2259
|
+
* matrix: {
|
|
2260
|
+
* content: ['f', 'wxyz', 'c', 'd'],
|
|
2261
|
+
* symbol: 'bSqr',
|
|
2262
|
+
* left: 'lb',
|
|
2263
|
+
* right: 'rb',
|
|
2264
|
+
* order: [2, 2],
|
|
2265
|
+
* fit: [0.2, 0.2],
|
|
2266
|
+
* yAlign: 'middle',
|
|
2267
|
+
* },
|
|
2268
|
+
* },
|
|
2269
|
+
* },
|
|
2270
|
+
* formSeries: ['1', '2', '3', '4']
|
|
2271
|
+
* });
|
|
2272
|
+
* const eqn = figure.elements._eqn;
|
|
2273
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
2274
|
+
* eqn.setTouchable();
|
|
2275
|
+
* eqn.showForm('1');
|
|
2276
|
+
* @interface
|
|
2277
|
+
* @group Equation Layout
|
|
2278
|
+
*/
|
|
2279
|
+
export type EQN_Matrix = {
|
|
2280
|
+
order?: [number, number];
|
|
2281
|
+
left?: string;
|
|
2282
|
+
content: TypeEquationPhrase;
|
|
2283
|
+
right?: string;
|
|
2284
|
+
scale?: number;
|
|
2285
|
+
fit?: 'max' | 'min' | TypeParsablePoint;
|
|
2286
|
+
space?: TypeParsablePoint;
|
|
2287
|
+
yAlign?: 'baseline' | 'middle';
|
|
2288
|
+
brac?: EQN_Bracket;
|
|
2289
|
+
fullContentBounds?: boolean;
|
|
2290
|
+
} | [
|
|
2291
|
+
([number, number] | null | undefined),
|
|
2292
|
+
(string | null | undefined),
|
|
2293
|
+
TypeEquationPhrase,
|
|
2294
|
+
(string | null | undefined),
|
|
2295
|
+
(number | null | undefined),
|
|
2296
|
+
('max' | 'min' | null | undefined),
|
|
2297
|
+
(TypeParsablePoint | null | undefined),
|
|
2298
|
+
('baseline' | 'middle' | null | undefined),
|
|
2299
|
+
(EQN_Bracket | null | undefined),
|
|
2300
|
+
(boolean | null | undefined)
|
|
2301
|
+
];
|
|
2302
|
+
/**
|
|
2303
|
+
* Single equation line definition
|
|
2304
|
+
*
|
|
2305
|
+
* Overrides default values of `baselineSpace` and `space` from
|
|
2306
|
+
* {@link EQN_Lines}.
|
|
2307
|
+
*
|
|
2308
|
+
* Use `justify` to define a specific element of the line to align the other
|
|
2309
|
+
* lines with.
|
|
2310
|
+
*
|
|
2311
|
+
* @property {TypeEquationPhrase} content Array of equation
|
|
2312
|
+
* phrases or equation line objects
|
|
2313
|
+
* @property {string} [justify] when {@link EQN_Lines}`.justify` is `'element'`,
|
|
2314
|
+
* use this property to define which element of the line to justify with. If
|
|
2315
|
+
* no element is specified, then left justification will be used.
|
|
2316
|
+
* @property {number} [space] default space between descent of previous line and
|
|
2317
|
+
* ascent of the this line (`0`).
|
|
2318
|
+
* @property {number | null} [baselineSpace] default space between baseline of
|
|
2319
|
+
* previous line and ascent of this line. If not `null` then will override
|
|
2320
|
+
* `space` (`null`).
|
|
2321
|
+
* @property {number} [offset] x Offset of line from justification position
|
|
2322
|
+
* (`0`)
|
|
2323
|
+
*
|
|
2324
|
+
* @see {@link EQN_Lines}
|
|
2325
|
+
*
|
|
2326
|
+
* @interface
|
|
2327
|
+
* @group Misc Equation
|
|
2328
|
+
*/
|
|
2329
|
+
export type EQN_Line = {
|
|
2330
|
+
content: TypeEquationPhrase;
|
|
2331
|
+
baselineSpace?: null | number;
|
|
2332
|
+
space?: number;
|
|
2333
|
+
justify?: string;
|
|
2334
|
+
offset?: number;
|
|
2335
|
+
};
|
|
2336
|
+
/**
|
|
2337
|
+
* Equation lines.
|
|
2338
|
+
*
|
|
2339
|
+
* 
|
|
2340
|
+
*
|
|
2341
|
+
* Options can be an object, or an array in the property order below
|
|
2342
|
+
*
|
|
2343
|
+
* The equation lines function can split an equation into multiple lines.
|
|
2344
|
+
* This might be because one line is too long, or it might be convenient to
|
|
2345
|
+
* display different forms of the same equation simultaneously on different
|
|
2346
|
+
* lines and then animate between them.
|
|
2347
|
+
*
|
|
2348
|
+
* Lines can be justified to the left, center or right, or lines can be aligned
|
|
2349
|
+
* with a specific element from each line (for instance an equals sign). To
|
|
2350
|
+
* justify to a specific element, use `justify: 'element'` and then define the
|
|
2351
|
+
* element name in the `justify` property of each line.
|
|
2352
|
+
*
|
|
2353
|
+
* Lines can be aligned in y with either the top most part of the top line, the
|
|
2354
|
+
* bottom most part of the bottom line, the middle of the lines or any of the
|
|
2355
|
+
* line's baselines.
|
|
2356
|
+
*
|
|
2357
|
+
* Spacing between lines is defined as either the space between the lowest
|
|
2358
|
+
* point (descent) of one line to the highest point (ascent) of the next,
|
|
2359
|
+
* or as the space between line baselines.
|
|
2360
|
+
* @property {Array<EQN_Line | TypeEquationPhrase>} content Array of equation
|
|
2361
|
+
* phrases or equation line objects
|
|
2362
|
+
* @property {'left' | 'center' | 'right' | 'element'} [justify] how to align
|
|
2363
|
+
* the lines in x. Use 'element' to align the lines with a specific element
|
|
2364
|
+
* from each line (that is defined with the `justify` property in each line)
|
|
2365
|
+
* (`'left'`)
|
|
2366
|
+
* @property {number | null} [baselineSpace] default space between baselines
|
|
2367
|
+
* of lines. If not `null` then will override `space` (`null`).
|
|
2368
|
+
* @property {number} [space] default space between descent of one line and
|
|
2369
|
+
* ascent of the next line (`0`).
|
|
2370
|
+
* @property {'bottom' | 'middle' | 'top' | number} [yAlign] How to align the
|
|
2371
|
+
* lines in y. `number` can be any line index, and it will align the baseline
|
|
2372
|
+
* of that line. So, using `0` will align the first line's baseline. (`0`)
|
|
2373
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
2374
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
2375
|
+
*
|
|
2376
|
+
* @see To test examples, append them to the
|
|
2377
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
2378
|
+
*
|
|
2379
|
+
* @example
|
|
2380
|
+
* // Two lines, array definition
|
|
2381
|
+
* figure.add({
|
|
2382
|
+
* name: 'eqn',
|
|
2383
|
+
* make: 'equation',
|
|
2384
|
+
* forms: {
|
|
2385
|
+
* 0: {
|
|
2386
|
+
* lines: [
|
|
2387
|
+
* [
|
|
2388
|
+
* ['a', '_ = ', 'b', '_ + _1', 'c', '_ - _1', 'd'],
|
|
2389
|
+
* ['_ + _2', 'e', '_ - _2', 'f'],
|
|
2390
|
+
* ],
|
|
2391
|
+
* 'right',
|
|
2392
|
+
* 0.2,
|
|
2393
|
+
* ],
|
|
2394
|
+
* },
|
|
2395
|
+
* },
|
|
2396
|
+
* });
|
|
2397
|
+
*
|
|
2398
|
+
* @example
|
|
2399
|
+
* // Two lines animating to 1
|
|
2400
|
+
* figure.add({
|
|
2401
|
+
* name: 'eqn',
|
|
2402
|
+
* make: 'equation',
|
|
2403
|
+
* elements: {
|
|
2404
|
+
* equals1: ' = ',
|
|
2405
|
+
* equals2: ' = ',
|
|
2406
|
+
* },
|
|
2407
|
+
* forms: {
|
|
2408
|
+
* 0: {
|
|
2409
|
+
* lines: {
|
|
2410
|
+
* content: [
|
|
2411
|
+
* {
|
|
2412
|
+
* content: ['a_1', 'equals1', 'b', '_ + ', 'c'],
|
|
2413
|
+
* justify: 'equals1',
|
|
2414
|
+
* },
|
|
2415
|
+
* {
|
|
2416
|
+
* content: ['d', '_ - ', 'e', 'equals2', 'a_2'],
|
|
2417
|
+
* justify: 'equals2',
|
|
2418
|
+
* },
|
|
2419
|
+
* ],
|
|
2420
|
+
* space: 0.08,
|
|
2421
|
+
* justify: 'element',
|
|
2422
|
+
* },
|
|
2423
|
+
* },
|
|
2424
|
+
* 1: ['d', '_ - ', 'e', 'equals1', 'b', '_ + ', 'c'],
|
|
2425
|
+
* },
|
|
2426
|
+
* });
|
|
2427
|
+
*
|
|
2428
|
+
* figure.getElement('eqn').showForm(0);
|
|
2429
|
+
* figure.getElement('eqn').animations.new()
|
|
2430
|
+
* .goToForm({
|
|
2431
|
+
* delay: 1, target: '1', duration: 1, animate: 'move',
|
|
2432
|
+
* })
|
|
2433
|
+
* .start();
|
|
2434
|
+
* @interface
|
|
2435
|
+
* @group Equation Layout
|
|
2436
|
+
*/
|
|
2437
|
+
export type EQN_Lines = {
|
|
2438
|
+
content: Array<TypeEquationPhrase | EQN_Line>;
|
|
2439
|
+
justify?: 'left' | 'right' | 'center' | 'element';
|
|
2440
|
+
baselineSpace?: null | number;
|
|
2441
|
+
space?: number;
|
|
2442
|
+
yAlign?: 'bottom' | 'top' | 'middle' | number;
|
|
2443
|
+
fullContentBounds?: boolean;
|
|
2444
|
+
};
|
|
2445
|
+
/**
|
|
2446
|
+
* Annotation options object.
|
|
2447
|
+
*
|
|
2448
|
+
* 
|
|
2449
|
+
*
|
|
2450
|
+
* 
|
|
2451
|
+
*
|
|
2452
|
+
* An annotation's layout is defined by its *position* and *alignement*.
|
|
2453
|
+
* For instance, an annotation at the top right of the content:
|
|
2454
|
+
* <pre>
|
|
2455
|
+
* AAAA
|
|
2456
|
+
* AAAA
|
|
2457
|
+
* CCCCCCCC
|
|
2458
|
+
* CCCCCCCC
|
|
2459
|
+
* CCCCCCCC
|
|
2460
|
+
* CCCCCCCC
|
|
2461
|
+
* </pre>
|
|
2462
|
+
* has a *position* relative to the content:
|
|
2463
|
+
* * `xPosition`: `'right'`
|
|
2464
|
+
* * `yPosition`: `'top'`
|
|
2465
|
+
*
|
|
2466
|
+
* and an *alignment* relative to the annotation:
|
|
2467
|
+
* * `xAlign`: `'left'`
|
|
2468
|
+
* * `yAlign`: `'bottom'`
|
|
2469
|
+
*
|
|
2470
|
+
*
|
|
2471
|
+
* In comparison, if `yAlign` were equal to `'top'`, then it would result in:
|
|
2472
|
+
* <pre>
|
|
2473
|
+
* CCCCCCCCAAAA
|
|
2474
|
+
* CCCCCCCCAAAA
|
|
2475
|
+
* CCCCCCCC
|
|
2476
|
+
* CCCCCCCC
|
|
2477
|
+
* </pre>
|
|
2478
|
+
* @property {TypeEquationPhrase} content
|
|
2479
|
+
* @property {'left' | 'center' | 'right' | number} [xPosition] where number is
|
|
2480
|
+
* the percentage width of the content (`'center'`)
|
|
2481
|
+
* @property {'bottom' | 'baseline' | 'middle' | 'top' | number} [yPosition]
|
|
2482
|
+
* where number is the percentage height of the content (`'top'`)
|
|
2483
|
+
* @property {'left' | 'center' | 'right' | number} [xAlign] where number is
|
|
2484
|
+
* the percentage width of the annotation (`'center'`)
|
|
2485
|
+
* @property {'bottom' | 'baseline' | 'middle' | 'top' | number} [yAlign] where
|
|
2486
|
+
* number is the percentage width of the annotation (`'bottom'`)
|
|
2487
|
+
* @property {Point} [offset] annotation offset (`[0, 0]`)
|
|
2488
|
+
* @property {number} [scale] annotation scale (`1`)
|
|
2489
|
+
* @property {boolean} [inSize] (`true`)
|
|
2490
|
+
* @property {boolean} [fullContentBounds] (`false`)
|
|
2491
|
+
* @property {string} [reference] calling getBounds on a glyph can return a
|
|
2492
|
+
* suggested position, alignment and offset of an annotation with some name. If
|
|
2493
|
+
* this name is defined here, then `xPosition`, `yPosition`, `xAlign`, `yAlign`
|
|
2494
|
+
* and `offset` will be overwritten with the glyph's suggestion.
|
|
2495
|
+
*
|
|
2496
|
+
* @example
|
|
2497
|
+
* figure.add({
|
|
2498
|
+
* make: 'equation',
|
|
2499
|
+
* forms: {
|
|
2500
|
+
* form1: {
|
|
2501
|
+
* annotate: {
|
|
2502
|
+
* content: 'a',
|
|
2503
|
+
* annotation: {
|
|
2504
|
+
* content: 'b',
|
|
2505
|
+
* xPosition: 'left',
|
|
2506
|
+
* yPosition: 'top',
|
|
2507
|
+
* xAlign: 'right',
|
|
2508
|
+
* yAlign: 'bottom',
|
|
2509
|
+
* scale: 0.5,
|
|
2510
|
+
* },
|
|
2511
|
+
* },
|
|
2512
|
+
* },
|
|
2513
|
+
* },
|
|
2514
|
+
* });
|
|
2515
|
+
*
|
|
2516
|
+
* @example
|
|
2517
|
+
* figure.add({
|
|
2518
|
+
* make: 'equation',
|
|
2519
|
+
* forms: {
|
|
2520
|
+
* form1: {
|
|
2521
|
+
* annotate: {
|
|
2522
|
+
* content: 'a',
|
|
2523
|
+
* annotations: [
|
|
2524
|
+
* {
|
|
2525
|
+
* content: 'b',
|
|
2526
|
+
* xPosition: 'left',
|
|
2527
|
+
* yPosition: 'bottom',
|
|
2528
|
+
* xAlign: 'right',
|
|
2529
|
+
* yAlign: 'top',
|
|
2530
|
+
* scale: 0.5,
|
|
2531
|
+
* },
|
|
2532
|
+
* {
|
|
2533
|
+
* content: 'c',
|
|
2534
|
+
* offset: [0, 0.05],
|
|
2535
|
+
* scale: 0.5,
|
|
2536
|
+
* },
|
|
2537
|
+
* ],
|
|
2538
|
+
* },
|
|
2539
|
+
* },
|
|
2540
|
+
* },
|
|
2541
|
+
* });
|
|
2542
|
+
* @interface
|
|
2543
|
+
* @group Misc Equation
|
|
2544
|
+
*/
|
|
2545
|
+
export type EQN_Annotation = {
|
|
2546
|
+
content: TypeEquationPhrase;
|
|
2547
|
+
xPosition?: 'left' | 'center' | 'right' | number;
|
|
2548
|
+
yPosition?: 'bottom' | 'baseline' | 'middle' | 'top' | number;
|
|
2549
|
+
xAlign?: 'left' | 'center' | 'right' | number;
|
|
2550
|
+
yAlign?: 'bottom' | 'baseline' | 'middle' | 'top' | number;
|
|
2551
|
+
offset?: Point;
|
|
2552
|
+
scale?: number;
|
|
2553
|
+
inSize?: boolean;
|
|
2554
|
+
fullContentBounds?: boolean;
|
|
2555
|
+
reference?: string;
|
|
2556
|
+
};
|
|
2557
|
+
/**
|
|
2558
|
+
* Encompass glyph options object.
|
|
2559
|
+
*
|
|
2560
|
+
* 
|
|
2561
|
+
*
|
|
2562
|
+
* A glyph can encompass (surround or overlay) an equation phrase (*content*). The glyph
|
|
2563
|
+
* can also be annotated.
|
|
2564
|
+
* <pre>
|
|
2565
|
+
*
|
|
2566
|
+
* gggggggggggggg
|
|
2567
|
+
* gggCCCCCCCCggg
|
|
2568
|
+
* gggCCCCCCCCggg
|
|
2569
|
+
* gggCCCCCCCCggg
|
|
2570
|
+
* gggCCCCCCCCggg
|
|
2571
|
+
* gggggggggggggg
|
|
2572
|
+
*
|
|
2573
|
+
* </pre>
|
|
2574
|
+
* @property {string} symbol
|
|
2575
|
+
* @property {EQN_Annotation} [annotation] use for one annotation only instead
|
|
2576
|
+
* of property `annotations`
|
|
2577
|
+
* @property {Array<EQN_Annotation>} [annotations] use for one or more
|
|
2578
|
+
* annotations
|
|
2579
|
+
* @property {number} [space] default space the glyph should extend beyond the
|
|
2580
|
+
* top, right, left and bottom sides of the content (`0`)
|
|
2581
|
+
* @property {number} [topSpace] space the glyph extends beyond the content top
|
|
2582
|
+
* @property {number} [rightSpace] space the glyph extends beyond the content
|
|
2583
|
+
* right
|
|
2584
|
+
* @property {number} [bottomSpace] space the glyph extends beyond the content
|
|
2585
|
+
* bottom
|
|
2586
|
+
* @property {number} [leftSpace] space the glyph extends beyond the content
|
|
2587
|
+
* left
|
|
2588
|
+
* @example
|
|
2589
|
+
* // surrounding content with a box glyph
|
|
2590
|
+
* figure.add({
|
|
2591
|
+
* make: 'equation',
|
|
2592
|
+
* elements: {
|
|
2593
|
+
* box: { symbol: 'box', lineWidth: 0.005 },
|
|
2594
|
+
* },
|
|
2595
|
+
* forms: {
|
|
2596
|
+
* form1: {
|
|
2597
|
+
* annotate: {
|
|
2598
|
+
* content: 'a',
|
|
2599
|
+
* glyphs: {
|
|
2600
|
+
* encompass: {
|
|
2601
|
+
* symbol: 'box',
|
|
2602
|
+
* space: 0.1, // e.g. only, this will be overwritten by next props
|
|
2603
|
+
* topSpace: 0.1,
|
|
2604
|
+
* rightSpace: 0.1,
|
|
2605
|
+
* bottomSpace: 0.1,
|
|
2606
|
+
* leftSpace: 0.1,
|
|
2607
|
+
* },
|
|
2608
|
+
* },
|
|
2609
|
+
* },
|
|
2610
|
+
* },
|
|
2611
|
+
* },
|
|
2612
|
+
* });
|
|
2613
|
+
* @interface
|
|
2614
|
+
* @group Misc Equation
|
|
2615
|
+
*/
|
|
2616
|
+
export type EQN_EncompassGlyph = {
|
|
2617
|
+
symbol?: string;
|
|
2618
|
+
annotation?: EQN_Annotation;
|
|
2619
|
+
annotations?: Array<EQN_Annotation>;
|
|
2620
|
+
space: number;
|
|
2621
|
+
topSpace?: number;
|
|
2622
|
+
rightSpace?: number;
|
|
2623
|
+
bottomSpace?: number;
|
|
2624
|
+
leftSpace?: number;
|
|
2625
|
+
};
|
|
2626
|
+
/**
|
|
2627
|
+
* Left/Right glyph options object.
|
|
2628
|
+
*
|
|
2629
|
+
* 
|
|
2630
|
+
*
|
|
2631
|
+
* 
|
|
2632
|
+
*
|
|
2633
|
+
* 
|
|
2634
|
+
*
|
|
2635
|
+
* A glyph can be to the left or right of an equation phrase (*content*).
|
|
2636
|
+
* The glyph can also be annotated.
|
|
2637
|
+
* <pre>
|
|
2638
|
+
*
|
|
2639
|
+
* ggg CCCCCCCC ggg
|
|
2640
|
+
* ggg CCCCCCCC ggg
|
|
2641
|
+
* ggg CCCCCCCC ggg
|
|
2642
|
+
* ggg CCCCCCCC ggg
|
|
2643
|
+
*
|
|
2644
|
+
* </pre>
|
|
2645
|
+
* @property {string} symbol
|
|
2646
|
+
* @property {EQN_Annotation} [annotation] use for one annotation only instead
|
|
2647
|
+
* of property `annotations`
|
|
2648
|
+
* @property {Array<EQN_Annotation>} [annotations] use for one or more
|
|
2649
|
+
* annotations
|
|
2650
|
+
* @property {number} [space] horizontal space between glyph and content (`0`)
|
|
2651
|
+
* @property {number} [overhang] amount glyph extends above content top and
|
|
2652
|
+
* below content bottom (`0`)
|
|
2653
|
+
* @property {number} [topSpace] amount glyph extends above content top
|
|
2654
|
+
* (overrids `overhang`)
|
|
2655
|
+
* @property {number} [bottomSpace] amount glyph extends below content bottom
|
|
2656
|
+
* (overrids `overhang`)
|
|
2657
|
+
* @property {number} [minContentHeight] force min content height for auto
|
|
2658
|
+
* glyph scaling
|
|
2659
|
+
* @property {number} [minContentDescent] force min content descent for auto
|
|
2660
|
+
* glyph scaling
|
|
2661
|
+
* @property {number} [minContentAscent] force min content ascent for auto
|
|
2662
|
+
* scaling
|
|
2663
|
+
* @property {number} [descent] force descent of glyph
|
|
2664
|
+
* @property {number} [height] force height of glyph (overrides `overhang`,
|
|
2665
|
+
* `topSpace`, `bottomSpace`)
|
|
2666
|
+
* @property {number} [yOffset] offset glyph in y (`0`)
|
|
2667
|
+
* @property {boolean} [annotationsOverContent] `true` means only glyph is
|
|
2668
|
+
* separated from content by `space` and not annotations (false`)
|
|
2669
|
+
*
|
|
2670
|
+
* @example
|
|
2671
|
+
* figure.add({
|
|
2672
|
+
* make: 'equation',
|
|
2673
|
+
* elements: {
|
|
2674
|
+
* rb: { symbol: 'angleBracket', side: 'right', width: 0.1 },
|
|
2675
|
+
* },
|
|
2676
|
+
* forms: {
|
|
2677
|
+
* form1: {
|
|
2678
|
+
* annotate: {
|
|
2679
|
+
* content: 'a',
|
|
2680
|
+
* glyphs: {
|
|
2681
|
+
* right: {
|
|
2682
|
+
* symbol: 'rb',
|
|
2683
|
+
* space: 0.05,
|
|
2684
|
+
* overhang: 0.1,
|
|
2685
|
+
* },
|
|
2686
|
+
* },
|
|
2687
|
+
* },
|
|
2688
|
+
* },
|
|
2689
|
+
* },
|
|
2690
|
+
* });
|
|
2691
|
+
*
|
|
2692
|
+
* @example
|
|
2693
|
+
* figure.add({
|
|
2694
|
+
* make: 'equation',
|
|
2695
|
+
* elements: {
|
|
2696
|
+
* arrow: { symbol: 'arrow', direction: 'down' },
|
|
2697
|
+
* },
|
|
2698
|
+
* forms: {
|
|
2699
|
+
* form1: {
|
|
2700
|
+
* annotate: {
|
|
2701
|
+
* content: 'a',
|
|
2702
|
+
* glyphs: {
|
|
2703
|
+
* left: {
|
|
2704
|
+
* symbol: 'arrow',
|
|
2705
|
+
* space: 0.05,
|
|
2706
|
+
* overhang: 0.1,
|
|
2707
|
+
* annotations: [
|
|
2708
|
+
* {
|
|
2709
|
+
* content: 'b',
|
|
2710
|
+
* xPosition: 'center',
|
|
2711
|
+
* yPosition: 'top',
|
|
2712
|
+
* xAlign: 'center',
|
|
2713
|
+
* yAlign: 'bottom',
|
|
2714
|
+
* scale: 0.7,
|
|
2715
|
+
* offset: [0, 0.05],
|
|
2716
|
+
* },
|
|
2717
|
+
* {
|
|
2718
|
+
* content: 'n',
|
|
2719
|
+
* xPosition: 'center',
|
|
2720
|
+
* yPosition: 'bottom',
|
|
2721
|
+
* xAlign: 'center',
|
|
2722
|
+
* yAlign: 'top',
|
|
2723
|
+
* scale: 0.7,
|
|
2724
|
+
* offset: [0, -0.05],
|
|
2725
|
+
* },
|
|
2726
|
+
* ],
|
|
2727
|
+
* },
|
|
2728
|
+
* },
|
|
2729
|
+
* },
|
|
2730
|
+
* },
|
|
2731
|
+
* },
|
|
2732
|
+
* });
|
|
2733
|
+
*
|
|
2734
|
+
* @example
|
|
2735
|
+
* figure.add({
|
|
2736
|
+
* make: 'equation',
|
|
2737
|
+
* elements: {
|
|
2738
|
+
* brace: { symbol: 'brace', side: 'right', width: 0.05 },
|
|
2739
|
+
* },
|
|
2740
|
+
* forms: {
|
|
2741
|
+
* form1: {
|
|
2742
|
+
* annotate: {
|
|
2743
|
+
* content: 'c',
|
|
2744
|
+
* glyphs: {
|
|
2745
|
+
* left: {
|
|
2746
|
+
* symbol: 'brace',
|
|
2747
|
+
* space: 0.05,
|
|
2748
|
+
* overhang: 0.2,
|
|
2749
|
+
* annotations: [
|
|
2750
|
+
* {
|
|
2751
|
+
* content: 'a',
|
|
2752
|
+
* xPosition: 'left',
|
|
2753
|
+
* yPosition: 'top',
|
|
2754
|
+
* xAlign: 'right',
|
|
2755
|
+
* yAlign: 'middle',
|
|
2756
|
+
* offset: [-0.05, 0],
|
|
2757
|
+
* },
|
|
2758
|
+
* {
|
|
2759
|
+
* content: 'b',
|
|
2760
|
+
* xPosition: 'left',
|
|
2761
|
+
* yPosition: 'bottom',
|
|
2762
|
+
* xAlign: 'right',
|
|
2763
|
+
* yAlign: 'middle',
|
|
2764
|
+
* offset: [-0.05, 0],
|
|
2765
|
+
* },
|
|
2766
|
+
* ],
|
|
2767
|
+
* },
|
|
2768
|
+
* },
|
|
2769
|
+
* },
|
|
2770
|
+
* },
|
|
2771
|
+
* },
|
|
2772
|
+
* });
|
|
2773
|
+
* @interface
|
|
2774
|
+
* @group Misc Equation
|
|
2775
|
+
*/
|
|
2776
|
+
export type EQN_LeftRightGlyph = {
|
|
2777
|
+
symbol?: string;
|
|
2778
|
+
annotation?: EQN_Annotation;
|
|
2779
|
+
annotations?: Array<EQN_Annotation>;
|
|
2780
|
+
space?: number;
|
|
2781
|
+
overhang?: number;
|
|
2782
|
+
topSpace?: number;
|
|
2783
|
+
bottomSpace?: number;
|
|
2784
|
+
minContentHeight?: number;
|
|
2785
|
+
minContentDescent?: number;
|
|
2786
|
+
minContentAscent?: number;
|
|
2787
|
+
descent?: number;
|
|
2788
|
+
height?: number;
|
|
2789
|
+
yOffset?: number;
|
|
2790
|
+
annotationsOverContent?: boolean;
|
|
2791
|
+
};
|
|
2792
|
+
/**
|
|
2793
|
+
* Top/Bottom glyph options object.
|
|
2794
|
+
*
|
|
2795
|
+
* 
|
|
2796
|
+
*
|
|
2797
|
+
* 
|
|
2798
|
+
*
|
|
2799
|
+
* A glyph can be to the top or bottom of an equation phrase (*content*).
|
|
2800
|
+
* The glyph can also be annotated.
|
|
2801
|
+
* <pre>
|
|
2802
|
+
*
|
|
2803
|
+
* gggggggg
|
|
2804
|
+
* gggggggg
|
|
2805
|
+
*
|
|
2806
|
+
* CCCCCCCC
|
|
2807
|
+
* CCCCCCCC
|
|
2808
|
+
* CCCCCCCC
|
|
2809
|
+
* CCCCCCCC
|
|
2810
|
+
*
|
|
2811
|
+
* gggggggg
|
|
2812
|
+
* gggggggg
|
|
2813
|
+
*
|
|
2814
|
+
* </pre>
|
|
2815
|
+
* @property {string} symbol
|
|
2816
|
+
* @property {EQN_Annotation} [annotation] use for one annotation only instead
|
|
2817
|
+
* of property `annotations`
|
|
2818
|
+
* @property {Array<EQN_Annotation>} [annotations] use for one or more
|
|
2819
|
+
* annotations
|
|
2820
|
+
* @property {number} [space] vertical space between glyph and content (`0`)
|
|
2821
|
+
* @property {number} [overhang] amount glyph extends above content top and
|
|
2822
|
+
* below content bottom (`0`)
|
|
2823
|
+
* @property {number} [width] force width of glyph
|
|
2824
|
+
* @property {number} [leftSpace] amount glyph extends beyond content left
|
|
2825
|
+
* @property {number} [rightSpace] amount glyph extends beyond content right
|
|
2826
|
+
* @property {number} [xOffset] offset glyph in x (`0`)
|
|
2827
|
+
* @property {boolean} [annotationsOverContent] `true` means only glyph is
|
|
2828
|
+
* separated from content by `space` and not annotations (false`)
|
|
2829
|
+
* @example
|
|
2830
|
+
* figure.add({
|
|
2831
|
+
* make: 'equation',
|
|
2832
|
+
* elements: {
|
|
2833
|
+
* rarrow: { symbol: 'arrow', direction: 'right' },
|
|
2834
|
+
* larrow: { symbol: 'arrow', direction: 'left' },
|
|
2835
|
+
* },
|
|
2836
|
+
* forms: {
|
|
2837
|
+
* form1: {
|
|
2838
|
+
* annotate: {
|
|
2839
|
+
* content: 'a',
|
|
2840
|
+
* glyphs: {
|
|
2841
|
+
* top: {
|
|
2842
|
+
* symbol: 'rarrow',
|
|
2843
|
+
* space: 0.05,
|
|
2844
|
+
* overhang: 0.1,
|
|
2845
|
+
* },
|
|
2846
|
+
* bottom: {
|
|
2847
|
+
* symbol: 'larrow',
|
|
2848
|
+
* space: 0.05,
|
|
2849
|
+
* overhang: 0.02,
|
|
2850
|
+
* },
|
|
2851
|
+
* },
|
|
2852
|
+
* },
|
|
2853
|
+
* },
|
|
2854
|
+
* },
|
|
2855
|
+
* });
|
|
2856
|
+
*
|
|
2857
|
+
* @example
|
|
2858
|
+
* figure.add({
|
|
2859
|
+
* make: 'equation',
|
|
2860
|
+
* elements: {
|
|
2861
|
+
* brace: { symbol: 'brace', side: 'top' },
|
|
2862
|
+
* },
|
|
2863
|
+
* forms: {
|
|
2864
|
+
* form1: {
|
|
2865
|
+
* annotate: {
|
|
2866
|
+
* content: ['2_1', 'x_1'],
|
|
2867
|
+
* glyphs: {
|
|
2868
|
+
* bottom: {
|
|
2869
|
+
* symbol: 'brace',
|
|
2870
|
+
* space: 0.05,
|
|
2871
|
+
* overhang: 0.2,
|
|
2872
|
+
* annotations: [
|
|
2873
|
+
* {
|
|
2874
|
+
* content: '2_2',
|
|
2875
|
+
* xPosition: 'left',
|
|
2876
|
+
* yPosition: 'bottom',
|
|
2877
|
+
* xAlign: 'center',
|
|
2878
|
+
* yAlign: 'baseline',
|
|
2879
|
+
* offset: [0, -0.2],
|
|
2880
|
+
* },
|
|
2881
|
+
* {
|
|
2882
|
+
* content: 'x_2',
|
|
2883
|
+
* xPosition: 'right',
|
|
2884
|
+
* yPosition: 'bottom',
|
|
2885
|
+
* xAlign: 'center',
|
|
2886
|
+
* yAlign: 'baseline',
|
|
2887
|
+
* offset: [0, -0.2],
|
|
2888
|
+
* },
|
|
2889
|
+
* ],
|
|
2890
|
+
* },
|
|
2891
|
+
* },
|
|
2892
|
+
* },
|
|
2893
|
+
* },
|
|
2894
|
+
* },
|
|
2895
|
+
* });
|
|
2896
|
+
* @interface
|
|
2897
|
+
* @group Misc Equation
|
|
2898
|
+
*/
|
|
2899
|
+
export type EQN_TopBottomGlyph = {
|
|
2900
|
+
symbol?: string;
|
|
2901
|
+
annotation?: EQN_Annotation;
|
|
2902
|
+
annotations?: Array<EQN_Annotation>;
|
|
2903
|
+
space?: number;
|
|
2904
|
+
overhang?: number;
|
|
2905
|
+
width?: number;
|
|
2906
|
+
leftSpace?: number;
|
|
2907
|
+
rightSpace?: number;
|
|
2908
|
+
xOffset?: number;
|
|
2909
|
+
annotationsOverContent?: boolean;
|
|
2910
|
+
};
|
|
2911
|
+
/**
|
|
2912
|
+
* Options object that aligns a line glyph with either the content or
|
|
2913
|
+
* annotation.
|
|
2914
|
+
*
|
|
2915
|
+
* @property {'left' | 'center' | 'right' | number | string} [xAlign]
|
|
2916
|
+
* @property {'bottom' | 'baseline' | 'middle' | 'top' | number | string,} [yAlign]
|
|
2917
|
+
* @property {0} [space]
|
|
2918
|
+
* @interface
|
|
2919
|
+
* @group Misc Equation
|
|
2920
|
+
*/
|
|
2921
|
+
export type EQN_LineGlyphAlign = {
|
|
2922
|
+
xAlign?: 'left' | 'center' | 'right' | number | string;
|
|
2923
|
+
yAlign?: 'bottom' | 'baseline' | 'middle' | 'top' | number | string;
|
|
2924
|
+
space?: 0;
|
|
2925
|
+
};
|
|
2926
|
+
/**
|
|
2927
|
+
* A glyph can be a line {@link EQN_LineSymbol} between some content and an
|
|
2928
|
+
* annotation.
|
|
2929
|
+
*
|
|
2930
|
+
* 
|
|
2931
|
+
*
|
|
2932
|
+
* <pre>
|
|
2933
|
+
*
|
|
2934
|
+
* aaaaa
|
|
2935
|
+
* aaaaa
|
|
2936
|
+
* g
|
|
2937
|
+
* g
|
|
2938
|
+
* g
|
|
2939
|
+
* CCCCCCCCC
|
|
2940
|
+
* CCCCCCCCC
|
|
2941
|
+
* CCCCCCCCC
|
|
2942
|
+
* CCCCCCCCC
|
|
2943
|
+
*
|
|
2944
|
+
* </pre>
|
|
2945
|
+
* @property {string} symbol
|
|
2946
|
+
* @property {EQN_LineGlyphAlign} [content] alignment and spacing to content
|
|
2947
|
+
* @property {EQN_LineGlyphAlign} [annotation] alignment and spacing to annotation
|
|
2948
|
+
* @property {number} [annotationIndex] annotation index to draw line to
|
|
2949
|
+
*
|
|
2950
|
+
* @example
|
|
2951
|
+
* figure.add({
|
|
2952
|
+
* name: 'eqn',
|
|
2953
|
+
* make: 'equation',
|
|
2954
|
+
* elements: {
|
|
2955
|
+
* l: {
|
|
2956
|
+
* symbol: 'line',
|
|
2957
|
+
* width: 0.005,
|
|
2958
|
+
* dash: [0.005, 0.005],
|
|
2959
|
+
* arrow: { start: 'barb' },
|
|
2960
|
+
* },
|
|
2961
|
+
* },
|
|
2962
|
+
* forms: {
|
|
2963
|
+
* 0: {
|
|
2964
|
+
* annotate: {
|
|
2965
|
+
* content: 'abc',
|
|
2966
|
+
* annotation: {
|
|
2967
|
+
* content: 'def',
|
|
2968
|
+
* xPosition: 'right',
|
|
2969
|
+
* yPosition: 'top',
|
|
2970
|
+
* xAlign: 'left',
|
|
2971
|
+
* yAlign: 'bottom',
|
|
2972
|
+
* scale: 0.6,
|
|
2973
|
+
* offset: [0.2, 0.2],
|
|
2974
|
+
* },
|
|
2975
|
+
* glyphs: {
|
|
2976
|
+
* line: {
|
|
2977
|
+
* annotationIndex: 0,
|
|
2978
|
+
* symbol: 'l',
|
|
2979
|
+
* content: {
|
|
2980
|
+
* xAlign: 'right',
|
|
2981
|
+
* yAlign: 'top',
|
|
2982
|
+
* space: 0.02,
|
|
2983
|
+
* },
|
|
2984
|
+
* annotation: {
|
|
2985
|
+
* xAlign: 'left',
|
|
2986
|
+
* yAlign: 'bottom',
|
|
2987
|
+
* space: 0.02,
|
|
2988
|
+
* },
|
|
2989
|
+
* },
|
|
2990
|
+
* },
|
|
2991
|
+
* },
|
|
2992
|
+
* },
|
|
2993
|
+
* },
|
|
2994
|
+
* });
|
|
2995
|
+
* @interface
|
|
2996
|
+
* @group Misc Equation
|
|
2997
|
+
*/
|
|
2998
|
+
export type EQN_LineGlyph = {
|
|
2999
|
+
symbol: string;
|
|
3000
|
+
content?: EQN_LineGlyphAlign;
|
|
3001
|
+
annotation?: EQN_LineGlyphAlign;
|
|
3002
|
+
annotationIndex?: number;
|
|
3003
|
+
};
|
|
3004
|
+
/**
|
|
3005
|
+
* Object defining all the glyphs annotating some content.
|
|
3006
|
+
*
|
|
3007
|
+
* Multiple glyphs are ok, but only one per position.
|
|
3008
|
+
*
|
|
3009
|
+
* @property {EQN_EncompassGlyph} [encompass]
|
|
3010
|
+
* @property {EQN_TopBottomGlyph} [top]
|
|
3011
|
+
* @property {EQN_LeftRightGlyph} [right]
|
|
3012
|
+
* @property {EQN_TopBottomGlyph} [bottom]
|
|
3013
|
+
* @property {EQN_LeftRightGlyph} [left]
|
|
3014
|
+
* @property {EQN_LineGlyph} [line]
|
|
3015
|
+
* @interface
|
|
3016
|
+
* @group Misc Equation
|
|
3017
|
+
*/
|
|
3018
|
+
export type EQN_Glyphs = {
|
|
3019
|
+
left?: EQN_LeftRightGlyph;
|
|
3020
|
+
right?: EQN_LeftRightGlyph;
|
|
3021
|
+
top?: EQN_TopBottomGlyph;
|
|
3022
|
+
bottom?: EQN_TopBottomGlyph;
|
|
3023
|
+
encompass?: EQN_EncompassGlyph;
|
|
3024
|
+
line?: EQN_LineGlyph;
|
|
3025
|
+
};
|
|
3026
|
+
/**
|
|
3027
|
+
* Equation annotation
|
|
3028
|
+
*
|
|
3029
|
+
* 
|
|
3030
|
+
*
|
|
3031
|
+
* An annotation is an equation phrase ('annotation') which is laid out relative
|
|
3032
|
+
* to another equation phrase ('content'). For example:
|
|
3033
|
+
* <pre>
|
|
3034
|
+
* AAAA
|
|
3035
|
+
* AAAA
|
|
3036
|
+
* CCCCCCCC
|
|
3037
|
+
* CCCCCCCC
|
|
3038
|
+
* CCCCCCCC
|
|
3039
|
+
* CCCCCCCC
|
|
3040
|
+
* </pre>
|
|
3041
|
+
*
|
|
3042
|
+
* The options for defining how to annotate one equation phrase with another is
|
|
3043
|
+
* {@link EQN_Annotation}
|
|
3044
|
+
*
|
|
3045
|
+
* Content can also be annotated with a glyph (that itself may also be
|
|
3046
|
+
* annotated). The glyph can either encompass the content, or can be to the
|
|
3047
|
+
* top, bottom, left or right of the content
|
|
3048
|
+
*
|
|
3049
|
+
* <pre>
|
|
3050
|
+
* Top Glyph
|
|
3051
|
+
* GGGGGGGGGGGGGGGGGGGGGGG
|
|
3052
|
+
* GGGGGGGGGGGGGGGGGGGGGGG Encompassing Glyph
|
|
3053
|
+
* /
|
|
3054
|
+
* /
|
|
3055
|
+
* GGG GGGGGGGGGGGGGGGGGGGGGGG GGG
|
|
3056
|
+
* GGG GGG GGG GGG
|
|
3057
|
+
* GGG GGG CCCCCCC GGG GGG
|
|
3058
|
+
* Left GGG GGG CCCCCCC GGG GGG Right
|
|
3059
|
+
* Glyph GGG GGG CCCCCCC GGG GGG Glyph
|
|
3060
|
+
* GGG GGG GGG GGG
|
|
3061
|
+
* GGG GGGGGGGGGGGGGGGGGGGGGGG GGG
|
|
3062
|
+
*
|
|
3063
|
+
*
|
|
3064
|
+
* GGGGGGGGGGGGGGGGGGGGGGG
|
|
3065
|
+
* GGGGGGGGGGGGGGGGGGGGGGG
|
|
3066
|
+
* Bottom Glyph
|
|
3067
|
+
* </pre>
|
|
3068
|
+
*
|
|
3069
|
+
* This function is used internally by almost all equation functions
|
|
3070
|
+
* (except for fraction) for their layout. As such, it is very generic and
|
|
3071
|
+
* powerful. It should also almost never neeed to be used as most layouts
|
|
3072
|
+
* can be achieved with a different functions that will have more succinct
|
|
3073
|
+
* code that is more readable.
|
|
3074
|
+
*
|
|
3075
|
+
* This is provided so all layout corner cases not covered by the functions
|
|
3076
|
+
* above are possible - including with custom glyphs.
|
|
3077
|
+
*
|
|
3078
|
+
* Options can *only* be an object.
|
|
3079
|
+
*
|
|
3080
|
+
* @property {TypeEquationPhrase} content
|
|
3081
|
+
* @property {EQN_Annotation} [annotation] use for just one annotation
|
|
3082
|
+
* @property {Array<EQN_Annotation>} [annotations] use for multiple annotations
|
|
3083
|
+
* @property {boolean} [inSize] `true` means resulting size includes
|
|
3084
|
+
* annotations (`true`)
|
|
3085
|
+
* @property {number} [space] extend resulting equation phrase size by space on
|
|
3086
|
+
* top, right, bottom and left sides (`0`)
|
|
3087
|
+
* @property {number} [topSpace] extend resulting equation phrase size by space
|
|
3088
|
+
* on top
|
|
3089
|
+
* @property {number} [bottomSpace] extend resulting equation phrase size by
|
|
3090
|
+
* space on bottom
|
|
3091
|
+
* @property {number} [leftSpace] extend resulting equation phrase size by space
|
|
3092
|
+
* on left
|
|
3093
|
+
* @property {number} [rightSpace] extend resulting equation phrase size by
|
|
3094
|
+
* space on right
|
|
3095
|
+
* @property {number} [contentScale] scale content (`1`)
|
|
3096
|
+
* @property {EQN_Glyphs} [glyphs] glyphs to annotate content with
|
|
3097
|
+
* @property {boolean} [fullContentBounds] use full bounds of content,
|
|
3098
|
+
* overriding any `inSize=false` properties in the content (`false`)
|
|
3099
|
+
* @property {boolean} [useFullBounds] make the bounds of this phrase equal to
|
|
3100
|
+
* the full bounds of the content even if `fullContentBounds=false` and the
|
|
3101
|
+
* brackets only surround a portion of the content (`false`)
|
|
3102
|
+
*
|
|
3103
|
+
* @see To test examples, append them to the
|
|
3104
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
3105
|
+
*
|
|
3106
|
+
* @example
|
|
3107
|
+
* // Some different annotation examples
|
|
3108
|
+
* figure.add({
|
|
3109
|
+
* name: 'eqn',
|
|
3110
|
+
* make: 'equation',
|
|
3111
|
+
* elements: {
|
|
3112
|
+
* bar: { symbol: 'bar', side: 'right' },
|
|
3113
|
+
* },
|
|
3114
|
+
* forms: {
|
|
3115
|
+
* // Single annotation
|
|
3116
|
+
* 1: {
|
|
3117
|
+
* annotate: {
|
|
3118
|
+
* content: 'a',
|
|
3119
|
+
* annotation: {
|
|
3120
|
+
* content: 'bbb',
|
|
3121
|
+
* yPosition: 'top',
|
|
3122
|
+
* yAlign: 'bottom',
|
|
3123
|
+
* xPosition: 'left',
|
|
3124
|
+
* xAlign: 'right',
|
|
3125
|
+
* scale: 0.5,
|
|
3126
|
+
* },
|
|
3127
|
+
* },
|
|
3128
|
+
* },
|
|
3129
|
+
* // Multiple annotations
|
|
3130
|
+
* 2: {
|
|
3131
|
+
* annotate: {
|
|
3132
|
+
* content: 'a',
|
|
3133
|
+
* annotations: [
|
|
3134
|
+
* {
|
|
3135
|
+
* content: 'bbb',
|
|
3136
|
+
* yPosition: 'top',
|
|
3137
|
+
* yAlign: 'bottom',
|
|
3138
|
+
* xPosition: 'left',
|
|
3139
|
+
* xAlign: 'right',
|
|
3140
|
+
* scale: 0.5,
|
|
3141
|
+
* },
|
|
3142
|
+
* {
|
|
3143
|
+
* content: 'ccc',
|
|
3144
|
+
* xPosition: 'right',
|
|
3145
|
+
* yPosition: 'middle',
|
|
3146
|
+
* xAlign: 'left',
|
|
3147
|
+
* yAlign: 'middle',
|
|
3148
|
+
* scale: 0.5,
|
|
3149
|
+
* offset: [0.05, 0],
|
|
3150
|
+
* },
|
|
3151
|
+
* ],
|
|
3152
|
+
* },
|
|
3153
|
+
* },
|
|
3154
|
+
* // With glyph
|
|
3155
|
+
* 3: {
|
|
3156
|
+
* annotate: {
|
|
3157
|
+
* content: 'a',
|
|
3158
|
+
* glyphs: {
|
|
3159
|
+
* left:{
|
|
3160
|
+
* symbol: 'bar',
|
|
3161
|
+
* overhang: 0.1,
|
|
3162
|
+
* annotation: {
|
|
3163
|
+
* content: 'bbb',
|
|
3164
|
+
* xPosition: 'right',
|
|
3165
|
+
* yPosition: 'bottom',
|
|
3166
|
+
* xAlign: 'left',
|
|
3167
|
+
* yAlign: 'middle',
|
|
3168
|
+
* scale: 0.5,
|
|
3169
|
+
* },
|
|
3170
|
+
* },
|
|
3171
|
+
* },
|
|
3172
|
+
* },
|
|
3173
|
+
* },
|
|
3174
|
+
* },
|
|
3175
|
+
* formSeries: ['1', '2', '3'],
|
|
3176
|
+
* });
|
|
3177
|
+
* const eqn = figure.elements._eqn;
|
|
3178
|
+
* eqn.onClick = () => eqn.nextForm();
|
|
3179
|
+
* eqn.setTouchable();
|
|
3180
|
+
* eqn.showForm('1');
|
|
3181
|
+
* @interface
|
|
3182
|
+
* @group Equation Layout
|
|
3183
|
+
*/
|
|
3184
|
+
export type EQN_Annotate = {
|
|
3185
|
+
content: TypeEquationPhrase;
|
|
3186
|
+
annotation?: EQN_Annotation;
|
|
3187
|
+
annotations?: Array<EQN_Annotation>;
|
|
3188
|
+
fullContentBounds?: boolean;
|
|
3189
|
+
useFullBounds?: boolean;
|
|
3190
|
+
glyphs?: EQN_Glyphs;
|
|
3191
|
+
inSize?: boolean;
|
|
3192
|
+
space?: number;
|
|
3193
|
+
topSpace?: number;
|
|
3194
|
+
bottomSpace?: number;
|
|
3195
|
+
leftSpace?: number;
|
|
3196
|
+
rightSpace?: number;
|
|
3197
|
+
contentScale?: number;
|
|
3198
|
+
};
|
|
3199
|
+
/**
|
|
3200
|
+
* Equation Functions.
|
|
3201
|
+
*
|
|
3202
|
+
* Contains methods for all equation functions.
|
|
3203
|
+
* @group Misc Equation
|
|
3204
|
+
*/
|
|
3205
|
+
export declare class EquationFunctions {
|
|
3206
|
+
elements: {
|
|
3207
|
+
[name: string]: FigureElementCollection | FigureElementPrimitive;
|
|
3208
|
+
};
|
|
3209
|
+
shapes: Record<string, any>;
|
|
3210
|
+
phrases: {
|
|
3211
|
+
[phraseName: string]: TypeEquationPhrase;
|
|
3212
|
+
};
|
|
3213
|
+
phraseElements: {
|
|
3214
|
+
[phraseName: string]: Array<FigureElementPrimitive>;
|
|
3215
|
+
};
|
|
3216
|
+
fullLineHeight: EquationForm | null;
|
|
3217
|
+
addElementFromKey: (key: string, params: Record<string, any>) => FigureElementPrimitive | null | undefined;
|
|
3218
|
+
getExistingOrAddSymbol: (keyOrObj: string | Record<string, any>) => FigureElementPrimitive | null | undefined;
|
|
3219
|
+
/**
|
|
3220
|
+
* @hideconstructor
|
|
3221
|
+
*/
|
|
3222
|
+
constructor(elements: {
|
|
3223
|
+
[name: string]: FigureElementCollection | FigureElementPrimitive;
|
|
3224
|
+
}, addElementFromKey: (key: string) => FigureElementPrimitive | null | undefined, getExistingOrAddSymbol: (keyOrObj: string | Record<string, any>) => FigureElementPrimitive | null | undefined);
|
|
3225
|
+
stringToElement(content: string): any;
|
|
3226
|
+
parseContent(content: TypeEquationPhrase | null | undefined): any;
|
|
3227
|
+
contentToElement(content: TypeEquationPhrase | Elements | FigureElementPrimitive | FigureElementCollection): Elements;
|
|
3228
|
+
eqnMethod(name: string, params: any): BaseAnnotationFunction | Fraction | Matrix | Lines | Scale | Container | Offset | Color | null;
|
|
3229
|
+
/**
|
|
3230
|
+
* Equation container function
|
|
3231
|
+
* @see {@link EQN_Container} for description and examples
|
|
3232
|
+
*/
|
|
3233
|
+
container(options: EQN_Container): Container;
|
|
3234
|
+
/**
|
|
3235
|
+
* Equation container function
|
|
3236
|
+
* @see {@link EQN_Offset} for description and examples
|
|
3237
|
+
*/
|
|
3238
|
+
offset(options: EQN_Offset): Offset;
|
|
3239
|
+
/**
|
|
3240
|
+
* Equation bracket function
|
|
3241
|
+
* @see {@link EQN_Bracket} for description and examples
|
|
3242
|
+
*/
|
|
3243
|
+
brac(options: EQN_Bracket): BaseAnnotationFunction;
|
|
3244
|
+
/**
|
|
3245
|
+
* Equation bar function
|
|
3246
|
+
* @see {@link EQN_Bar} for description and examples
|
|
3247
|
+
*/
|
|
3248
|
+
bar(options: EQN_Bar, forceOptions?: Record<string, any>): BaseAnnotationFunction;
|
|
3249
|
+
/**
|
|
3250
|
+
* Equation annotate function
|
|
3251
|
+
* @see {@link EQN_Annotate} for description and examples
|
|
3252
|
+
*/
|
|
3253
|
+
annotate(options: EQN_Annotate): BaseAnnotationFunction;
|
|
3254
|
+
/**
|
|
3255
|
+
* Equation annotate function
|
|
3256
|
+
* @see {@link EQN_Scale} for description and examples
|
|
3257
|
+
*/
|
|
3258
|
+
scale(options: EQN_Scale): Scale;
|
|
3259
|
+
/**
|
|
3260
|
+
* Equation color function
|
|
3261
|
+
* @see {@link EQN_Color} for description and examples
|
|
3262
|
+
*/
|
|
3263
|
+
color(options: EQN_Color): Color;
|
|
3264
|
+
/**
|
|
3265
|
+
* Equation fraction function
|
|
3266
|
+
* @see {@link EQN_Fraction} for description and examples
|
|
3267
|
+
*/
|
|
3268
|
+
frac(options: EQN_Fraction): Fraction;
|
|
3269
|
+
root(optionsOrArray: EQN_Root): BaseAnnotationFunction;
|
|
3270
|
+
/**
|
|
3271
|
+
* Equation super-sub script function
|
|
3272
|
+
* @see {@link EQN_SuperscriptSubscript} for description and examples
|
|
3273
|
+
*/
|
|
3274
|
+
supSub(options: EQN_SuperscriptSubscript): BaseAnnotationFunction;
|
|
3275
|
+
/**
|
|
3276
|
+
* Equation superscript function
|
|
3277
|
+
* @see {@link EQN_Superscript} for description and examples
|
|
3278
|
+
*/
|
|
3279
|
+
sup(options: EQN_Superscript): BaseAnnotationFunction;
|
|
3280
|
+
/**
|
|
3281
|
+
* Equation subscript function
|
|
3282
|
+
* @see {@link EQN_Subscript} for description and examples
|
|
3283
|
+
*/
|
|
3284
|
+
sub(options: EQN_Subscript): BaseAnnotationFunction;
|
|
3285
|
+
/**
|
|
3286
|
+
* Equation touch box function
|
|
3287
|
+
* @see {@link EQN_TouchBox} for description and examples
|
|
3288
|
+
*/
|
|
3289
|
+
touchBox(options: EQN_TouchBox): BaseAnnotationFunction;
|
|
3290
|
+
/**
|
|
3291
|
+
* Equation box function
|
|
3292
|
+
* @see {@link EQN_Box} for description and examples
|
|
3293
|
+
*/
|
|
3294
|
+
box(options: EQN_Box): BaseAnnotationFunction;
|
|
3295
|
+
/**
|
|
3296
|
+
* Equation pad function
|
|
3297
|
+
* @see {@link EQN_Pad} for description and examples
|
|
3298
|
+
*/
|
|
3299
|
+
pad(options: EQN_Pad): BaseAnnotationFunction;
|
|
3300
|
+
/**
|
|
3301
|
+
* Equation top bar function
|
|
3302
|
+
* @see {@link EQN_Bar} for description and examples
|
|
3303
|
+
*/
|
|
3304
|
+
topBar(options: EQN_Bar): BaseAnnotationFunction;
|
|
3305
|
+
/**
|
|
3306
|
+
* Equation bottom bar function
|
|
3307
|
+
* @see {@link EQN_Bar} for description and examples
|
|
3308
|
+
*/
|
|
3309
|
+
bottomBar(options: EQN_Bar): BaseAnnotationFunction;
|
|
3310
|
+
/**
|
|
3311
|
+
* Equation matrix function
|
|
3312
|
+
* @see {@link EQN_Matrix} for description and examples
|
|
3313
|
+
*/
|
|
3314
|
+
matrix(options: EQN_Matrix): BaseAnnotationFunction | Matrix;
|
|
3315
|
+
/**
|
|
3316
|
+
* Equation matrix function
|
|
3317
|
+
* @see {@link EQN_Matrix} for description and examples
|
|
3318
|
+
*/
|
|
3319
|
+
lines(options: EQN_Lines): Lines;
|
|
3320
|
+
/**
|
|
3321
|
+
* Equation integral function
|
|
3322
|
+
* @see {@link EQN_Integral} for description and examples
|
|
3323
|
+
*/
|
|
3324
|
+
int(options: EQN_Integral): BaseAnnotationFunction;
|
|
3325
|
+
/**
|
|
3326
|
+
* Equation sum of function
|
|
3327
|
+
* @see {@link EQN_SumOf} for description and examples
|
|
3328
|
+
*/
|
|
3329
|
+
sumOf(options: EQN_SumOf): BaseAnnotationFunction;
|
|
3330
|
+
/**
|
|
3331
|
+
* Equation product of function
|
|
3332
|
+
* @see {@link EQN_ProdOf} for description and examples
|
|
3333
|
+
*/
|
|
3334
|
+
prodOf(options: EQN_ProdOf): BaseAnnotationFunction;
|
|
3335
|
+
sumProd(optionsOrArray: EQN_SumOf | EQN_ProdOf): BaseAnnotationFunction;
|
|
3336
|
+
processComment(optionsOrArray: EQN_Comment): any[];
|
|
3337
|
+
/**
|
|
3338
|
+
* Equation top comment of function
|
|
3339
|
+
* @param {EQN_Comment} options
|
|
3340
|
+
* @see {@link EQN_Comment} for description and examples
|
|
3341
|
+
*/
|
|
3342
|
+
topComment(...args: any[]): BaseAnnotationFunction;
|
|
3343
|
+
/**
|
|
3344
|
+
* Equation bottom comment of function
|
|
3345
|
+
* @param {EQN_Comment} options
|
|
3346
|
+
* @see {@link EQN_Comment} for description and examples
|
|
3347
|
+
*/
|
|
3348
|
+
bottomComment(...args: any[]): BaseAnnotationFunction;
|
|
3349
|
+
/**
|
|
3350
|
+
* Equation strike of function
|
|
3351
|
+
* @see {@link EQN_Strike} for description and examples
|
|
3352
|
+
*/
|
|
3353
|
+
strike(options: EQN_Strike): BaseAnnotationFunction;
|
|
3354
|
+
processStrike(optionsOrContent: EQN_StrikeComment): any[];
|
|
3355
|
+
/**
|
|
3356
|
+
* Equation top strike of function
|
|
3357
|
+
* @param {EQN_Strike} options
|
|
3358
|
+
* @see {@link EQN_Strike} for description and examples
|
|
3359
|
+
*/
|
|
3360
|
+
topStrike(...args: any[]): BaseAnnotationFunction;
|
|
3361
|
+
/**
|
|
3362
|
+
* Equation bottom strike of function
|
|
3363
|
+
* @param {EQN_Strike} options
|
|
3364
|
+
* @see {@link EQN_Strike} for description and examples
|
|
3365
|
+
*/
|
|
3366
|
+
bottomStrike(...args: any[]): BaseAnnotationFunction;
|
|
3367
|
+
}
|