figureone 1.5.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/figureone.min.js +1 -1
- package/index.js +1069 -144
- package/llms-full.txt +65 -0
- package/llms.txt +17 -0
- package/package.json +1 -1
- package/types/js/figure/Element.d.ts +12 -3
- package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +4 -1
- package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +2 -1
- package/types/js/figure/Equation/Elements/DrawOrder.d.ts +6 -0
- package/types/js/figure/Equation/Elements/Element.d.ts +11 -3
- package/types/js/figure/Equation/Elements/Opacity.d.ts +6 -0
- package/types/js/figure/Equation/Equation.d.ts +18 -0
- package/types/js/figure/Equation/EquationForm.d.ts +4 -0
- package/types/js/figure/Equation/EquationFunctions.d.ts +300 -2
- package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +1 -1
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +1 -1
|
@@ -11,6 +11,8 @@ import Container from './Elements/Container';
|
|
|
11
11
|
import BaseAnnotationFunction from './Elements/BaseAnnotationFunction';
|
|
12
12
|
import Offset from './Elements/Offset';
|
|
13
13
|
import Color from './Elements/Color';
|
|
14
|
+
import Opacity from './Elements/Opacity';
|
|
15
|
+
import DrawOrder from './Elements/DrawOrder';
|
|
14
16
|
import type { TypeColor } from '../../tools/types';
|
|
15
17
|
export declare function getFigureElement(elementsObject: {
|
|
16
18
|
[key: string]: FigureElementPrimitive | FigureElementCollection;
|
|
@@ -46,6 +48,10 @@ export declare function getFigureElement(elementsObject: {
|
|
|
46
48
|
* - `{ prodOf: `{@link EQN_ProdOf} `}`
|
|
47
49
|
* - `{ topStrike: `{@link EQN_StrikeComment} `}`
|
|
48
50
|
* - `{ bottomStrike: `{@link EQN_StrikeComment} `}`
|
|
51
|
+
* - `{ color: `{@link EQN_Color} `}`
|
|
52
|
+
* - `{ opacity: `{@link EQN_Opacity} `}`
|
|
53
|
+
* - `{ back: `{@link EQN_Back} `}`
|
|
54
|
+
* - `{ front: `{@link EQN_Front} `}`
|
|
49
55
|
* - `{ make: string, name?: string, ... }` (inline element — creates any
|
|
50
56
|
* element type directly in a form using the same `make` values as
|
|
51
57
|
* {@link Figure.add}. If `name` is omitted, one is auto-generated.)
|
|
@@ -142,6 +148,14 @@ export type TypeEquationPhrase = string | number | {
|
|
|
142
148
|
topStrike: EQN_StrikeComment;
|
|
143
149
|
} | {
|
|
144
150
|
bottomStrike: EQN_StrikeComment;
|
|
151
|
+
} | {
|
|
152
|
+
color: EQN_Color;
|
|
153
|
+
} | {
|
|
154
|
+
opacity: EQN_Opacity;
|
|
155
|
+
} | {
|
|
156
|
+
back: EQN_Back;
|
|
157
|
+
} | {
|
|
158
|
+
front: EQN_Front;
|
|
145
159
|
} | {
|
|
146
160
|
make: string;
|
|
147
161
|
name?: string;
|
|
@@ -564,6 +578,25 @@ export type EQN_Scale = {
|
|
|
564
578
|
* },
|
|
565
579
|
* touch: { onClick: e => e.nextForm() },
|
|
566
580
|
* });
|
|
581
|
+
* @example
|
|
582
|
+
* // The `color` function recolours a phrase explicitly. Separately, an element
|
|
583
|
+
* // can opt out of the equation's default ('form') colour cascade with
|
|
584
|
+
* // `ignoreSetColor`, while still accepting explicit colour commands. Here both
|
|
585
|
+
* // squares start blue; recolouring the whole equation to grey greys the left
|
|
586
|
+
* // (free) square, but the right (locked) square keeps its colour.
|
|
587
|
+
* const blue = [0, 0, 1, 1];
|
|
588
|
+
* const locked = figure.primitives.rectangle({ width: 0.5, height: 0.5, color: blue });
|
|
589
|
+
* locked.ignoreSetColor = 'form'; // ignore the default cascade, keep blue
|
|
590
|
+
* const eqn = figure.add({
|
|
591
|
+
* make: 'equation',
|
|
592
|
+
* color: [1, 0, 0, 1],
|
|
593
|
+
* elements: {
|
|
594
|
+
* free: figure.primitives.rectangle({ width: 0.5, height: 0.5, color: blue }),
|
|
595
|
+
* locked,
|
|
596
|
+
* },
|
|
597
|
+
* forms: { 0: ['free', ' ', 'locked'] },
|
|
598
|
+
* });
|
|
599
|
+
* eqn.setColor([0.5, 0.5, 0.5, 1], true, 'form'); // free -> grey, locked stays blue
|
|
567
600
|
* @interface
|
|
568
601
|
* @group Equation Layout
|
|
569
602
|
*/
|
|
@@ -577,6 +610,255 @@ export type EQN_Color = {
|
|
|
577
610
|
TypeColor,
|
|
578
611
|
(boolean | null | undefined)
|
|
579
612
|
];
|
|
613
|
+
/**
|
|
614
|
+
* Equation opacity function
|
|
615
|
+
*
|
|
616
|
+
* Set an opacity multiplier on an equation phrase. The opacity cascades
|
|
617
|
+
* multiplicatively, so nested `opacity` functions multiply together (e.g. an
|
|
618
|
+
* outer `0.5` around an inner `0.5` yields `0.25` on the inner content).
|
|
619
|
+
*
|
|
620
|
+
* Opacity values are expected to be in the range `[0, 1]`. Whenever the form
|
|
621
|
+
* is shown, the cascaded opacity is assigned to each wrapped element, overriding
|
|
622
|
+
* any externally-set element `opacity`. Set `ignoreOpacity: true` on the form
|
|
623
|
+
* to suppress this and preserve externally-set opacities.
|
|
624
|
+
*
|
|
625
|
+
* Options can be an object, or an array in the property order below
|
|
626
|
+
*
|
|
627
|
+
* @property {TypeEquationPhrase} content
|
|
628
|
+
* @property {number} opacity opacity multiplier in the range `[0, 1]`
|
|
629
|
+
* @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
|
|
630
|
+
*
|
|
631
|
+
* @see To test examples, append them to the
|
|
632
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
633
|
+
*
|
|
634
|
+
* @example
|
|
635
|
+
* // Simple Array Definition
|
|
636
|
+
* figure.add({
|
|
637
|
+
* make: 'equation',
|
|
638
|
+
* forms: {
|
|
639
|
+
* 0: ['a', { opacity: ['b', 0.3] }, 'c'],
|
|
640
|
+
* },
|
|
641
|
+
* });
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* // Simple Object Definition
|
|
645
|
+
* figure.add({
|
|
646
|
+
* make: 'equation',
|
|
647
|
+
* forms: {
|
|
648
|
+
* 0: [
|
|
649
|
+
* 'a',
|
|
650
|
+
* {
|
|
651
|
+
* opacity: {
|
|
652
|
+
* content: 'b',
|
|
653
|
+
* opacity: 0.3,
|
|
654
|
+
* },
|
|
655
|
+
* },
|
|
656
|
+
* 'c',
|
|
657
|
+
* ],
|
|
658
|
+
* },
|
|
659
|
+
* });
|
|
660
|
+
*
|
|
661
|
+
* @interface
|
|
662
|
+
* @group Equation Layout
|
|
663
|
+
*/
|
|
664
|
+
export type EQN_Opacity = {
|
|
665
|
+
content: TypeEquationPhrase;
|
|
666
|
+
opacity: number;
|
|
667
|
+
fullContentBounds?: boolean;
|
|
668
|
+
name?: string;
|
|
669
|
+
} | [
|
|
670
|
+
TypeEquationPhrase,
|
|
671
|
+
number,
|
|
672
|
+
(boolean | null | undefined)
|
|
673
|
+
];
|
|
674
|
+
/**
|
|
675
|
+
* Equation back function
|
|
676
|
+
*
|
|
677
|
+
* Send an equation phrase's elements back in the equation's draw stack. All
|
|
678
|
+
* elements within `content` are moved together as a group, keeping their
|
|
679
|
+
* current relative draw order. Nested `front`/`back` functions are applied
|
|
680
|
+
* inner-most first, so an inner `front`/`back` reorders the elements and this
|
|
681
|
+
* (outer) function then moves the reordered group as a unit.
|
|
682
|
+
*
|
|
683
|
+
* The group's position is determined by, in order of precedence:
|
|
684
|
+
* - `before` - position the group just before (behind) the most-back of the
|
|
685
|
+
* named anchor element(s). `num` shifts it further back (default `0`).
|
|
686
|
+
* - `after` - position the group just after (in front of) the most-front of
|
|
687
|
+
* the named anchor element(s). `num` shifts it further forward (default `0`).
|
|
688
|
+
* - `num` - a positive value moves the group that many places back; a negative
|
|
689
|
+
* value positions it `|num|` places ahead of the very back.
|
|
690
|
+
* - otherwise the group is sent completely to the back.
|
|
691
|
+
*
|
|
692
|
+
* The reorder is applied whenever the form is shown, relative to the equation's
|
|
693
|
+
* natural (definition) draw order, so each form deterministically defines its
|
|
694
|
+
* own stacking.
|
|
695
|
+
*
|
|
696
|
+
* Options can be an object, or an array in the property order below
|
|
697
|
+
*
|
|
698
|
+
* @property {TypeEquationPhrase} content
|
|
699
|
+
* @property {number} [num] places to send the group back (positive), or an
|
|
700
|
+
* absolute position `|num|` places ahead of the full back (negative). When
|
|
701
|
+
* `before`/`after` is set, `num` is the offset from the anchor (default `0`).
|
|
702
|
+
* If undefined (and no anchor), the group is sent completely to the back
|
|
703
|
+
* @property {string | Array<string>} [before] anchor element name(s) - position
|
|
704
|
+
* the group just before the most-back anchor
|
|
705
|
+
* @property {string | Array<string>} [after] anchor element name(s) - position
|
|
706
|
+
* the group just after the most-front anchor
|
|
707
|
+
* @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
|
|
708
|
+
*
|
|
709
|
+
* @see To test examples, append them to the
|
|
710
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* // Three overlapping squares, offset so the stacking order is visible. Blue
|
|
714
|
+
* // is defined last so it sits on top by default; `back` sends it behind the
|
|
715
|
+
* // red and green squares (so green ends up on top).
|
|
716
|
+
* const sq = color => figure.primitives.rectangle({ width: 0.6, height: 0.6, color });
|
|
717
|
+
* figure.add({
|
|
718
|
+
* make: 'equation',
|
|
719
|
+
* elements: {
|
|
720
|
+
* r: sq([1, 0, 0, 1]),
|
|
721
|
+
* g: sq([0, 0.8, 0, 1]),
|
|
722
|
+
* b: sq([0, 0, 1, 1]),
|
|
723
|
+
* },
|
|
724
|
+
* forms: {
|
|
725
|
+
* 0: [
|
|
726
|
+
* { offset: ['r', [0, 0]] },
|
|
727
|
+
* { offset: ['g', [0.3, -0.25]] },
|
|
728
|
+
* { offset: [{ back: ['b'] }, [0.6, -0.5]] },
|
|
729
|
+
* ],
|
|
730
|
+
* },
|
|
731
|
+
* });
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* // Object Definition with an anchor - position the blue square just before
|
|
735
|
+
* // (behind) the red square, so red and green sit on top of it.
|
|
736
|
+
* const sq = color => figure.primitives.rectangle({ width: 0.6, height: 0.6, color });
|
|
737
|
+
* figure.add({
|
|
738
|
+
* make: 'equation',
|
|
739
|
+
* elements: {
|
|
740
|
+
* r: sq([1, 0, 0, 1]),
|
|
741
|
+
* g: sq([0, 0.8, 0, 1]),
|
|
742
|
+
* b: sq([0, 0, 1, 1]),
|
|
743
|
+
* },
|
|
744
|
+
* forms: {
|
|
745
|
+
* 0: [
|
|
746
|
+
* { offset: ['r', [0, 0]] },
|
|
747
|
+
* { offset: ['g', [0.3, -0.25]] },
|
|
748
|
+
* { offset: [{ back: { content: 'b', before: 'r' } }, [0.6, -0.5]] },
|
|
749
|
+
* ],
|
|
750
|
+
* },
|
|
751
|
+
* });
|
|
752
|
+
*
|
|
753
|
+
* @interface
|
|
754
|
+
* @group Equation Layout
|
|
755
|
+
*/
|
|
756
|
+
export type EQN_Back = {
|
|
757
|
+
content: TypeEquationPhrase;
|
|
758
|
+
num?: number;
|
|
759
|
+
before?: string | Array<string>;
|
|
760
|
+
after?: string | Array<string>;
|
|
761
|
+
fullContentBounds?: boolean;
|
|
762
|
+
name?: string;
|
|
763
|
+
} | [
|
|
764
|
+
TypeEquationPhrase,
|
|
765
|
+
(number | null | undefined),
|
|
766
|
+
(boolean | null | undefined)
|
|
767
|
+
];
|
|
768
|
+
/**
|
|
769
|
+
* Equation front function
|
|
770
|
+
*
|
|
771
|
+
* Bring an equation phrase's elements forward in the equation's draw stack. All
|
|
772
|
+
* elements within `content` are moved together as a group, keeping their
|
|
773
|
+
* current relative draw order. Nested `front`/`back` functions are applied
|
|
774
|
+
* inner-most first, so an inner `front`/`back` reorders the elements and this
|
|
775
|
+
* (outer) function then moves the reordered group as a unit.
|
|
776
|
+
*
|
|
777
|
+
* The group's position is determined by, in order of precedence:
|
|
778
|
+
* - `before` - position the group just before (behind) the most-back of the
|
|
779
|
+
* named anchor element(s). `num` shifts it further back (default `0`).
|
|
780
|
+
* - `after` - position the group just after (in front of) the most-front of
|
|
781
|
+
* the named anchor element(s). `num` shifts it further forward (default `0`).
|
|
782
|
+
* - `num` - a positive value moves the group that many places forward; a
|
|
783
|
+
* negative value positions it `|num|` places behind the very front.
|
|
784
|
+
* - otherwise the group is brought completely to the front.
|
|
785
|
+
*
|
|
786
|
+
* The reorder is applied whenever the form is shown, relative to the equation's
|
|
787
|
+
* natural (definition) draw order, so each form deterministically defines its
|
|
788
|
+
* own stacking.
|
|
789
|
+
*
|
|
790
|
+
* Options can be an object, or an array in the property order below
|
|
791
|
+
*
|
|
792
|
+
* @property {TypeEquationPhrase} content
|
|
793
|
+
* @property {number} [num] places to bring the group forward (positive), or an
|
|
794
|
+
* absolute position `|num|` places behind the full front (negative). When
|
|
795
|
+
* `before`/`after` is set, `num` is the offset from the anchor (default `0`).
|
|
796
|
+
* If undefined (and no anchor), the group is brought completely to the front
|
|
797
|
+
* @property {string | Array<string>} [before] anchor element name(s) - position
|
|
798
|
+
* the group just before the most-back anchor
|
|
799
|
+
* @property {string | Array<string>} [after] anchor element name(s) - position
|
|
800
|
+
* the group just after the most-front anchor
|
|
801
|
+
* @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
|
|
802
|
+
*
|
|
803
|
+
* @see To test examples, append them to the
|
|
804
|
+
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* // Three overlapping squares, offset so the stacking order is visible. Red is
|
|
808
|
+
* // defined first so it sits at the back by default; `front` brings it on top
|
|
809
|
+
* // of the green and blue squares.
|
|
810
|
+
* const sq = color => figure.primitives.rectangle({ width: 0.6, height: 0.6, color });
|
|
811
|
+
* figure.add({
|
|
812
|
+
* make: 'equation',
|
|
813
|
+
* elements: {
|
|
814
|
+
* r: sq([1, 0, 0, 1]),
|
|
815
|
+
* g: sq([0, 0.8, 0, 1]),
|
|
816
|
+
* b: sq([0, 0, 1, 1]),
|
|
817
|
+
* },
|
|
818
|
+
* forms: {
|
|
819
|
+
* 0: [
|
|
820
|
+
* { offset: [{ front: ['r'] }, [0, 0]] },
|
|
821
|
+
* { offset: ['g', [0.3, -0.25]] },
|
|
822
|
+
* { offset: ['b', [0.6, -0.5]] },
|
|
823
|
+
* ],
|
|
824
|
+
* },
|
|
825
|
+
* });
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
* // Object Definition with an anchor - position the red square just after (in
|
|
829
|
+
* // front of) the green square, so it covers green but stays behind blue.
|
|
830
|
+
* const sq = color => figure.primitives.rectangle({ width: 0.6, height: 0.6, color });
|
|
831
|
+
* figure.add({
|
|
832
|
+
* make: 'equation',
|
|
833
|
+
* elements: {
|
|
834
|
+
* r: sq([1, 0, 0, 1]),
|
|
835
|
+
* g: sq([0, 0.8, 0, 1]),
|
|
836
|
+
* b: sq([0, 0, 1, 1]),
|
|
837
|
+
* },
|
|
838
|
+
* forms: {
|
|
839
|
+
* 0: [
|
|
840
|
+
* { offset: [{ front: { content: 'r', after: 'g' } }, [0, 0]] },
|
|
841
|
+
* { offset: ['g', [0.3, -0.25]] },
|
|
842
|
+
* { offset: ['b', [0.6, -0.5]] },
|
|
843
|
+
* ],
|
|
844
|
+
* },
|
|
845
|
+
* });
|
|
846
|
+
*
|
|
847
|
+
* @interface
|
|
848
|
+
* @group Equation Layout
|
|
849
|
+
*/
|
|
850
|
+
export type EQN_Front = {
|
|
851
|
+
content: TypeEquationPhrase;
|
|
852
|
+
num?: number;
|
|
853
|
+
before?: string | Array<string>;
|
|
854
|
+
after?: string | Array<string>;
|
|
855
|
+
fullContentBounds?: boolean;
|
|
856
|
+
name?: string;
|
|
857
|
+
} | [
|
|
858
|
+
TypeEquationPhrase,
|
|
859
|
+
(number | null | undefined),
|
|
860
|
+
(boolean | null | undefined)
|
|
861
|
+
];
|
|
580
862
|
/**
|
|
581
863
|
* Equation bracket
|
|
582
864
|
*
|
|
@@ -3272,8 +3554,8 @@ export declare class EquationFunctions {
|
|
|
3272
3554
|
stringToElement(content: string): any;
|
|
3273
3555
|
parseContent(content: TypeEquationPhrase | null | undefined): any;
|
|
3274
3556
|
contentToElement(content: TypeEquationPhrase | Elements | FigureElementPrimitive | FigureElementCollection): Elements;
|
|
3275
|
-
eqnMethod(name: string, params: any): BaseAnnotationFunction | Fraction | Matrix | Lines | Scale | Container | Offset | Color | null;
|
|
3276
|
-
dispatchEqnMethod(name: string, params: any): BaseAnnotationFunction | Fraction | Matrix | Lines | Scale | Container | Offset | Color | null;
|
|
3557
|
+
eqnMethod(name: string, params: any): BaseAnnotationFunction | Fraction | Matrix | Lines | Scale | Container | Offset | Color | Opacity | DrawOrder | null;
|
|
3558
|
+
dispatchEqnMethod(name: string, params: any): BaseAnnotationFunction | Fraction | Matrix | Lines | Scale | Container | Offset | Color | Opacity | DrawOrder | null;
|
|
3277
3559
|
/**
|
|
3278
3560
|
* Equation container function
|
|
3279
3561
|
* @see {@link EQN_Container} for description and examples
|
|
@@ -3309,6 +3591,22 @@ export declare class EquationFunctions {
|
|
|
3309
3591
|
* @see {@link EQN_Color} for description and examples
|
|
3310
3592
|
*/
|
|
3311
3593
|
color(options: EQN_Color): Color;
|
|
3594
|
+
/**
|
|
3595
|
+
* Equation opacity function
|
|
3596
|
+
* @see {@link EQN_Opacity} for description and examples
|
|
3597
|
+
*/
|
|
3598
|
+
opacity(options: EQN_Opacity): Opacity;
|
|
3599
|
+
/**
|
|
3600
|
+
* Equation back function
|
|
3601
|
+
* @see {@link EQN_Back} for description and examples
|
|
3602
|
+
*/
|
|
3603
|
+
back(options: EQN_Back): DrawOrder;
|
|
3604
|
+
/**
|
|
3605
|
+
* Equation front function
|
|
3606
|
+
* @see {@link EQN_Front} for description and examples
|
|
3607
|
+
*/
|
|
3608
|
+
front(options: EQN_Front): DrawOrder;
|
|
3609
|
+
drawOrder(options: EQN_Front | EQN_Back, front: boolean): DrawOrder;
|
|
3312
3610
|
/**
|
|
3313
3611
|
* Equation fraction function
|
|
3314
3612
|
* @see {@link EQN_Fraction} for description and examples
|
|
@@ -108,7 +108,7 @@ export default class FigureElementPrimitive2DText extends FigureElementPrimitive
|
|
|
108
108
|
* @return {FigureFont}
|
|
109
109
|
*/
|
|
110
110
|
getFont(): FigureFont;
|
|
111
|
-
setColor(color: TypeColor, setDefault?: boolean): void;
|
|
111
|
+
setColor(color: TypeColor, setDefault?: boolean, from?: string | null): void;
|
|
112
112
|
stateSet(): void;
|
|
113
113
|
measureAndAlignText(): void;
|
|
114
114
|
_getStateProperties(options: {
|
|
@@ -81,7 +81,7 @@ export default class FigureElementPrimitiveGLText extends FigureElementPrimitive
|
|
|
81
81
|
* @param {OBJ_Font} font
|
|
82
82
|
*/
|
|
83
83
|
setFont(font: OBJ_Font): void;
|
|
84
|
-
setColor(color: TypeColor, setDefault?: boolean): void;
|
|
84
|
+
setColor(color: TypeColor, setDefault?: boolean, from?: string | null): void;
|
|
85
85
|
calcBorderAndBounds(): void;
|
|
86
86
|
calcBorder(): void;
|
|
87
87
|
stateSet(): void;
|