figureone 0.15.10 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/figureone.min.js +1 -1
  2. package/index.js +79167 -0
  3. package/package.json +15 -1
  4. package/types/index.d.ts +132 -0
  5. package/types/js/figure/Animation/Animation.d.ts +36 -0
  6. package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
  7. package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
  8. package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
  9. package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
  10. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
  11. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
  12. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
  13. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
  14. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
  15. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
  16. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
  17. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
  18. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
  19. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
  20. package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
  21. package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
  22. package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
  23. package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
  24. package/types/js/figure/DrawContext2D.d.ts +9 -0
  25. package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
  26. package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
  27. package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
  28. package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
  29. package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
  30. package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
  31. package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
  32. package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
  33. package/types/js/figure/Element.d.ts +1212 -0
  34. package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
  35. package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
  36. package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
  37. package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
  38. package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
  39. package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
  40. package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
  41. package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
  42. package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
  43. package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
  44. package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
  45. package/types/js/figure/Equation/Equation.d.ts +984 -0
  46. package/types/js/figure/Equation/EquationForm.d.ts +139 -0
  47. package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
  48. package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
  49. package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
  50. package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
  51. package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
  52. package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
  53. package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
  54. package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
  55. package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
  56. package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
  57. package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
  58. package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
  59. package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
  60. package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
  61. package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
  62. package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
  63. package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
  64. package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
  65. package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
  66. package/types/js/figure/Figure.d.ts +711 -0
  67. package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
  68. package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
  69. package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
  70. package/types/js/figure/FigureCollections/Button.d.ts +195 -0
  71. package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
  72. package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
  73. package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
  74. package/types/js/figure/FigureCollections/Line.d.ts +587 -0
  75. package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
  76. package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
  77. package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
  78. package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
  79. package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
  80. package/types/js/figure/FigureCollections/Text.d.ts +307 -0
  81. package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
  82. package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
  83. package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
  84. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
  85. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
  86. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
  87. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
  88. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
  89. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
  90. package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
  91. package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
  92. package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
  93. package/types/js/figure/FontManager.d.ts +113 -0
  94. package/types/js/figure/Gesture.d.ts +39 -0
  95. package/types/js/figure/Recorder/Recorder.d.ts +291 -0
  96. package/types/js/figure/Recorder/parseState.d.ts +3 -0
  97. package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
  98. package/types/js/figure/Recorder/state.d.ts +7 -0
  99. package/types/js/figure/SlideNavigator.d.ts +606 -0
  100. package/types/js/figure/TimeKeeper.d.ts +174 -0
  101. package/types/js/figure/geometries/arc.d.ts +18 -0
  102. package/types/js/figure/geometries/arrow.d.ts +215 -0
  103. package/types/js/figure/geometries/buffer.d.ts +4 -0
  104. package/types/js/figure/geometries/copy/copy.d.ts +178 -0
  105. package/types/js/figure/geometries/ellipse.d.ts +17 -0
  106. package/types/js/figure/geometries/line.d.ts +13 -0
  107. package/types/js/figure/geometries/lines/corners.d.ts +7 -0
  108. package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
  109. package/types/js/figure/geometries/lines/lines.d.ts +31 -0
  110. package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
  111. package/types/js/figure/geometries/rectangle.d.ts +19 -0
  112. package/types/js/figure/geometries/triangle.d.ts +27 -0
  113. package/types/js/figure/webgl/Atlas.d.ts +42 -0
  114. package/types/js/figure/webgl/shaders.d.ts +143 -0
  115. package/types/js/figure/webgl/target.d.ts +9 -0
  116. package/types/js/figure/webgl/webgl.d.ts +54 -0
  117. package/types/js/tools/FunctionMap.d.ts +69 -0
  118. package/types/js/tools/color.d.ts +11 -0
  119. package/types/js/tools/colorNames.d.ts +2 -0
  120. package/types/js/tools/d2/polygon.d.ts +60 -0
  121. package/types/js/tools/d2/triangles.d.ts +0 -0
  122. package/types/js/tools/d3/cone.d.ts +57 -0
  123. package/types/js/tools/d3/cube.d.ts +26 -0
  124. package/types/js/tools/d3/cylinder.d.ts +45 -0
  125. package/types/js/tools/d3/line3.d.ts +55 -0
  126. package/types/js/tools/d3/prism.d.ts +49 -0
  127. package/types/js/tools/d3/revolve.d.ts +87 -0
  128. package/types/js/tools/d3/sphere.d.ts +33 -0
  129. package/types/js/tools/d3/surface.d.ts +47 -0
  130. package/types/js/tools/g2.d.ts +242 -0
  131. package/types/js/tools/geometry/Bounds.d.ts +446 -0
  132. package/types/js/tools/geometry/Line.d.ts +314 -0
  133. package/types/js/tools/geometry/Path.d.ts +67 -0
  134. package/types/js/tools/geometry/Plane.d.ts +201 -0
  135. package/types/js/tools/geometry/Point.d.ts +359 -0
  136. package/types/js/tools/geometry/Rect.d.ts +115 -0
  137. package/types/js/tools/geometry/Transform.d.ts +623 -0
  138. package/types/js/tools/geometry/angle.d.ts +105 -0
  139. package/types/js/tools/geometry/common.d.ts +9 -0
  140. package/types/js/tools/geometry/coordinates.d.ts +30 -0
  141. package/types/js/tools/geometry/deceleration.d.ts +13 -0
  142. package/types/js/tools/geometry/polygon.d.ts +4 -0
  143. package/types/js/tools/geometry/quaternion.d.ts +15 -0
  144. package/types/js/tools/geometry/scene.d.ts +282 -0
  145. package/types/js/tools/geometry/tools.d.ts +8 -0
  146. package/types/js/tools/geometry/types.d.ts +2 -0
  147. package/types/js/tools/getCssColors.d.ts +1 -0
  148. package/types/js/tools/getCssVariables.d.ts +4 -0
  149. package/types/js/tools/getImageData.d.ts +1 -0
  150. package/types/js/tools/getScssColors.d.ts +2 -0
  151. package/types/js/tools/htmlGenerator.d.ts +85 -0
  152. package/types/js/tools/m2.d.ts +24 -0
  153. package/types/js/tools/m3.d.ts +71 -0
  154. package/types/js/tools/math.d.ts +112 -0
  155. package/types/js/tools/morph.d.ts +651 -0
  156. package/types/js/tools/styleSheets.d.ts +3 -0
  157. package/types/js/tools/tools.d.ts +281 -0
  158. package/types/js/tools/types.d.ts +305 -0
  159. package/figureone.worker.js +0 -1
@@ -0,0 +1,195 @@
1
+ import { FigureElementCollection, FigureElementPrimitive } from '../Element';
2
+ import type { OBJ_Collection, OBJ_LineStyleSimple } from '../FigurePrimitives/FigurePrimitiveTypes';
3
+ import type { TypeColor, OBJ_Font, OBJ_CurvedCorner } from '../../tools/types';
4
+ import type FigureCollections from './FigureCollections';
5
+ import EquationLabel from './EquationLabel';
6
+ import type { EQN_Equation, Equation } from '../Equation/Equation';
7
+ /**
8
+ * Collections button label options object.
9
+ *
10
+ * A button can be annotated with a label using the `text` property and can be:
11
+ * - text (`string`, `Array<string>`)
12
+ * - an equation (`Equation`, `EQN_Equation`)
13
+ *
14
+ * In all cases, an actual {@link Equation} is created as the label. The
15
+ * equation can have multiple forms, which can be set using the `showForm`
16
+ * method.
17
+ *
18
+ * If `text`: `string`, then an equation with a single form named `base` will
19
+ * be created with a single element being the string text.
20
+ *
21
+ * If `text`: `Array<string>`, then an equation with a form for each element
22
+ * of the array is created. Each form is named '0', '1', '2'... corresponding
23
+ * with the index of the array. Each form is has a single element, being the
24
+ * text at that index.
25
+ *
26
+ * Use `text`: {@link Equation} or {@link EQN_Equation} to create completely
27
+ * custom equations with any forms desirable.
28
+ *
29
+ * @see {@link COL_Button}
30
+ *
31
+ * @property {null | string | Array<string> | Equation | EQN_Equation } text
32
+ * @property {OBJ_Font} [font] font to use
33
+ * @property {number} [scale] size of the label
34
+ * @property {TypeColor} [color]
35
+ * @interface
36
+ * @group Misc Shapes
37
+ */
38
+ export type OBJ_ButtonLabel = {
39
+ text: null | string | Array<string> | Equation | EQN_Equation;
40
+ font?: OBJ_Font;
41
+ scale?: number;
42
+ color?: TypeColor;
43
+ };
44
+ /**
45
+ * Button state options object.
46
+ *
47
+ * @property {TypeColor} [colorLine]
48
+ * @property {TypeColor} [colorFill]
49
+ * @property {TypeColor} [colorLabel]
50
+ * @property {string} [label]
51
+ * @see {@link COL_Button}
52
+ * @interface
53
+ * @group Misc Shapes
54
+ */
55
+ export type OBJ_ButtonColorState = {
56
+ colorLine?: TypeColor;
57
+ colorFill?: TypeColor;
58
+ colorLabel?: TypeColor;
59
+ };
60
+ /**
61
+ * Button state options object.
62
+ *
63
+ * The `label` can either be the label text, or it can be the name of the form
64
+ * of the equation label.
65
+ *
66
+ * @property {TypeColor} [colorLine]
67
+ * @property {TypeColor} [colorFill]
68
+ * @property {TypeColor} [colorLabel]
69
+ * @property {string} [label]
70
+ * @see {@link COL_Button}
71
+ * @interface
72
+ * @group Misc Shapes
73
+ */
74
+ export type OBJ_ButtonState = {
75
+ colorLine?: TypeColor;
76
+ colorFill?: TypeColor;
77
+ colorLabel?: TypeColor;
78
+ label?: string;
79
+ };
80
+ /**
81
+ * {@link CollectionsButton} options object that extends {@link OBJ_Collection}
82
+ * options object (without `parent`).
83
+ *
84
+ * @property {number} [width] button width
85
+ * @property {number} [height] button height
86
+ * @property {OBJ_CurvedCorner} [corner] button corner
87
+ * @property {null | OBJ_LineStyleSimple} [line] button outline - use `null` to
88
+ * remove the default line
89
+ * @property {OBJ_ButtonLabel} [label] button label
90
+ * @property {TypeColor} [colorLine]
91
+ * @property {TypeColor} [colorFill]
92
+ * @property {TypeColor} [colorLabel]
93
+ * @property {OBJ_ButtonColorState>} [touchDown] set colors between a touch
94
+ * down and touch up
95
+ * @property {Array<OBJ_ButtonState | string>} [states]
96
+ *
97
+ * @extends OBJ_Collection
98
+ * @interface
99
+ * @group 2D Shape Collections
100
+ */
101
+ export type COL_Button = {
102
+ width?: number;
103
+ height?: number;
104
+ corner?: OBJ_CurvedCorner;
105
+ line?: null | OBJ_LineStyleSimple;
106
+ label?: OBJ_ButtonLabel;
107
+ colorLine?: TypeColor;
108
+ colorFill?: TypeColor;
109
+ colorLabel?: TypeColor;
110
+ touchDown?: OBJ_ButtonColorState;
111
+ states?: Array<OBJ_ButtonState | string>;
112
+ } & OBJ_Collection;
113
+ declare class ButtonLabel extends EquationLabel {
114
+ constructor(collections: FigureCollections, labelText: string | Equation | EQN_Equation | Array<string>, color: TypeColor, scale?: number, font?: OBJ_Font | null | undefined);
115
+ }
116
+ /**
117
+ * {@link FigureElementCollection} representing a button.
118
+ *
119
+ * ![](./apiassets/button.png)
120
+ *
121
+ * ![](./apiassets/button1.gif)
122
+ *
123
+ * A button can be simple, or it can change state with each press.
124
+ *
125
+ * Notifications - The notification manager property `notifications` will
126
+ * publish the following events:
127
+ * - `touch`: button is pressed - the current state index is passed to the
128
+ * subscriber
129
+ *
130
+ * See {@link COL_Button} for setup options.
131
+ *
132
+ * To test examples below, append them to the
133
+ * <a href="#drawing-boilerplate">boilerplate</a>
134
+ *
135
+ * @example
136
+ * // Simple button
137
+ * figure.add({
138
+ * make: 'collections.button',
139
+ * label: 'Start',
140
+ * });
141
+ *
142
+ * @example
143
+ * // Borderless button
144
+ * figure.add({
145
+ * make: 'collections.button',
146
+ * label: 'Start',
147
+ * colorFill: [0.8, 0.8, 0.8, 1],
148
+ * line: null,
149
+ * });
150
+ *
151
+ * @example
152
+ * // Button that changes state and has a touch buffer of 0.1 around it
153
+ * const button = figure.add({
154
+ * make: 'collections.button',
155
+ * states: ['Slow', 'Medium', 'Fast'],
156
+ * width: 0.7,
157
+ * height: 0.3,
158
+ * touchBorder: 0.1,
159
+ * });
160
+ *
161
+ * button.notifications.add('touch', (index) => {
162
+ * console.log(index);
163
+ * });
164
+ * @group 2D Shape Collections
165
+ */
166
+ declare class CollectionsButton extends FigureElementCollection {
167
+ _fill: FigureElementPrimitive;
168
+ _line: FigureElementPrimitive | null;
169
+ label: ButtonLabel | null;
170
+ _label: Equation | null;
171
+ width: number;
172
+ height: number;
173
+ states: Array<OBJ_ButtonState>;
174
+ touchDown: OBJ_ButtonColorState;
175
+ /**
176
+ * @hideconstructor
177
+ */
178
+ constructor(collections: FigureCollections, optionsIn: COL_Button);
179
+ incrementState(): void;
180
+ /**
181
+ * Set the button state index.
182
+ * @param {number} index
183
+ */
184
+ setStateIndex(index: number): void;
185
+ /**
186
+ * Get the current button state index.
187
+ * @return {number}
188
+ */
189
+ getStateIndex(): any;
190
+ getStateProperty(propertyName: string): any;
191
+ updateState(): void;
192
+ updateStateForTouch(down: boolean): void;
193
+ setLabel(text: string): void;
194
+ }
195
+ export default CollectionsButton;
@@ -0,0 +1,77 @@
1
+ import { Point } from '../../tools/g2';
2
+ import { Equation } from '../Equation/Equation';
3
+ import type { TypeVAlign, TypeHAlign } from '../Equation/EquationForm';
4
+ import type { EQN_Equation } from '../Equation/Equation';
5
+ import type { TypeColor } from '../../tools/types';
6
+ import type FigureCollections from './FigureCollections';
7
+ export type TypeLabelOptions = {
8
+ label?: string | Equation | Array<string> | EQN_Equation;
9
+ color?: TypeColor;
10
+ scale?: number;
11
+ position?: Point;
12
+ form?: string;
13
+ yAlign?: TypeVAlign;
14
+ xAlign?: TypeHAlign;
15
+ font?: any;
16
+ };
17
+ /**
18
+ * Orientation of the label.
19
+ *
20
+ * `'horizontal' | 'toLine' | 'awayLine' | 'upright'`
21
+ *
22
+ * Where:
23
+ * - `'horizontal'`: Label will be horizontal
24
+ * - `'baseToLine'`: Label will have same angle as line with text base toward
25
+ * the line
26
+ * - `'baseAway'`: Label will have same angle as line with text base away from
27
+ * the line
28
+ * - `'upright'`: Label will have same angle as line with text being more
29
+ * upright than upside down.
30
+ */
31
+ export type TypeLabelOrientation = 'horizontal' | 'baseAway' | 'baseToLine' | 'upright';
32
+ /**
33
+ * Label location relative to the line.
34
+ *
35
+ * `'top' | 'left' | 'bottom' | 'right' | 'start' | 'end' | 'positive' | 'negative'`
36
+ *
37
+ * '`top`' is in the positive y direction and `'right'` is in the positive
38
+ * x direction. '`bottom`' and '`left`' are the opposite sides respectively.
39
+ *
40
+ * `'positive'` is on the side of the line that the line rotates toward when
41
+ * rotating in the positive direction. `'negative'` is the opposite side.
42
+ *
43
+ * `'start'` is the start end of the line, while `'end'` is the opposide end
44
+ * of the line.
45
+ */
46
+ export type TypeLabelLocation = 'top' | 'left' | 'bottom' | 'right' | 'start' | 'end' | 'outside' | 'inside' | 'positive' | 'negative';
47
+ /**
48
+ * Label sub location relative to line.
49
+ *
50
+ * `'top' | 'left' | 'bottom' | 'right'`
51
+ *
52
+ * The label sub location is a fallback for when an invalid case is encountered
53
+ * by the primary location. When the primary location is `'top'` or `'bottom'`
54
+ * and the line is perfectly vertical, then the sub location would be used.
55
+ *
56
+ * Similarly, if the primary location is `'left'` or `'right'` and the line is
57
+ * perfectly horizontal, then the sub location would be used.
58
+ */
59
+ export type TypeLabelSubLocation = 'top' | 'left' | 'bottom' | 'right';
60
+ /**
61
+ * Equation label
62
+ * @group Misc Equation
63
+ */
64
+ export default class EquationLabel {
65
+ eqn: Equation;
66
+ height: number;
67
+ width: number;
68
+ aOffset: number;
69
+ lastOffsetMag: number;
70
+ constructor(collections: FigureCollections, options?: TypeLabelOptions);
71
+ showForm(formName: string): void;
72
+ setText(text: string): void;
73
+ getText(): string;
74
+ updateRotation(position: Point, lineAngle: number, offsetMag: number, location: 'top' | 'bottom' | 'left' | 'right' | 'positive' | 'negative' | 'start' | 'end' | 'inside' | 'outside', subLocation: 'top' | 'bottom' | 'left' | 'right', orientation: 'horizontal' | 'baseAway' | 'baseToLine' | 'upright', parentAngleOffset?: number, style?: 'oval' | 'rectangle', relativeToLine?: boolean, startThetaAngle?: number, endThetaAngle?: number): void;
75
+ getOvalOffset(labelAngle: number, h: number, w: number, offsetMag: number, offsetAngle: number, change: boolean, location: 'top' | 'bottom' | 'left' | 'right' | 'positive' | 'negative' | 'start' | 'end' | 'inside' | 'outside', startThetaAngle?: number, endThetaAngle?: number): Point;
76
+ }
77
+ export type TypeEquationLabel = EquationLabel;
@@ -0,0 +1,122 @@
1
+ import WebGLInstance from '../webgl/webgl';
2
+ import { Transform, Point } from '../../tools/g2';
3
+ import DrawContext2D from '../DrawContext2D';
4
+ import CollectionsLine from './Line';
5
+ import CollectionsAngle from './Angle';
6
+ import CollectionsPolyline from './PolyLine';
7
+ import CollectionsAxis from './Axis';
8
+ import CollectionsAxis3 from './Axis3';
9
+ import CollectionsTrace from './Trace';
10
+ import CollectionsToggle from './Toggle';
11
+ import CollectionsSlider from './Slider';
12
+ import CollectionsButton from './Button';
13
+ import type { COL_Toggle } from './Toggle';
14
+ import type { COL_Slider } from './Slider';
15
+ import type { COL_Button } from './Button';
16
+ import type { COL_Line } from './Line';
17
+ import type { COL_Angle } from './Angle';
18
+ import type { TypeLabelOptions } from './EquationLabel';
19
+ import type { COL_Polyline } from './PolyLine';
20
+ import type { COL_Axis } from './Axis';
21
+ import type { COL_Axis3 } from './Axis3';
22
+ import type { COL_Trace } from './Trace';
23
+ import type { COL_Plot } from './Plot';
24
+ import type { COL_Rectangle } from './Rectangle';
25
+ import EquationLabel from './EquationLabel';
26
+ import CollectionsPlot from './Plot';
27
+ import CollectionsPlotLegend from './Legend';
28
+ import CollectionsRectangle from './Rectangle';
29
+ import type { EQN_Equation } from '../Equation/Equation';
30
+ import { Equation } from '../Equation/Equation';
31
+ import type { OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
32
+ import SlideNavigator from './SlideNavigator';
33
+ import type { COL_SlideNavigator } from './SlideNavigator';
34
+ import { FigureElementCollection } from '../Element';
35
+ import type { TypeColor } from '../../tools/types';
36
+ import CollectionsText from './Text';
37
+ import type { OBJ_FormattedText } from './Text';
38
+ /**
39
+ * Built in figure collections.
40
+ *
41
+ * Provides advanced primitives the specific methods, animations and interactivity.
42
+ * @group Misc Shapes
43
+ */
44
+ export default class FigureCollections {
45
+ webgl: Array<WebGLInstance>;
46
+ draw2D: DrawContext2D;
47
+ primitives: any;
48
+ isTouchDevice: boolean;
49
+ animateNextFrame: () => void;
50
+ /**
51
+ * @hideconstructor
52
+ */
53
+ constructor(primitives: any, isTouchDevice: boolean, animateNextFrame: () => void);
54
+ /**
55
+ * Create a {@link FigureElementCollection}.
56
+ */
57
+ collection(transformOrPointOrOptions?: Transform | Point | OBJ_Collection, ...moreOptions: Array<OBJ_Collection>): FigureElementCollection;
58
+ /**
59
+ * Create a {@link CollectionsLine}.
60
+ */
61
+ line(...options: Array<COL_Line>): CollectionsLine;
62
+ /**
63
+ * Create a {@link CollectionsAngle}.
64
+ */
65
+ angle(...options: Array<COL_Angle>): CollectionsAngle;
66
+ label(...options: Array<TypeLabelOptions>): EquationLabel;
67
+ text(...options: Array<OBJ_FormattedText>): CollectionsText;
68
+ /**
69
+ * Create a {@link CollectionsPolyline}.
70
+ */
71
+ polyline(...options: Array<COL_Polyline>): CollectionsPolyline;
72
+ /**
73
+ * Create a {@link CollectionsRectangle}.
74
+ */
75
+ rectangle(...options: Array<COL_Rectangle>): CollectionsRectangle;
76
+ /**
77
+ * Create a {@link CollectionSlideNavigator}
78
+ */
79
+ slideNavigator(...options: Array<COL_SlideNavigator>): SlideNavigator;
80
+ /**
81
+ * Create a {@link CollectionsAixs}.
82
+ */
83
+ axis(...options: Array<COL_Axis>): CollectionsAxis;
84
+ /**
85
+ * Create a {@link CollectionsAixs3}.
86
+ */
87
+ axis3(...options: Array<COL_Axis3>): CollectionsAxis3;
88
+ /**
89
+ * Create a {@link CollectionToggle}.
90
+ */
91
+ toggle(...options: Array<COL_Toggle>): CollectionsToggle;
92
+ /**
93
+ * Create a {@link CollectionSlider}.
94
+ */
95
+ slider(...options: Array<COL_Slider>): CollectionsSlider;
96
+ /**
97
+ * Create a {@link CollectionSlider}.
98
+ */
99
+ button(...options: Array<COL_Button>): CollectionsButton;
100
+ /**
101
+ * Create a {@link CollectionsTrace}.
102
+ */
103
+ trace(...options: Array<COL_Trace>): CollectionsTrace;
104
+ /**
105
+ * Create a {@link CollectionsPlot}.
106
+ */
107
+ plot(...options: Array<COL_Plot>): CollectionsPlot;
108
+ /**
109
+ * Create a {@link CollectionsLegend}.
110
+ */
111
+ plotLegend(...options: Array<COL_Plot>): CollectionsPlotLegend;
112
+ /**
113
+ * Create a {@link Equation}.
114
+ */
115
+ equation(options: EQN_Equation): Equation;
116
+ addEquation(parent: FigureElementCollection, name: string, options?: EQN_Equation): Equation;
117
+ cursor(optionsIn: {
118
+ color: TypeColor;
119
+ width: number;
120
+ radius: number;
121
+ }): FigureElementCollection;
122
+ }
@@ -0,0 +1,270 @@
1
+ import { Point } from '../../tools/g2';
2
+ import type { TypeParsablePoint } from '../../tools/g2';
3
+ import { FigureElementCollection } from '../Element';
4
+ import type { COL_Trace } from './Trace';
5
+ import type CollectionsTrace from './Trace';
6
+ import type { OBJ_Font, OBJ_Font_Fixed } from '../../tools/types';
7
+ import type { OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
8
+ import type { OBJ_PlotFrame } from './Plot';
9
+ import type FigureCollections from './FigureCollections';
10
+ import type CollectionsRectangle from './Rectangle';
11
+ import type { OBJ_FormattedText } from './Text';
12
+ /**
13
+ * Legend customization for a single trace sample in the legend.
14
+ *
15
+ * @property {OBJ_Font} [font] default font
16
+ * @property {number} [length] length of the line sample
17
+ * @property {TypeParsablePoint} [offset] offset of this trace sample from
18
+ * the last trace sample
19
+ * @property {number} [space] space between line sample and text
20
+ * @property {boolean} [fontColorIsLineColor] use line color as font color
21
+ * @property {OBJ_TextLines | 'string'} [text] custom text
22
+ * @property {TypeParsablePoint} [position] position of the trace sample
23
+ * @interface
24
+ * @group Misc Shapes
25
+ */
26
+ export type OBJ_PlotLegendCustomTrace = {
27
+ font?: OBJ_Font;
28
+ length?: number;
29
+ offset?: TypeParsablePoint;
30
+ space?: number;
31
+ fontColorIsLineColor?: boolean;
32
+ text?: OBJ_FormattedText | 'string';
33
+ position?: TypeParsablePoint;
34
+ };
35
+ /**
36
+ * Legend customization options object
37
+ *
38
+ * Allows customization of specific trace samples in the legend.
39
+ * `_arrayIndexOrName` represents a generic key that should actually
40
+ * be the array index of the specific trace defined in {@link COL_PlotLegend}
41
+ * or the name of the trace. See examples in {@link CollectionsPlotLegend} for use.
42
+ *
43
+ * @property {OBJ_PlotLegendCustomTrace} [_arrayIndexOrName]
44
+ * @interface
45
+ * @group Misc Shapes
46
+ */
47
+ export type OBJ_PlotLegendCustom = {
48
+ [_arrayIndexOrName: string]: OBJ_PlotLegendCustomTrace;
49
+ };
50
+ /**
51
+ * {@link CollectionsPlotLegend} options object that extends {@link OBJ_Collection}
52
+ * options object (without `parent`).
53
+ *
54
+ * A legend consists of a number of trace samples and their corresponding names,
55
+ * and may have an encompassing frame with a border and fill.
56
+ *
57
+ * @extends OBJ_Collection
58
+ *
59
+ * @property {TypeParsablePoint} [position] position of the first trace in the
60
+ * legend
61
+ * @property {number} [length] length of the line sample
62
+ * @property {number} [space] space between the line and the text
63
+ * @property {Array<TypeParsablePoint> | TypeParsablePoint} [offset] offset
64
+ * between trace samples - can be used to space out a legend, or make it
65
+ * horizontal
66
+ * @property {OBJ_Font} [font] default font for trace sample text
67
+ * @property {boolean} [fontColorIsLineColor] set the trace sample text color to
68
+ * the same as the line sample
69
+ * @property {Array<number> | OBJ_PlotFrame} [frame] frame around the legend -
70
+ * specifying just a color will create a solid fill rectangle of that color
71
+ * @property {Array<number>} [show] array of which trace indeces to show if only
72
+ * some should be shown
73
+ * @property {Array<number>} [hide] array of which trace indeces to hide if some
74
+ * should be hidden
75
+ * @property {OBJ_PlotLegendCustom} [custom] customizations to specific trace
76
+ * samples
77
+ * @property {Array<COL_Trace>} [traces] the traces from the plot that this
78
+ * legend will display. This is used by {@link CollectionsPlot} and should not be
79
+ * used by the user.
80
+ * @interface
81
+ * @group Misc Shapes
82
+ */
83
+ export type COL_PlotLegend = {
84
+ position?: TypeParsablePoint;
85
+ length?: number;
86
+ space?: number;
87
+ offset?: Array<TypeParsablePoint> | TypeParsablePoint;
88
+ font?: OBJ_Font;
89
+ fontColorIsLineColor?: boolean;
90
+ frame?: Array<number> | OBJ_PlotFrame;
91
+ show?: Array<number>;
92
+ hide?: Array<number>;
93
+ custom?: OBJ_PlotLegendCustom;
94
+ traces: Array<COL_Trace>;
95
+ } & OBJ_Collection;
96
+ /**
97
+ * {@link FigureElementCollection} representing an legend.
98
+ *
99
+ * ![](./apiassets/advlegend_ex1.png)
100
+ * ![](./apiassets/advlegend_ex2.png)
101
+ *
102
+ * ![](./apiassets/advlegend_ex3.png)
103
+ * ![](./apiassets/advlegend_ex4.png)
104
+ *
105
+ * ![](./apiassets/advlegend_ex5.png)
106
+ *
107
+ * This object defines a legend in an {@link CollectionsPlot}.
108
+ *
109
+ * The legend includes traces, trace names and a frame. Each can be customized
110
+ * using the {@link COL_PlotLegend} options object.
111
+ *
112
+ * To test examples below, append them to the
113
+ * <a href="#drawing-boilerplate">boilerplate</a>.
114
+ *
115
+ * All examples below also use this power function to generate the traces:
116
+ * ```javascript
117
+ * const pow = (pow = 2, start = 0, stop = 10, step = 0.05) => {
118
+ * const xValues = Fig.range(start, stop, step);
119
+ * return xValues.map(x => new Fig.Point(x, x ** pow));
120
+ * }
121
+ * ```
122
+ *
123
+ * @example
124
+ * // By default, the legend will appear in the top right corner
125
+ * figure.add({
126
+ * name: 'plot',
127
+ * make: 'collections.plot',
128
+ * trace: [
129
+ * { points: pow(2), name: 'Power 2' },
130
+ * { points: pow(2.5), name: 'Power 2.5' },
131
+ * {
132
+ * points: pow(3, 0, 10, 0.5),
133
+ * name: 'Power 3',
134
+ * markers: { radius: 0.03, sides: 10 },
135
+ * },
136
+ * ],
137
+ * legend: true,
138
+ * });
139
+ *
140
+ * @example
141
+ * // Change the line length, position and use a frame on the legend
142
+ * figure.add({
143
+ * name: 'plot',
144
+ * make: 'collections.plot',
145
+ * trace: [
146
+ * { points: pow(2), name: 'Power 2' },
147
+ * { points: pow(2.5), name: 'Power 2.5' },
148
+ * {
149
+ * points: pow(3, 0, 10, 0.5),
150
+ * name: 'Power 3',
151
+ * markers: { radius: 0.03, sides: 10 },
152
+ * },
153
+ * ],
154
+ * legend: {
155
+ * length: 0.5,
156
+ * frame: [0.95, 0.95, 0.95, 1],
157
+ * position: [0.2, 1.8],
158
+ * },
159
+ * });
160
+ *
161
+ * @example
162
+ * // Make a horizontal legend
163
+ * figure.add({
164
+ * name: 'plot',
165
+ * make: 'collections.plot',
166
+ * trace: [
167
+ * { points: pow(2), name: 'Power 2' },
168
+ * { points: pow(2.5), name: 'Power 2.5' },
169
+ * {
170
+ * points: pow(3, 0, 10, 0.5),
171
+ * name: 'Power 3',
172
+ * markers: { radius: 0.03, sides: 10 },
173
+ * },
174
+ * ],
175
+ * legend: {
176
+ * offset: [0.9, 0],
177
+ * position: [-0.3, -0.5],
178
+ * frame: {
179
+ * line: { width: 0.005 },
180
+ * corner: { radius: 0.05, sides: 10 },
181
+ * },
182
+ * },
183
+ * });
184
+ *
185
+ * @example
186
+ * // Customize legend trace text
187
+ * figure.add({
188
+ * name: 'plot',
189
+ * make: 'collections.plot',
190
+ * trace: [
191
+ * { points: pow(2), name: 'Power 2' },
192
+ * { points: pow(2.5), name: 'Power 2.5' },
193
+ * {
194
+ * points: pow(3, 0, 10, 0.5),
195
+ * name: 'Power 3',
196
+ * markers: { radius: 0.03, sides: 10 },
197
+ * },
198
+ * ],
199
+ * legend: {
200
+ * offset: [0, -0.2],
201
+ * custom: {
202
+ * 1: {
203
+ * font: { size: 0.1, style: 'italic', color: [1, 0, 0, 1] },
204
+ * text: {
205
+ * text: [
206
+ * 'Power 2.5',
207
+ * {
208
+ * text: 'Reference Trace',
209
+ * font: { size: 0.06 },
210
+ * lineSpace: 0.06,
211
+ * },
212
+ * ],
213
+ * justify: 'left',
214
+ * },
215
+ * },
216
+ * },
217
+ * },
218
+ * });
219
+ *
220
+ * @example
221
+ * // Customize legend
222
+ * figure.add({
223
+ * name: 'plot',
224
+ * make: 'collections.plot',
225
+ * trace: [
226
+ * { points: pow(2), name: 'Power 2' },
227
+ * { points: pow(2.5), name: 'Power 2.5' },
228
+ * {
229
+ * points: pow(3, 10, 0.5),
230
+ * name: 'Power 3',
231
+ * markers: { radius: 0.03, sides: 10 },
232
+ * },
233
+ * ],
234
+ * legend: {
235
+ * fontColorIsLineColor: true,
236
+ * length: 0,
237
+ * custom: {
238
+ * 0: { position: [2, 0.2] },
239
+ * 1: { position: [2, 0.7] },
240
+ * 'Power 3': { position: [2, 2] },
241
+ * }
242
+ * },
243
+ * });
244
+ * @group Misc Shapes
245
+ */
246
+ declare class CollectionsPlotLegend extends FigureElementCollection {
247
+ _frame: CollectionsRectangle | null | undefined;
248
+ defaultFont: OBJ_Font_Fixed;
249
+ traces: Array<CollectionsTrace>;
250
+ offset: Array<Point>;
251
+ toShow: Array<number>;
252
+ frameSpace: number;
253
+ /**
254
+ * @hideconstructor
255
+ */
256
+ constructor(collections: FigureCollections, optionsIn: COL_PlotLegend);
257
+ getTraceIndex(name: string | number): number;
258
+ getTracesToShow(o: {
259
+ show?: any;
260
+ hide?: any;
261
+ }): number[];
262
+ getOffset(o: {
263
+ offset: Array<TypeParsablePoint> | TypeParsablePoint;
264
+ }): Point[];
265
+ addTraces(o: COL_PlotLegend): void;
266
+ addFrame(optionsIn: Record<string, any> | boolean | Array<number>): void;
267
+ fontUpdated(): void;
268
+ update(): void;
269
+ }
270
+ export default CollectionsPlotLegend;