@rnacanvas/draw.floating 3.3.0 → 4.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/README.md +278 -1
- package/dist/Drawing.d.ts +9 -0
- package/dist/Drawing.d.ts.map +1 -1
- package/dist/StrungCircle.d.ts +18 -0
- package/dist/StrungCircle.d.ts.map +1 -0
- package/dist/StrungElementOwner.d.ts +5 -0
- package/dist/StrungElementOwner.d.ts.map +1 -0
- package/dist/StrungRectangle.d.ts +24 -0
- package/dist/StrungRectangle.d.ts.map +1 -0
- package/dist/StrungText.d.ts +19 -0
- package/dist/StrungText.d.ts.map +1 -0
- package/dist/StrungTriangle.d.ts +24 -0
- package/dist/StrungTriangle.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -2
- package/tsconfig.json +1 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ All exports of this package can be accessed as named imports.
|
|
|
12
12
|
|
|
13
13
|
```javascript
|
|
14
14
|
// some example imports
|
|
15
|
-
import { Text, Circle, Rectangle } from '@rnacanvas/draw.floating';
|
|
15
|
+
import { Text, Circle, Rectangle, Triangle } from '@rnacanvas/draw.floating';
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## `class Text`
|
|
@@ -678,6 +678,10 @@ var rectangle = Rectangle.create();
|
|
|
678
678
|
var savedRectangle = rectangle.serialized();
|
|
679
679
|
```
|
|
680
680
|
|
|
681
|
+
Throws if the ID of the rectangle is falsy.
|
|
682
|
+
|
|
683
|
+
<b>Rectangles must have an ID to be serializable.</b>
|
|
684
|
+
|
|
681
685
|
### `static recreate()`
|
|
682
686
|
|
|
683
687
|
Recreates a saved rectangle given the parent drawing that its DOM node is in.
|
|
@@ -697,3 +701,276 @@ rectangle2.domNode === rectangle1.domNode; // true
|
|
|
697
701
|
|
|
698
702
|
rectangle2 === rectangle1; // false
|
|
699
703
|
```
|
|
704
|
+
|
|
705
|
+
## `class Triangle`
|
|
706
|
+
|
|
707
|
+
A triangle element.
|
|
708
|
+
|
|
709
|
+
```javascript
|
|
710
|
+
var triangle = Triangle.create();
|
|
711
|
+
|
|
712
|
+
// set center coordinates
|
|
713
|
+
triangle.centerX = 10;
|
|
714
|
+
triangle.centerY = 20;
|
|
715
|
+
|
|
716
|
+
triangle.width = 15;
|
|
717
|
+
triangle.height = 25;
|
|
718
|
+
|
|
719
|
+
// black stroke
|
|
720
|
+
triangle.domNode.setAttribute('stroke', 'black');
|
|
721
|
+
triangle.domNode.setAttribute('stroke-width', '1');
|
|
722
|
+
|
|
723
|
+
// white filling
|
|
724
|
+
triangle.domNode.setAttribute('fill', 'white');
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
### `static create()`
|
|
728
|
+
|
|
729
|
+
Creates a new triangle from scratch.
|
|
730
|
+
|
|
731
|
+
```javascript
|
|
732
|
+
var triangle = Triangle.create();
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
The triangle will be created with a UUID
|
|
736
|
+
and with some default values
|
|
737
|
+
(e.g., width and height, stroke and fill colors).
|
|
738
|
+
|
|
739
|
+
### `constructor()`
|
|
740
|
+
|
|
741
|
+
Constructs a new triangle instance wrapping the specified SVG path element.
|
|
742
|
+
|
|
743
|
+
```javascript
|
|
744
|
+
var domNode = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
745
|
+
|
|
746
|
+
var triangle = new Triangle(domNode);
|
|
747
|
+
|
|
748
|
+
triangle.domNode === domNode; // true
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
The input SVG path element is not modified in any way by this constructor.
|
|
752
|
+
|
|
753
|
+
This constructor is more meant for internal use
|
|
754
|
+
(e.g., when recreating saved triangle elements).
|
|
755
|
+
|
|
756
|
+
### `readonly domNode`
|
|
757
|
+
|
|
758
|
+
The SVG path element corresponding to the triangle element.
|
|
759
|
+
|
|
760
|
+
```javascript
|
|
761
|
+
var triangle = Triangle.create();
|
|
762
|
+
|
|
763
|
+
triangle.domNode instanceof SVGPathElement; // true
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
### `readonly id`
|
|
767
|
+
|
|
768
|
+
The ID of the triangle.
|
|
769
|
+
|
|
770
|
+
Is equal to the `id` attribute of the underlying SVG path element.
|
|
771
|
+
|
|
772
|
+
```javascript
|
|
773
|
+
var triangle = Triangle.create();
|
|
774
|
+
|
|
775
|
+
triangle.domNode.setAttribute('id', 'id-12345');
|
|
776
|
+
|
|
777
|
+
triangle.id; // "id-12345"
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
<b>All drawing elements must have a unique ID for RNAcanvas drawings to be savable
|
|
781
|
+
and for undo / redo functionality to work.</b>
|
|
782
|
+
|
|
783
|
+
Note that the `create()` static method already creates triangles with a UUID.
|
|
784
|
+
|
|
785
|
+
(IDs should generally not be changed after being initialized.)
|
|
786
|
+
|
|
787
|
+
### `centerX`
|
|
788
|
+
|
|
789
|
+
Center X coordinate.
|
|
790
|
+
|
|
791
|
+
```javascript
|
|
792
|
+
var triangle = Triangle.create();
|
|
793
|
+
|
|
794
|
+
triangle.centerX = 10;
|
|
795
|
+
|
|
796
|
+
// is stored under the `data-center-x` attribute
|
|
797
|
+
triangle.domNode.dataset.centerX; // "10"
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
This value is stored under the `data-center-x` attribute,
|
|
801
|
+
which allows for watching for changes to it using mutation observers.
|
|
802
|
+
|
|
803
|
+
### `centerY`
|
|
804
|
+
|
|
805
|
+
Center Y coordinate.
|
|
806
|
+
|
|
807
|
+
```javascript
|
|
808
|
+
var triangle = Triangle.create();
|
|
809
|
+
|
|
810
|
+
triangle.centerY = 20;
|
|
811
|
+
|
|
812
|
+
// is stored under the `data-center-y` attribute
|
|
813
|
+
triangle.domNode.dataset.centerY; // "20"
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
This value is stored under the `data-center-y` attribute,
|
|
817
|
+
which allows for watching for changes to it using mutation observers.
|
|
818
|
+
|
|
819
|
+
### `drag()`
|
|
820
|
+
|
|
821
|
+
Move the center coordinates of a triangle by the specified X and Y amounts.
|
|
822
|
+
|
|
823
|
+
```javascript
|
|
824
|
+
var triangle = Triangle.create();
|
|
825
|
+
|
|
826
|
+
triangle.centerX = 10;
|
|
827
|
+
triangle.centerY = 20;
|
|
828
|
+
|
|
829
|
+
triangle.drag(5, -2);
|
|
830
|
+
|
|
831
|
+
triangle.centerX; // 15
|
|
832
|
+
triangle.centerY; // 18
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
### `direction`
|
|
836
|
+
|
|
837
|
+
The direction of the triangle (in radians).
|
|
838
|
+
|
|
839
|
+
```javascript
|
|
840
|
+
var triangle = Triangle.create();
|
|
841
|
+
|
|
842
|
+
// triangles are created upright by default
|
|
843
|
+
triangle.direction; // -Math.PI / 2
|
|
844
|
+
|
|
845
|
+
// "pointing" to the left
|
|
846
|
+
triangle.direction = Math.PI;
|
|
847
|
+
|
|
848
|
+
// "pointing" to the right
|
|
849
|
+
triangle.direction = 0;
|
|
850
|
+
|
|
851
|
+
// is stored under the `data-direction` attribute
|
|
852
|
+
triangle.domNode.dataset.direction; // "0"
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
This value is stored under the `data-direction` attribute,
|
|
856
|
+
which allows for watching for changes to it using mutation observers.
|
|
857
|
+
|
|
858
|
+
### `width`
|
|
859
|
+
|
|
860
|
+
The width of a triangle.
|
|
861
|
+
|
|
862
|
+
```javascript
|
|
863
|
+
var triangle = Triangle.create();
|
|
864
|
+
|
|
865
|
+
triangle.width = 30;
|
|
866
|
+
|
|
867
|
+
// is stored under the `data-width` attribute
|
|
868
|
+
triangle.domNode.dataset.width; // "30"
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
This value is stored under the `data-width` attribute,
|
|
872
|
+
which allows for watching for changes to it using mutation observers.
|
|
873
|
+
|
|
874
|
+
### `height`
|
|
875
|
+
|
|
876
|
+
The height of a triangle.
|
|
877
|
+
|
|
878
|
+
```javascript
|
|
879
|
+
var triangle = Triangle.create();
|
|
880
|
+
|
|
881
|
+
triangle.height = 50;
|
|
882
|
+
|
|
883
|
+
// is stored under the `data-height` attribute
|
|
884
|
+
triangle.domNode.dataset.height; // "50"
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
This value is stored under the `data-height` attribute,
|
|
888
|
+
which allows for watching for changes to it using mutation observers.
|
|
889
|
+
|
|
890
|
+
### `tailsHeight`
|
|
891
|
+
|
|
892
|
+
Controls the height between the bottom corners of a triangle
|
|
893
|
+
and the midpoint of its base.
|
|
894
|
+
|
|
895
|
+
A positive tails height results in a triangle appearing as a "barbed" arrow.
|
|
896
|
+
|
|
897
|
+
A negative tails height results in a triangle appearing as a diamond arrow.
|
|
898
|
+
|
|
899
|
+
```javascript
|
|
900
|
+
var triangle = Triangle.create();
|
|
901
|
+
|
|
902
|
+
triangle.tailsHeight = 5;
|
|
903
|
+
|
|
904
|
+
// is stored under the `data-tails-height` attribute
|
|
905
|
+
triangle.domNode.dataset.tailsHeight; // "5"
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
This value is stored under the `data-tails-height` attribute,
|
|
909
|
+
which allows for watching for changes to it using mutation observers.
|
|
910
|
+
|
|
911
|
+
### `readonly bbox`
|
|
912
|
+
|
|
913
|
+
The bounding box of a triangle.
|
|
914
|
+
|
|
915
|
+
<b>Bounding boxes can only be calculated
|
|
916
|
+
when drawing elements have been added to the document body.</b>
|
|
917
|
+
|
|
918
|
+
```javascript
|
|
919
|
+
var triangle = Triangle.create();
|
|
920
|
+
|
|
921
|
+
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
922
|
+
|
|
923
|
+
svg.append(triangle.domNode);
|
|
924
|
+
|
|
925
|
+
// add everything to the document body
|
|
926
|
+
document.body.append(svg);
|
|
927
|
+
|
|
928
|
+
triangle.centerX = 0;
|
|
929
|
+
triangle.centerY = 0;
|
|
930
|
+
|
|
931
|
+
triangle.width = 10;
|
|
932
|
+
triangle.height = 20;
|
|
933
|
+
|
|
934
|
+
triangle.bbox.x; // -5
|
|
935
|
+
triangle.bbox.y; // -10
|
|
936
|
+
triangle.bbox.width; // 10
|
|
937
|
+
triangle.bbox.height; // 20
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
See [Box](https://pzhaojohnson.github.io/rnacanvas.boxes/) class documentation
|
|
941
|
+
for a full list of bounding box methods and properties.
|
|
942
|
+
|
|
943
|
+
### `serialized()`
|
|
944
|
+
|
|
945
|
+
Returns the serialized form of a triangle,
|
|
946
|
+
which is a JSON-serializable object.
|
|
947
|
+
|
|
948
|
+
```javascript
|
|
949
|
+
var triangle = Triangle.create();
|
|
950
|
+
|
|
951
|
+
var savedTriangle = triangle.serialized();
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
Throws if the ID of the triangle is falsy.
|
|
955
|
+
|
|
956
|
+
<b>Triangles must have an ID to be serializable.</b>
|
|
957
|
+
|
|
958
|
+
### `static recreate()`
|
|
959
|
+
|
|
960
|
+
Recreates a saved triangle given the parent drawing that its DOM node is in.
|
|
961
|
+
|
|
962
|
+
```javascript
|
|
963
|
+
var triangle1 = Triangle.create();
|
|
964
|
+
|
|
965
|
+
var savedTriangle = triangle1.serialized();
|
|
966
|
+
|
|
967
|
+
// an RNAcanvas drawing
|
|
968
|
+
parentDrawing;
|
|
969
|
+
|
|
970
|
+
var triangle2 = Triangle.recreate(savedTriangle, parentDrawing);
|
|
971
|
+
|
|
972
|
+
// share the same DOM node
|
|
973
|
+
triangle2.domNode === triangle1.domNode; // true
|
|
974
|
+
|
|
975
|
+
triangle2 === triangle1; // false
|
|
976
|
+
```
|
package/dist/Drawing.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import type { StrungElementOwner } from './StrungElementOwner';
|
|
1
2
|
/**
|
|
2
3
|
* The drawing interface used by floating elements.
|
|
3
4
|
*/
|
|
4
5
|
export interface Drawing {
|
|
5
6
|
readonly domNode: SVGSVGElement;
|
|
7
|
+
readonly bonds: {
|
|
8
|
+
/**
|
|
9
|
+
* Finds and returns the first bond that fulfills the provided callback function.
|
|
10
|
+
*
|
|
11
|
+
* Returns `undefined` if no bonds fulfill the provided callback function.
|
|
12
|
+
*/
|
|
13
|
+
find(f: (bond: StrungElementOwner) => boolean): StrungElementOwner | undefined;
|
|
14
|
+
};
|
|
6
15
|
}
|
|
7
16
|
//# sourceMappingURL=Drawing.d.ts.map
|
package/dist/Drawing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawing.d.ts","sourceRoot":"","sources":["../src/Drawing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Drawing.d.ts","sourceRoot":"","sources":["../src/Drawing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAEhC,QAAQ,CAAC,KAAK,EAAE;QACd;;;;WAIG;QACH,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAAC;KAChF,CAAA;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Circle } from './Circle';
|
|
2
|
+
import { StrungElement } from '@rnacanvas/draw.strung';
|
|
3
|
+
import type { StrungElementOwner } from './StrungElementOwner';
|
|
4
|
+
import type { Drawing } from './Drawing';
|
|
5
|
+
export declare class StrungCircle extends StrungElement {
|
|
6
|
+
#private;
|
|
7
|
+
readonly owner: StrungElementOwner;
|
|
8
|
+
static on(owner: StrungElementOwner): StrungCircle;
|
|
9
|
+
constructor(circle: Circle, owner: StrungElementOwner);
|
|
10
|
+
save(): {
|
|
11
|
+
circle: {
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
ownerID: string;
|
|
15
|
+
};
|
|
16
|
+
static recreate(savedStrungCircle: unknown, parentDrawing: Drawing): StrungCircle | never;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=StrungCircle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StrungCircle.d.ts","sourceRoot":"","sources":["../src/StrungCircle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,qBAAa,YAAa,SAAQ,aAAa;;aAYC,KAAK,EAAE,kBAAkB;IAXvE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB;gBAWvB,MAAM,EAAE,MAAM,EAAoB,KAAK,EAAE,kBAAkB;IAMvE,IAAI;;;;;;IAQJ,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,YAAY,GAAG,KAAK;CAqB1F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StrungElementOwner.d.ts","sourceRoot":"","sources":["../src/StrungElementOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAAG,CAC/B,qBAAqB,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,GAC5C;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CACjB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Rectangle } from './Rectangle';
|
|
2
|
+
import { StrungElement } from '@rnacanvas/draw.strung';
|
|
3
|
+
import type { StrungElementOwner } from './StrungElementOwner';
|
|
4
|
+
import type { Drawing } from './Drawing';
|
|
5
|
+
export declare class StrungRectangle extends StrungElement {
|
|
6
|
+
#private;
|
|
7
|
+
readonly owner: StrungElementOwner;
|
|
8
|
+
static on(owner: StrungElementOwner): StrungRectangle;
|
|
9
|
+
constructor(rectangle: Rectangle, owner: StrungElementOwner);
|
|
10
|
+
get width(): number;
|
|
11
|
+
set width(width: number);
|
|
12
|
+
get height(): number;
|
|
13
|
+
set height(height: number);
|
|
14
|
+
get cornerRadius(): number;
|
|
15
|
+
set cornerRadius(cornerRadius: number);
|
|
16
|
+
save(): {
|
|
17
|
+
rectangle: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
ownerID: string;
|
|
21
|
+
};
|
|
22
|
+
static recreate(savedStrungRectangle: unknown, parentDrawing: Drawing): StrungRectangle | never;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=StrungRectangle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StrungRectangle.d.ts","sourceRoot":"","sources":["../src/StrungRectangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,qBAAa,eAAgB,SAAQ,aAAa;;aAYI,KAAK,EAAE,kBAAkB;IAX7E,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,GAAG,eAAe;gBAWzC,SAAS,EAAE,SAAS,EAAoB,KAAK,EAAE,kBAAkB;IAM7E,IAAI,KAAK,WAER;IAED,IAAI,KAAK,CAAC,KAAK,QAAA,EAEd;IAED,IAAI,MAAM,WAET;IAED,IAAI,MAAM,CAAC,MAAM,QAAA,EAEhB;IAED,IAAI,YAAY,WAEf;IAED,IAAI,YAAY,CAAC,YAAY,QAAA,EAE5B;IAED,IAAI;;;;;;IAQJ,MAAM,CAAC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,eAAe,GAAG,KAAK;CAqBhG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Text } from './Text';
|
|
2
|
+
import { StrungElement } from '@rnacanvas/draw.strung';
|
|
3
|
+
import type { StrungElementOwner } from './StrungElementOwner';
|
|
4
|
+
import type { Drawing } from './Drawing';
|
|
5
|
+
export declare class StrungText extends StrungElement {
|
|
6
|
+
#private;
|
|
7
|
+
readonly owner: StrungElementOwner;
|
|
8
|
+
static on(owner: StrungElementOwner): StrungText;
|
|
9
|
+
constructor(text: Text, owner: StrungElementOwner);
|
|
10
|
+
get textContent(): string;
|
|
11
|
+
save(): {
|
|
12
|
+
text: {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
ownerID: string;
|
|
16
|
+
};
|
|
17
|
+
static recreate(savedStrungText: unknown, parentDrawing: Drawing): StrungText | never;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=StrungText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StrungText.d.ts","sourceRoot":"","sources":["../src/StrungText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,qBAAa,UAAW,SAAQ,aAAa;;aAYD,KAAK,EAAE,kBAAkB;IAXnE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU;gBAWpC,IAAI,EAAE,IAAI,EAAoB,KAAK,EAAE,kBAAkB;IAMnE,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI;;;;;;IAQJ,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,UAAU,GAAG,KAAK;CAqBtF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Triangle } from './Triangle';
|
|
2
|
+
import { StrungElement } from '@rnacanvas/draw.strung';
|
|
3
|
+
import type { StrungElementOwner } from './StrungElementOwner';
|
|
4
|
+
import type { Drawing } from './Drawing';
|
|
5
|
+
export declare class StrungTriangle extends StrungElement {
|
|
6
|
+
#private;
|
|
7
|
+
readonly owner: StrungElementOwner;
|
|
8
|
+
static on(owner: StrungElementOwner): StrungTriangle;
|
|
9
|
+
constructor(triangle: Triangle, owner: StrungElementOwner);
|
|
10
|
+
get width(): number;
|
|
11
|
+
set width(width: number);
|
|
12
|
+
get height(): number;
|
|
13
|
+
set height(height: number);
|
|
14
|
+
get tailsHeight(): number;
|
|
15
|
+
set tailsHeight(tailsHeight: number);
|
|
16
|
+
save(): {
|
|
17
|
+
triangle: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
ownerID: string;
|
|
21
|
+
};
|
|
22
|
+
static recreate(savedStrungTriangle: unknown, parentDrawing: Drawing): StrungTriangle | never;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=StrungTriangle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StrungTriangle.d.ts","sourceRoot":"","sources":["../src/StrungTriangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,qBAAa,cAAe,SAAQ,aAAa;;aAYG,KAAK,EAAE,kBAAkB;IAX3E,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,GAAG,cAAc;gBAWxC,QAAQ,EAAE,QAAQ,EAAoB,KAAK,EAAE,kBAAkB;IAM3E,IAAI,KAAK,WAER;IAED,IAAI,KAAK,CAAC,KAAK,QAAA,EAEd;IAED,IAAI,MAAM,WAET;IAED,IAAI,MAAM,CAAC,MAAM,QAAA,EAEhB;IAED,IAAI,WAAW,WAEd;IAED,IAAI,WAAW,CAAC,WAAW,QAAA,EAE1B;IAED,IAAI;;;;;;IAQJ,MAAM,CAAC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,cAAc,GAAG,KAAK;CAqB9F"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["draw.floating"]=e():t["draw.floating"]=e()}(this,()=>(()=>{var t={645(t){var e;e=()=>(()=>{var t={986(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){var e=0;return t.forEach(function(t){return e+=t}),e}function i(t){return r(t)/t.length}function n(t){t.sort(function(t,e){return t-e})}t.r(e),t.d(e,{areWithin:()=>m,average:()=>i,clamp:()=>l,degrees:()=>b,flipAway:()=>v,isBetween:()=>h,isBetweenExclusive:()=>u,isBetweenInclusive:()=>h,max:()=>d,mean:()=>i,median:()=>a,min:()=>c,normalizeAngle:()=>w,radians:()=>y,round:()=>p,sortNumbers:()=>n,sortNumbersAscending:()=>n,sortNumbersDescending:()=>f,sortedNumbers:()=>s,sortedNumbersAscending:()=>s,sortedNumbersDescending:()=>g,sum:()=>r});var o=function(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))};function s(t){var e=o([],t,!0);return n(e),e}function a(t){if(0==t.length)return NaN;var e=s(t);if(e.length%2!=0)return e[Math.floor(e.length/2)];var r=e.length/2,n=r-1;return i([e[r],e[n]])}function c(t){if(0==t.length)return 1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.min(e,t)}),e}function d(t){if(0==t.length)return-1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.max(e,t)}),e}function h(t,e,r){return t>=e&&t<=r}function u(t,e,r){return t>e&&t<r}function l(t,e,r){return t<e?e:t>r?r:t}function m(t,e,r){return Math.abs(t-e)<=r}function f(t){n(t),t.reverse()}function g(t){var e=s(t);return e.reverse(),e}function p(t,e){return Number.parseFloat(t.toFixed(null!=e?e:0))}function b(t){return t*(180/Math.PI)}function y(t){return t*(Math.PI/180)}function w(t,e){void 0===e&&(e=-Math.PI);var r=t-e;return e+((r%=2*Math.PI)>=0?r:r+2*Math.PI)}function v(t,e){var r=(e=w(e,t))-t;return(r<Math.PI/2||r>3*Math.PI/2)&&(t+=Math.PI),t}return e})()}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.r(i),r.d(i,{Box:()=>e});var t=r(986);class e{static matching(t){let{x:r,y:i,width:n,height:o}=t;return new e(r,i,n,o)}static bounding(r){let i=[...r];if(0==i.length)throw new Error("An empty collection of boxes doesn't have a bounding box.");let n=i.map(t=>e.matching(t)),o=(0,t.min)(n.map(t=>t.left)),s=(0,t.min)(n.map(t=>t.top)),a=(0,t.max)(n.map(t=>t.right))-o,c=(0,t.max)(n.map(t=>t.bottom))-s;return new e(o,s,a,c)}constructor(t,e,r,i){this.x=t,this.y=e,this.width=r,this.height=i}get centerX(){return this.minX+this.width/2}get centerY(){return this.minY+this.height/2}get minX(){return this.x}get minY(){return this.y}get maxX(){return this.minX+this.width}get maxY(){return this.minY+this.height}get top(){return this.minY}get right(){return this.maxX}get bottom(){return this.maxY}get left(){return this.minX}bounds(t){let r=e.matching(t);return this.minX<=r.minX&&this.minY<=r.minY&&this.maxX>=r.maxX&&this.maxY>=r.maxY}padded(...t){let r="number"==typeof t[0]?t[0]:"factor"in t[0]?t[0].factor*this.width:t[0].percentage/100*this.width,i="number"==typeof t[0]&&"number"==typeof t[1]?t[1]:"number"==typeof t[0]?t[0]:"factor"in t[0]?t[0].factor*this.height:t[0].percentage/100*this.height;return new e(this.x-r,this.y-i,this.width+2*r,this.height+2*i)}get periphery(){return{atAngle:t=>{let e=this.width/2,r=this.height/2,i=Math.pow(Math.pow(e,2)+Math.pow(r,2),.5),n=this.centerX+i*Math.cos(t),o=this.centerY+i*Math.sin(t),s=i;return Math.abs(this.centerX-n)>e&&(s=Math.abs(e/Math.cos(t)),s=Number.isFinite(s)?s:r),Math.abs(this.centerY-o)>r&&(s=Math.abs(r/Math.sin(t)),s=Number.isFinite(s)?s:e),{x:this.centerX+s*Math.cos(t),y:this.centerY+s*Math.sin(t)}}}}}})(),i})(),t.exports=e()},731(t){var e;e=()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{CenterPoint:()=>d});var r,i,n,o,s,a=function(t,e,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(t,r):n?n.value=r:e.set(t,r),r},c=function(t,e,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(t):i?i.value:e.get(t)};class d{constructor(t){r.add(this),i.set(this,void 0),n.set(this,{move:[]}),o.set(this,void 0),a(this,i,t,"f"),a(this,o,new MutationObserver(()=>c(this,r,"m",s).call(this,"move")),"f"),c(this,o,"f").observe(t,{attributes:!0,childList:!0,characterData:!0,subtree:!0})}get x(){let t=c(this,i,"f").getBBox();return t.x+t.width/2}set x(t){let e=this.x,r=[...c(this,i,"f").x.baseVal].map(t=>t.value);0!=r.length||r.push(0),r=r.map(r=>r+(t-e)),c(this,i,"f").setAttribute("x",r.join(", "))}get y(){let t=c(this,i,"f").getBBox();return t.y+t.height/2}set y(t){let e=this.y,r=[...c(this,i,"f").y.baseVal].map(t=>t.value);0!=r.length||r.push(0),r=r.map(r=>r+(t-e)),c(this,i,"f").setAttribute("y",r.join(", "))}addEventListener(t,e){c(this,n,"f")[t].push(e)}removeEventListener(t,e){c(this,n,"f")[t]=c(this,n,"f")[t].filter(t=>t!==e)}}return i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,s=function(t){c(this,n,"f")[t].forEach(t=>t())},e})(),t.exports=e()},456(t){var e;e=()=>(()=>{var t={277(t){var e;e=()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Vector:()=>r});class r{static matching(t){let e="x"in t?t.x:t.magnitude*Math.cos(t.direction),i="y"in t?t.y:t.magnitude*Math.sin(t.direction);return new r(e,i)}constructor(t,e){this.x=t,this.y=e}[Symbol.iterator](){return[this.x,this.y].values()}get magnitude(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))}set magnitude(t){let e=this.direction;this.x=t*Math.cos(e),this.y=t*Math.sin(e)}get direction(){return Math.atan2(this.y,this.x)}set direction(t){let e=this.magnitude;this.x=e*Math.cos(t),this.y=e*Math.sin(t)}}return e})(),t.exports=e()}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.r(i),r.d(i,{Point:()=>e,RelativePoint:()=>h});var t=r(277);class e{static matching(t){return new e(t.x,t.y)}constructor(t,e){this.x=t,this.y=e}[Symbol.iterator](){return[this.x,this.y].values()}displace(e){let r=t.Vector.matching(e);this.x+=r.x,this.y+=r.y}displaced(t){let r=e.matching(this);return r.displace(t),r}displacementTo(e){return new t.Vector(e.x-this.x,e.y-this.y)}displacementFrom(e){return new t.Vector(this.x-e.x,this.y-e.y)}distanceTo(t){return this.displacementTo(t).magnitude}distanceFrom(t){return this.distanceTo(t)}directionTo(t){return this.displacementTo(t).direction}directionFrom(t){return this.displacementFrom(t).direction}}var n,o,s,a,c,d=function(t,e,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(t):i?i.value:e.get(t)};class h{constructor(e){n.add(this),o.set(this,void 0),s.set(this,new t.Vector(0,0)),a.set(this,{move:[]}),function(t,e,r){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");e.set(t,r)}(this,o,e),e.addEventListener("move",()=>d(this,n,"m",c).call(this,"move"))}get x(){return d(this,o,"f").x+d(this,s,"f").x}set x(t){d(this,s,"f").x=t-d(this,o,"f").x,d(this,n,"m",c).call(this,"move")}get y(){return d(this,o,"f").y+d(this,s,"f").y}set y(t){d(this,s,"f").y=t-d(this,o,"f").y,d(this,n,"m",c).call(this,"move")}addEventListener(t,e){d(this,a,"f")[t].push(e)}removeEventListener(t,e){d(this,a,"f")[t]=d(this,a,"f")[t].filter(t=>t!==e)}}o=new WeakMap,s=new WeakMap,a=new WeakMap,n=new WeakSet,c=function(t){d(this,a,"f")[t].forEach(t=>t())}})(),i})(),t.exports=e()},854(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return"number"==typeof t}function i(t){return r(t)&&Number.isFinite(t)}function n(t){return r(t)&&!Number.isFinite(t)}function o(t){return i(t)&&t>0}function s(t){return i(t)&&t>=0}function a(t){return"string"==typeof t}function c(t){return null==t}function d(t){return"object"==typeof t&&null!==t}function h(t){return Array.isArray(t)}function u(t){return h(t)&&0==t.length}function l(t){return h(t)&&t.length>0}function m(t){return h(t)&&t.every(r)}function f(t){return m(t)&&t.length>0}function g(t){return h(t)&&t.every(i)}function p(t){return h(t)&&t.every(n)}function b(t){return h(t)&&t.every(a)}function y(t){return b(t)&&t.length>0}return t.r(e),t.d(e,{isArray:()=>h,isEmptyArray:()=>u,isFiniteNumber:()=>i,isFiniteNumbersArray:()=>g,isNonEmptyArray:()=>l,isNonEmptyNumbersArray:()=>f,isNonEmptyStringsArray:()=>y,isNonFiniteNumber:()=>n,isNonFiniteNumbersArray:()=>p,isNonNegativeFiniteNumber:()=>s,isNonNullObject:()=>d,isNullish:()=>c,isNumber:()=>r,isNumbersArray:()=>m,isPositiveFiniteNumber:()=>o,isString:()=>a,isStringsArray:()=>b}),e})()}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.r(i),r.d(i,{Circle:()=>l,Rectangle:()=>v,Text:()=>u});const t={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let e;const n=new Uint8Array(16),o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function s(t,r,i){const s=(t=t||{}).random??t.rng?.()??function(){if(!e){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");e=crypto.getRandomValues.bind(crypto)}return e(n)}();if(s.length<16)throw new Error("Random bytes length must be >= 16");if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,r){if((i=i||0)<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let t=0;t<16;++t)r[i+t]=s[t];return r}return function(t,e=0){return(o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]).toLowerCase()}(s)}const a=function(e,r,i){return!t.randomUUID||r||e?s(e,r,i):t.randomUUID()};var c=r(645),d=r(731),h=r(854);class u{static create(t){let e=document.createElementNS("http://www.w3.org/2000/svg","text");return e.id="id-"+a(),e.textContent=null!=t?t:"",e.setAttribute("font-family","Arial"),e.setAttribute("font-size","9"),e.setAttribute("font-weight","700"),e.setAttribute("font-style","normal"),e.setAttribute("fill","black"),e.setAttribute("fill-opacity","1"),new u(e)}constructor(t){this.domNode=t}get id(){return this.domNode.id}get bbox(){return c.Box.matching(this.domNode.getBBox())}get centerX(){return this.bbox.centerX}set centerX(t){new d.CenterPoint(this.domNode).x=t}get centerY(){return this.bbox.centerY}set centerY(t){new d.CenterPoint(this.domNode).y=t}drag(t,e){this.centerX+=t,this.centerY+=e}serialized(){if(!this.id)throw new Error("Text element ID is falsy.");return{id:this.id}}static recreate(t,e){if(!(0,h.isNonNullObject)(t))throw new Error(`Saved text element is not an object: ${t}.`);if(!t.id)throw new Error("Saved text element ID is falsy.");if(!(0,h.isString)(t.id))throw new Error(`Saved text element ID is not a string: ${t.id}.`);let r=e.domNode.querySelector("#"+t.id);if(!r)throw new Error("Unable to find text element DOM node in parent drawing by ID.");if(!(r instanceof SVGTextElement))throw new Error(`Text element DOM node is not an SVG text element: ${r}.`);return new u(r)}}class l{static create(){let t=document.createElementNS("http://www.w3.org/2000/svg","circle");return t.id="id-"+a(),t.setAttribute("r","6"),t.setAttribute("stroke","black"),t.setAttribute("stroke-width","1"),t.setAttribute("stroke-opacity","1"),t.setAttribute("stroke-dasharray",""),t.setAttribute("stroke-linecap",""),t.setAttribute("fill","white"),t.setAttribute("fill-opacity","1"),new l(t)}constructor(t){this.domNode=t}get id(){return this.domNode.id}get centerX(){return this.domNode.cx.baseVal.value}set centerX(t){this.domNode.setAttribute("cx",`${t}`)}get centerY(){return this.domNode.cy.baseVal.value}set centerY(t){this.domNode.setAttribute("cy",`${t}`)}drag(t,e){this.centerX+=t,this.centerY+=e}serialized(){if(!this.id)throw new Error("Circle ID is falsy.");return{id:this.id}}static recreate(t,e){if(!(0,h.isNonNullObject)(t))throw new Error(`Saved circle must be an object: ${t}.`);if(!t.id)throw new Error("Saved circle ID is falsy.");if(!(0,h.isString)(t.id))throw new Error(`Saved circle ID must be a string: ${t.id}.`);let r=e.domNode.querySelector("#"+t.id);if(!r)throw new Error("Unable to find circle element DOM node by ID.");if(!(r instanceof SVGCircleElement))throw new Error(`Circle element DOM node is not an SVG circle element: ${r}.`);return new l(r)}}var m=r(456);class f{constructor(){this.centerX=0,this.centerY=0,this.direction=-Math.PI/2,this.width=0,this.height=0,this.cornerRadius=0}static matching(t){let e=new f;return e.centerX=t.centerX,e.centerY=t.centerY,e.direction=t.direction,e.width=t.width,e.height=t.height,e.cornerRadius=t.cornerRadius,e}toString(){let t=new m.Point(this.centerX,this.centerY);t.displace({magnitude:this.height/2,direction:this.direction}),t.displace({magnitude:this.width/2-this.cornerRadius,direction:this.direction+Math.PI/2});let e=`M ${t.x} ${t.y}`;return t.displace({magnitude:Math.SQRT2*this.cornerRadius,direction:this.direction+3*Math.PI/4}),e+=` A ${this.cornerRadius} ${this.cornerRadius} 90 0 1 ${t.x} ${t.y}`,t.displace({magnitude:this.height-2*this.cornerRadius,direction:this.direction+Math.PI}),e+=` L ${t.x} ${t.y}`,t.displace({magnitude:Math.SQRT2*this.cornerRadius,direction:this.direction+5*Math.PI/4}),e+=` A ${this.cornerRadius} ${this.cornerRadius} 90 0 1 ${t.x} ${t.y}`,t.displace({magnitude:this.width-2*this.cornerRadius,direction:this.direction+3*Math.PI/2}),e+=` L ${t.x} ${t.y}`,t.displace({magnitude:Math.SQRT2*this.cornerRadius,direction:this.direction+7*Math.PI/4}),e+=` A ${this.cornerRadius} ${this.cornerRadius} 90 0 1 ${t.x} ${t.y}`,t.displace({magnitude:this.height-2*this.cornerRadius,direction:this.direction}),e+=` L ${t.x} ${t.y}`,t.displace({magnitude:Math.SQRT2*this.cornerRadius,direction:this.direction+9*Math.PI/4}),e+=` A ${this.cornerRadius} ${this.cornerRadius} 90 0 1 ${t.x} ${t.y}`,e+=" Z",e}}var g,p,b,y,w=function(t,e,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(t):i?i.value:e.get(t)};class v{static create(){let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.id="id-"+a();let e=new v(t);return e.centerX=0,e.centerY=0,e.direction=-Math.PI/2,e.width=5.5,e.height=5.5,e.cornerRadius=0,e.domNode.setAttribute("stroke","black"),e.domNode.setAttribute("stroke-width","1"),e.domNode.setAttribute("stroke-opacity","1"),e.domNode.setAttribute("stroke-linejoin",""),e.domNode.setAttribute("stroke-dasharray",""),e.domNode.setAttribute("stroke-linecap",""),e.domNode.setAttribute("fill","white"),e.domNode.setAttribute("fill-opacity","1"),e}constructor(t){g.add(this),this.domNode=t,t.dataset.centerX||w(this,g,"m",p).call(this),t.dataset.centerY||w(this,g,"m",b).call(this)}get id(){return this.domNode.id}get centerX(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.centerX)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set centerX(t){Number.isFinite(t)?(this.domNode.dataset.centerX=`${t}`,w(this,g,"m",y).call(this)):console.error(`The specified center X coordinate is nonfinite: ${t}.`)}get centerY(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.centerY)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set centerY(t){Number.isFinite(t)?(this.domNode.dataset.centerY=`${t}`,w(this,g,"m",y).call(this)):console.error(`The specified center Y coordinate is nonfinite: ${t}.`)}drag(t,e){this.centerX+=t,this.centerY+=e}get direction(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.direction)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set direction(t){Number.isFinite(t)?(this.domNode.dataset.direction=`${t}`,w(this,g,"m",y).call(this)):console.error(`The specified direction angle is nonfinite: ${t}.`)}get width(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.width)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set width(t){Number.isFinite(t)?(this.domNode.dataset.width=`${t}`,w(this,g,"m",y).call(this)):console.error(`The specified width is nonfinite: ${t}.`)}get height(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.height)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set height(t){Number.isFinite(t)?(this.domNode.dataset.height=`${t}`,w(this,g,"m",y).call(this)):console.error(`The specified height is nonfinite: ${t}.`)}get cornerRadius(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.cornerRadius)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set cornerRadius(t){Number.isFinite(t)?(this.domNode.dataset.cornerRadius=`${t}`,w(this,g,"m",y).call(this)):console.error(`The specified corner radius is nonfinite: ${t}.`)}get bbox(){return c.Box.matching(this.domNode.getBBox())}serialized(){if(!this.id)throw new Error("Rectangle ID is falsy.");return{id:this.id}}static recreate(t,e){if(!(0,h.isNonNullObject)(t))throw new Error(`Saved rectangle is not an object: ${t}.`);if(!t.id)throw new Error("Saved rectangle ID is falsy.");if(!(0,h.isString)(t.id))throw new Error(`Saved rectangle ID is not a string: ${t.id}.`);let r=e.domNode.querySelector("#"+t.id);if(!r)throw new Error("Unable to find saved rectangle DOM node in parent drawing by ID.");if(!(r instanceof SVGPathElement))throw new Error(`DOM node found for saved rectangle is not an SVG path element: ${r}.`);let i=new v(r);return(0,h.isFiniteNumber)(t.width)&&(i.width=t.width),(0,h.isFiniteNumber)(t.height)&&(i.height=t.height),(0,h.isFiniteNumber)(t.borderRadius)&&(i.cornerRadius=t.borderRadius),(0,h.isFiniteNumber)(t.rotation)&&(i.direction=t.rotation-Math.PI/2),i}}g=new WeakSet,p=function(){let t=c.Box.matching(this.domNode.getBBox());this.domNode.dataset.centerX=`${t.centerX}`},b=function(){let t=c.Box.matching(this.domNode.getBBox());this.domNode.dataset.centerY=`${t.centerY}`},y=function(){let t=new f;t.centerX=this.centerX,t.centerY=this.centerY,t.direction=this.direction,t.width=this.width,t.height=this.height,t.cornerRadius=this.cornerRadius,this.domNode.setAttribute("d",t.toString())}})(),i})());
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["draw.floating"]=e():t["draw.floating"]=e()}(this,()=>(()=>{var t={645(t){var e;e=()=>(()=>{var t={986(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){var e=0;return t.forEach(function(t){return e+=t}),e}function i(t){return r(t)/t.length}function n(t){t.sort(function(t,e){return t-e})}t.r(e),t.d(e,{areWithin:()=>m,average:()=>i,clamp:()=>l,degrees:()=>y,flipAway:()=>w,isBetween:()=>h,isBetweenExclusive:()=>d,isBetweenInclusive:()=>h,max:()=>c,mean:()=>i,median:()=>a,min:()=>u,normalizeAngle:()=>N,radians:()=>p,round:()=>b,sortNumbers:()=>n,sortNumbersAscending:()=>n,sortNumbersDescending:()=>f,sortedNumbers:()=>s,sortedNumbersAscending:()=>s,sortedNumbersDescending:()=>g,sum:()=>r});var o=function(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))};function s(t){var e=o([],t,!0);return n(e),e}function a(t){if(0==t.length)return NaN;var e=s(t);if(e.length%2!=0)return e[Math.floor(e.length/2)];var r=e.length/2,n=r-1;return i([e[r],e[n]])}function u(t){if(0==t.length)return 1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.min(e,t)}),e}function c(t){if(0==t.length)return-1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.max(e,t)}),e}function h(t,e,r){return t>=e&&t<=r}function d(t,e,r){return t>e&&t<r}function l(t,e,r){return t<e?e:t>r?r:t}function m(t,e,r){return Math.abs(t-e)<=r}function f(t){n(t),t.reverse()}function g(t){var e=s(t);return e.reverse(),e}function b(t,e){return Number.parseFloat(t.toFixed(null!=e?e:0))}function y(t){return t*(180/Math.PI)}function p(t){return t*(Math.PI/180)}function N(t,e){void 0===e&&(e=-Math.PI);var r=t-e;return e+((r%=2*Math.PI)>=0?r:r+2*Math.PI)}function w(t,e){var r=(e=N(e,t))-t;return(r<Math.PI/2||r>3*Math.PI/2)&&(t+=Math.PI),t}return e})()}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.r(i),r.d(i,{Box:()=>e});var t=r(986);class e{static matching(t){let{x:r,y:i,width:n,height:o}=t;return new e(r,i,n,o)}static bounding(r){let i=[...r];if(0==i.length)throw new Error("An empty collection of boxes doesn't have a bounding box.");let n=i.map(t=>e.matching(t)),o=(0,t.min)(n.map(t=>t.left)),s=(0,t.min)(n.map(t=>t.top)),a=(0,t.max)(n.map(t=>t.right))-o,u=(0,t.max)(n.map(t=>t.bottom))-s;return new e(o,s,a,u)}constructor(t,e,r,i){this.x=t,this.y=e,this.width=r,this.height=i}get centerX(){return this.minX+this.width/2}get centerY(){return this.minY+this.height/2}get minX(){return this.x}get minY(){return this.y}get maxX(){return this.minX+this.width}get maxY(){return this.minY+this.height}get top(){return this.minY}get right(){return this.maxX}get bottom(){return this.maxY}get left(){return this.minX}bounds(t){let r=e.matching(t);return this.minX<=r.minX&&this.minY<=r.minY&&this.maxX>=r.maxX&&this.maxY>=r.maxY}padded(...t){let r="number"==typeof t[0]?t[0]:"factor"in t[0]?t[0].factor*this.width:t[0].percentage/100*this.width,i="number"==typeof t[0]&&"number"==typeof t[1]?t[1]:"number"==typeof t[0]?t[0]:"factor"in t[0]?t[0].factor*this.height:t[0].percentage/100*this.height;return new e(this.x-r,this.y-i,this.width+2*r,this.height+2*i)}get periphery(){return{atAngle:t=>{let e=this.width/2,r=this.height/2,i=Math.pow(Math.pow(e,2)+Math.pow(r,2),.5),n=this.centerX+i*Math.cos(t),o=this.centerY+i*Math.sin(t),s=i;return Math.abs(this.centerX-n)>e&&(s=Math.abs(e/Math.cos(t)),s=Number.isFinite(s)?s:r),Math.abs(this.centerY-o)>r&&(s=Math.abs(r/Math.sin(t)),s=Number.isFinite(s)?s:e),{x:this.centerX+s*Math.cos(t),y:this.centerY+s*Math.sin(t)}}}}}})(),i})(),t.exports=e()},731(t){var e;e=()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{CenterPoint:()=>c});var r,i,n,o,s,a=function(t,e,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(t,r):n?n.value=r:e.set(t,r),r},u=function(t,e,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(t):i?i.value:e.get(t)};class c{constructor(t){r.add(this),i.set(this,void 0),n.set(this,{move:[]}),o.set(this,void 0),a(this,i,t,"f"),a(this,o,new MutationObserver(()=>u(this,r,"m",s).call(this,"move")),"f"),u(this,o,"f").observe(t,{attributes:!0,childList:!0,characterData:!0,subtree:!0})}get x(){let t=u(this,i,"f").getBBox();return t.x+t.width/2}set x(t){let e=this.x,r=[...u(this,i,"f").x.baseVal].map(t=>t.value);0!=r.length||r.push(0),r=r.map(r=>r+(t-e)),u(this,i,"f").setAttribute("x",r.join(", "))}get y(){let t=u(this,i,"f").getBBox();return t.y+t.height/2}set y(t){let e=this.y,r=[...u(this,i,"f").y.baseVal].map(t=>t.value);0!=r.length||r.push(0),r=r.map(r=>r+(t-e)),u(this,i,"f").setAttribute("y",r.join(", "))}addEventListener(t,e){u(this,n,"f")[t].push(e)}removeEventListener(t,e){u(this,n,"f")[t]=u(this,n,"f")[t].filter(t=>t!==e)}}return i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,s=function(t){u(this,n,"f")[t].forEach(t=>t())},e})(),t.exports=e()},456(t){var e;e=()=>(()=>{var t={986(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){var e=0;return t.forEach(function(t){return e+=t}),e}function i(t){return r(t)/t.length}function n(t){t.sort(function(t,e){return t-e})}t.r(e),t.d(e,{areWithin:()=>m,average:()=>i,clamp:()=>l,degrees:()=>y,flipAway:()=>w,isBetween:()=>h,isBetweenExclusive:()=>d,isBetweenInclusive:()=>h,max:()=>c,mean:()=>i,median:()=>a,min:()=>u,normalizeAngle:()=>N,radians:()=>p,round:()=>b,sortNumbers:()=>n,sortNumbersAscending:()=>n,sortNumbersDescending:()=>f,sortedNumbers:()=>s,sortedNumbersAscending:()=>s,sortedNumbersDescending:()=>g,sum:()=>r});var o=function(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))};function s(t){var e=o([],t,!0);return n(e),e}function a(t){if(0==t.length)return NaN;var e=s(t);if(e.length%2!=0)return e[Math.floor(e.length/2)];var r=e.length/2,n=r-1;return i([e[r],e[n]])}function u(t){if(0==t.length)return 1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.min(e,t)}),e}function c(t){if(0==t.length)return-1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.max(e,t)}),e}function h(t,e,r){return t>=e&&t<=r}function d(t,e,r){return t>e&&t<r}function l(t,e,r){return t<e?e:t>r?r:t}function m(t,e,r){return Math.abs(t-e)<=r}function f(t){n(t),t.reverse()}function g(t){var e=s(t);return e.reverse(),e}function b(t,e){return Number.parseFloat(t.toFixed(null!=e?e:0))}function y(t){return t*(180/Math.PI)}function p(t){return t*(Math.PI/180)}function N(t,e){void 0===e&&(e=-Math.PI);var r=t-e;return e+((r%=2*Math.PI)>=0?r:r+2*Math.PI)}function w(t,e){var r=(e=N(e,t))-t;return(r<Math.PI/2||r>3*Math.PI/2)&&(t+=Math.PI),t}return e})()},854(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return"number"==typeof t}function i(t){return r(t)&&Number.isFinite(t)}function n(t){return r(t)&&!Number.isFinite(t)}function o(t){return i(t)&&t>0}function s(t){return i(t)&&t>=0}function a(t){return"string"==typeof t}function u(t){return""===t}function c(t){return a(t)&&!u(t)}function h(t){return!!a(t)&&0==t.trim().length}function d(t){if(!a(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function l(t){try{return JSON.stringify(t),!0}catch{return!1}}function m(t){return!!t}function f(t){return!t}function g(t){return null==t}function b(t){return"object"==typeof t&&null!==t}function y(t){return Array.isArray(t)}function p(t){return y(t)&&0==t.length}function N(t){return y(t)&&t.length>0}function w(t){return y(t)&&t.every(r)}function v(t){return w(t)&&t.length>0}function x(t){return y(t)&&t.every(i)}function S(t){return y(t)&&t.every(n)}function M(t){return y(t)&&t.every(a)}function P(t){return M(t)&&t.length>0}function A(t){return t instanceof SVGGraphicsElement}return t.r(e),t.d(e,{isArray:()=>y,isEmptyArray:()=>p,isEmptyString:()=>u,isFalsy:()=>f,isFiniteNumber:()=>i,isFiniteNumbersArray:()=>x,isJSON:()=>d,isJSONSerializable:()=>l,isNonEmptyArray:()=>N,isNonEmptyNumbersArray:()=>v,isNonEmptyString:()=>c,isNonEmptyStringsArray:()=>P,isNonFiniteNumber:()=>n,isNonFiniteNumbersArray:()=>S,isNonNegativeFiniteNumber:()=>s,isNonNullObject:()=>b,isNullish:()=>g,isNumber:()=>r,isNumbersArray:()=>w,isPositiveFiniteNumber:()=>o,isSVGGraphicsElement:()=>A,isString:()=>a,isStringsArray:()=>M,isTruthy:()=>m,isWhitespace:()=>h}),e})()},277(t){var e;e=()=>(()=>{var t={854(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return"number"==typeof t}function i(t){return r(t)&&Number.isFinite(t)}function n(t){return r(t)&&!Number.isFinite(t)}function o(t){return i(t)&&t>0}function s(t){return i(t)&&t>=0}function a(t){return"string"==typeof t}function u(t){return""===t}function c(t){return a(t)&&!u(t)}function h(t){return!!a(t)&&0==t.trim().length}function d(t){if(!a(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function l(t){try{return JSON.stringify(t),!0}catch{return!1}}function m(t){return!!t}function f(t){return!t}function g(t){return null==t}function b(t){return"object"==typeof t&&null!==t}function y(t){return Array.isArray(t)}function p(t){return y(t)&&0==t.length}function N(t){return y(t)&&t.length>0}function w(t){return y(t)&&t.every(r)}function v(t){return w(t)&&t.length>0}function x(t){return y(t)&&t.every(i)}function S(t){return y(t)&&t.every(n)}function M(t){return y(t)&&t.every(a)}function P(t){return M(t)&&t.length>0}function A(t){return t instanceof SVGGraphicsElement}return t.r(e),t.d(e,{isArray:()=>y,isEmptyArray:()=>p,isEmptyString:()=>u,isFalsy:()=>f,isFiniteNumber:()=>i,isFiniteNumbersArray:()=>x,isJSON:()=>d,isJSONSerializable:()=>l,isNonEmptyArray:()=>N,isNonEmptyNumbersArray:()=>v,isNonEmptyString:()=>c,isNonEmptyStringsArray:()=>P,isNonFiniteNumber:()=>n,isNonFiniteNumbersArray:()=>S,isNonNegativeFiniteNumber:()=>s,isNonNullObject:()=>b,isNullish:()=>g,isNumber:()=>r,isNumbersArray:()=>w,isPositiveFiniteNumber:()=>o,isSVGGraphicsElement:()=>A,isString:()=>a,isStringsArray:()=>M,isTruthy:()=>m,isWhitespace:()=>h}),e})()}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.r(i),r.d(i,{Vector:()=>e,isFiniteVectorLike:()=>o,isVectorLike:()=>n});var t=r(854);class e{static matching(t){let r="x"in t?t.x:t.magnitude*Math.cos(t.direction),i="y"in t?t.y:t.magnitude*Math.sin(t.direction);return new e(r,i)}constructor(t,e){this.x=t,this.y=e}[Symbol.iterator](){return[this.x,this.y].values()}get magnitude(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))}set magnitude(t){let e=this.direction;this.x=t*Math.cos(e),this.y=t*Math.sin(e)}get direction(){return Math.atan2(this.y,this.x)}set direction(t){let e=this.magnitude;this.x=e*Math.cos(t),this.y=e*Math.sin(t)}isFinite(){return(0,t.isFiniteNumber)(this.x)&&(0,t.isFiniteNumber)(this.y)}}function n(e){return!(!(0,t.isNonNullObject)(e)||!((0,t.isNumber)(e.x)&&(0,t.isNumber)(e.y)||(0,t.isNumber)(e.magnitude)&&(0,t.isNumber)(e.direction)))}function o(t){return!!n(t)&&e.matching(t).isFinite()}})(),i})(),t.exports=e()}};const e={};function r(i){const n=e[i];if(void 0!==n)return n.exports;const o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var n=e[i++],o=e[i++];r.o(t,n)?0===o&&i++:0===o?Object.defineProperty(t,n,{enumerable:!0,value:e[i++]}):Object.defineProperty(t,n,{enumerable:!0,get:o})}else for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let i={};return(()=>{"use strict";r.r(i),r.d(i,{FinitePoint:()=>o,Point:()=>n,RelativePoint:()=>l,midpoint:()=>f});var t=r(277),e=r(854);class n{static matching(t){return new n(t.x,t.y)}constructor(t,e){this.x=t,this.y=e}[Symbol.iterator](){return[this.x,this.y].values()}set(t){(0,e.isNumber)(null==t?void 0:t.x)&&(this.x=t.x),(0,e.isNumber)(null==t?void 0:t.y)&&(this.y=t.y)}drag(t,e){this.displace({x:t,y:e})}displace(e){let r=t.Vector.matching(e);this.x+=r.x,this.y+=r.y}displaced(t){let e=n.matching(this);return e.displace(t),e}displacementTo(e){return new t.Vector(e.x-this.x,e.y-this.y)}displacementFrom(e){return new t.Vector(this.x-e.x,this.y-e.y)}distanceTo(t){return this.displacementTo(t).magnitude}distanceFrom(t){return this.distanceTo(t)}directionTo(t){return this.displacementTo(t).direction}directionFrom(t){return this.displacementFrom(t).direction}deepCopy(){return new n(this.x,this.y)}}class o extends n{static matching(t){let e=n.matching(t);return new o(e.x,e.y)}constructor(t,r){if(super(t,r),!(0,e.isFiniteNumber)(t)||!(0,e.isFiniteNumber)(r))throw new Error(`Finite points must have finite number coordinates: (${t}, ${r}).`)}set(...t){let e=new n(0,0);e.set(...t),o.matching(e),super.set(...t)}}var s,a,u,c,h,d=function(t,e,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(t):i?i.value:e.get(t)};class l{constructor(e){s.add(this),a.set(this,void 0),u.set(this,new t.Vector(0,0)),c.set(this,{move:[]}),function(t,e,r){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");e.set(t,r)}(this,a,e),e.addEventListener("move",()=>d(this,s,"m",h).call(this,"move"))}get x(){return d(this,a,"f").x+d(this,u,"f").x}set x(t){d(this,u,"f").x=t-d(this,a,"f").x,d(this,s,"m",h).call(this,"move")}get y(){return d(this,a,"f").y+d(this,u,"f").y}set y(t){d(this,u,"f").y=t-d(this,a,"f").y,d(this,s,"m",h).call(this,"move")}addEventListener(t,e){d(this,c,"f")[t].push(e)}removeEventListener(t,e){d(this,c,"f")[t]=d(this,c,"f")[t].filter(t=>t!==e)}}a=new WeakMap,u=new WeakMap,c=new WeakMap,s=new WeakSet,h=function(t){d(this,c,"f")[t].forEach(t=>t())};var m=r(986);function f(t,e){return new n((0,m.average)([t.x,e.x]),(0,m.average)([t.y,e.y]))}})(),i})(),t.exports=e()},854(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return"number"==typeof t}function i(t){return r(t)&&Number.isFinite(t)}function n(t){return r(t)&&!Number.isFinite(t)}function o(t){return i(t)&&t>0}function s(t){return i(t)&&t>=0}function a(t){return"string"==typeof t}function u(t){return""===t}function c(t){return a(t)&&!u(t)}function h(t){return!!a(t)&&0==t.trim().length}function d(t){if(!a(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function l(t){try{return JSON.stringify(t),!0}catch{return!1}}function m(t){return!!t}function f(t){return!t}function g(t){return null==t}function b(t){return"object"==typeof t&&null!==t}function y(t){return Array.isArray(t)}function p(t){return y(t)&&0==t.length}function N(t){return y(t)&&t.length>0}function w(t){return y(t)&&t.every(r)}function v(t){return w(t)&&t.length>0}function x(t){return y(t)&&t.every(i)}function S(t){return y(t)&&t.every(n)}function M(t){return y(t)&&t.every(a)}function P(t){return M(t)&&t.length>0}function A(t){return t instanceof SVGGraphicsElement}return t.r(e),t.d(e,{isArray:()=>y,isEmptyArray:()=>p,isEmptyString:()=>u,isFalsy:()=>f,isFiniteNumber:()=>i,isFiniteNumbersArray:()=>x,isJSON:()=>d,isJSONSerializable:()=>l,isNonEmptyArray:()=>N,isNonEmptyNumbersArray:()=>v,isNonEmptyString:()=>c,isNonEmptyStringsArray:()=>P,isNonFiniteNumber:()=>n,isNonFiniteNumbersArray:()=>S,isNonNegativeFiniteNumber:()=>s,isNonNullObject:()=>b,isNullish:()=>g,isNumber:()=>r,isNumbersArray:()=>w,isPositiveFiniteNumber:()=>o,isSVGGraphicsElement:()=>A,isString:()=>a,isStringsArray:()=>M,isTruthy:()=>m,isWhitespace:()=>h}),e})()}};const e={};function r(i){const n=e[i];if(void 0!==n)return n.exports;const o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let i={};return(()=>{"use strict";r.r(i),r.d(i,{Circle:()=>l,Rectangle:()=>w,Text:()=>d,Triangle:()=>F});const t={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let e;const n=new Uint8Array(16),o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function s(t,r,i){const s=(t=t||{}).random??t.rng?.()??function(){if(!e){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");e=crypto.getRandomValues.bind(crypto)}return e(n)}();if(s.length<16)throw new Error("Random bytes length must be >= 16");if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,r){if((i=i||0)<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let t=0;t<16;++t)r[i+t]=s[t];return r}return function(t,e=0){return(o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]).toLowerCase()}(s)}const a=function(e,r,i){return!t.randomUUID||r||e?s(e,r,i):t.randomUUID()};var u=r(645),c=r(731),h=r(854);class d{static create(t){let e=document.createElementNS("http://www.w3.org/2000/svg","text");return e.id="id-"+a(),e.textContent=null!=t?t:"",e.setAttribute("font-family","Arial"),e.setAttribute("font-size","9"),e.setAttribute("font-weight","700"),e.setAttribute("font-style","normal"),e.setAttribute("fill","black"),e.setAttribute("fill-opacity","1"),new d(e)}constructor(t){this.domNode=t}get id(){return this.domNode.id}get bbox(){return u.Box.matching(this.domNode.getBBox())}get centerX(){return this.bbox.centerX}set centerX(t){new c.CenterPoint(this.domNode).x=t}get centerY(){return this.bbox.centerY}set centerY(t){new c.CenterPoint(this.domNode).y=t}drag(t,e){this.centerX+=t,this.centerY+=e}serialized(){if(!this.id)throw new Error("Text element ID is falsy.");return{id:this.id}}static recreate(t,e){if(!(0,h.isNonNullObject)(t))throw new Error(`Saved text element is not an object: ${t}.`);if(!t.id)throw new Error("Saved text element ID is falsy.");if(!(0,h.isString)(t.id))throw new Error(`Saved text element ID is not a string: ${t.id}.`);let r=e.domNode.querySelector("#"+t.id);if(!r)throw new Error("Unable to find text element DOM node in parent drawing by ID.");if(!(r instanceof SVGTextElement))throw new Error(`Text element DOM node is not an SVG text element: ${r}.`);return new d(r)}}class l{static create(){let t=document.createElementNS("http://www.w3.org/2000/svg","circle");return t.id="id-"+a(),t.setAttribute("r","6"),t.setAttribute("stroke","black"),t.setAttribute("stroke-width","1"),t.setAttribute("stroke-opacity","1"),t.setAttribute("stroke-dasharray",""),t.setAttribute("stroke-linecap",""),t.setAttribute("fill","white"),t.setAttribute("fill-opacity","1"),new l(t)}constructor(t){this.domNode=t}get id(){return this.domNode.id}get centerX(){return this.domNode.cx.baseVal.value}set centerX(t){this.domNode.setAttribute("cx",`${t}`)}get centerY(){return this.domNode.cy.baseVal.value}set centerY(t){this.domNode.setAttribute("cy",`${t}`)}drag(t,e){this.centerX+=t,this.centerY+=e}serialized(){if(!this.id)throw new Error("Circle ID is falsy.");return{id:this.id}}static recreate(t,e){if(!(0,h.isNonNullObject)(t))throw new Error(`Saved circle must be an object: ${t}.`);if(!t.id)throw new Error("Saved circle ID is falsy.");if(!(0,h.isString)(t.id))throw new Error(`Saved circle ID must be a string: ${t.id}.`);let r=e.domNode.querySelector("#"+t.id);if(!r)throw new Error("Unable to find circle element DOM node by ID.");if(!(r instanceof SVGCircleElement))throw new Error(`Circle element DOM node is not an SVG circle element: ${r}.`);return new l(r)}}var m=r(456);class f{constructor(){this.centerX=0,this.centerY=0,this.direction=-Math.PI/2,this.width=0,this.height=0,this.cornerRadius=0}static matching(t){let e=new f;return e.centerX=t.centerX,e.centerY=t.centerY,e.direction=t.direction,e.width=t.width,e.height=t.height,e.cornerRadius=t.cornerRadius,e}toString(){let t=new m.Point(this.centerX,this.centerY);t.displace({magnitude:this.height/2,direction:this.direction}),t.displace({magnitude:this.width/2-this.cornerRadius,direction:this.direction+Math.PI/2});let e=`M ${t.x} ${t.y}`;return t.displace({magnitude:Math.SQRT2*this.cornerRadius,direction:this.direction+3*Math.PI/4}),e+=` A ${this.cornerRadius} ${this.cornerRadius} 90 0 1 ${t.x} ${t.y}`,t.displace({magnitude:this.height-2*this.cornerRadius,direction:this.direction+Math.PI}),e+=` L ${t.x} ${t.y}`,t.displace({magnitude:Math.SQRT2*this.cornerRadius,direction:this.direction+5*Math.PI/4}),e+=` A ${this.cornerRadius} ${this.cornerRadius} 90 0 1 ${t.x} ${t.y}`,t.displace({magnitude:this.width-2*this.cornerRadius,direction:this.direction+3*Math.PI/2}),e+=` L ${t.x} ${t.y}`,t.displace({magnitude:Math.SQRT2*this.cornerRadius,direction:this.direction+7*Math.PI/4}),e+=` A ${this.cornerRadius} ${this.cornerRadius} 90 0 1 ${t.x} ${t.y}`,t.displace({magnitude:this.height-2*this.cornerRadius,direction:this.direction}),e+=` L ${t.x} ${t.y}`,t.displace({magnitude:Math.SQRT2*this.cornerRadius,direction:this.direction+9*Math.PI/4}),e+=` A ${this.cornerRadius} ${this.cornerRadius} 90 0 1 ${t.x} ${t.y}`,e+=" Z",e}}var g,b,y,p,N=function(t,e,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(t):i?i.value:e.get(t)};class w{static create(){let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.id="id-"+a();let e=new w(t);return e.centerX=0,e.centerY=0,e.direction=-Math.PI/2,e.width=5.5,e.height=5.5,e.cornerRadius=0,e.domNode.setAttribute("stroke","black"),e.domNode.setAttribute("stroke-width","1"),e.domNode.setAttribute("stroke-opacity","1"),e.domNode.setAttribute("stroke-linejoin",""),e.domNode.setAttribute("stroke-dasharray",""),e.domNode.setAttribute("stroke-linecap",""),e.domNode.setAttribute("fill","white"),e.domNode.setAttribute("fill-opacity","1"),e}constructor(t){g.add(this),this.domNode=t,t.dataset.centerX||N(this,g,"m",b).call(this),t.dataset.centerY||N(this,g,"m",y).call(this)}get id(){return this.domNode.id}get centerX(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.centerX)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set centerX(t){Number.isFinite(t)?(this.domNode.dataset.centerX=`${t}`,N(this,g,"m",p).call(this)):console.error(`The specified center X coordinate is nonfinite: ${t}.`)}get centerY(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.centerY)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set centerY(t){Number.isFinite(t)?(this.domNode.dataset.centerY=`${t}`,N(this,g,"m",p).call(this)):console.error(`The specified center Y coordinate is nonfinite: ${t}.`)}drag(t,e){this.centerX+=t,this.centerY+=e}get direction(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.direction)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set direction(t){Number.isFinite(t)?(this.domNode.dataset.direction=`${t}`,N(this,g,"m",p).call(this)):console.error(`The specified direction angle is nonfinite: ${t}.`)}get width(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.width)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set width(t){Number.isFinite(t)?(this.domNode.dataset.width=`${t}`,N(this,g,"m",p).call(this)):console.error(`The specified width is nonfinite: ${t}.`)}get height(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.height)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set height(t){Number.isFinite(t)?(this.domNode.dataset.height=`${t}`,N(this,g,"m",p).call(this)):console.error(`The specified height is nonfinite: ${t}.`)}get cornerRadius(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.cornerRadius)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set cornerRadius(t){Number.isFinite(t)?(this.domNode.dataset.cornerRadius=`${t}`,N(this,g,"m",p).call(this)):console.error(`The specified corner radius is nonfinite: ${t}.`)}get bbox(){return u.Box.matching(this.domNode.getBBox())}serialized(){if(!this.id)throw new Error("Rectangle ID is falsy.");return{id:this.id}}static recreate(t,e){if(!(0,h.isNonNullObject)(t))throw new Error(`Saved rectangle is not an object: ${t}.`);if(!t.id)throw new Error("Saved rectangle ID is falsy.");if(!(0,h.isString)(t.id))throw new Error(`Saved rectangle ID is not a string: ${t.id}.`);let r=e.domNode.querySelector("#"+t.id);if(!r)throw new Error("Unable to find saved rectangle DOM node in parent drawing by ID.");if(!(r instanceof SVGPathElement))throw new Error(`DOM node found for saved rectangle is not an SVG path element: ${r}.`);let i=new w(r);return(0,h.isFiniteNumber)(t.width)&&(i.width=t.width),(0,h.isFiniteNumber)(t.height)&&(i.height=t.height),(0,h.isFiniteNumber)(t.borderRadius)&&(i.cornerRadius=t.borderRadius),(0,h.isFiniteNumber)(t.rotation)&&(i.direction=t.rotation-Math.PI/2),i}}g=new WeakSet,b=function(){let t=u.Box.matching(this.domNode.getBBox());this.domNode.dataset.centerX=`${t.centerX}`},y=function(){let t=u.Box.matching(this.domNode.getBBox());this.domNode.dataset.centerY=`${t.centerY}`},p=function(){let t=new f;t.centerX=this.centerX,t.centerY=this.centerY,t.direction=this.direction,t.width=this.width,t.height=this.height,t.cornerRadius=this.cornerRadius,this.domNode.setAttribute("d",t.toString())};class v{constructor(){this.centerX=0,this.centerY=0,this.direction=-Math.PI/2,this.width=0,this.height=0,this.tailsHeight=0}static matching(t){let e=new v;return e.centerX=t.centerX,e.centerY=t.centerY,e.direction=t.direction,e.width=t.width,e.height=t.height,e.tailsHeight=t.tailsHeight,e}toString(){let t=new m.Point(this.centerX,this.centerY),e=t.displaced({magnitude:this.height/2,direction:this.direction}),r=t.displaced({magnitude:this.width/2,direction:this.direction-Math.PI/2}).displaced({magnitude:this.height/2,direction:this.direction+Math.PI}),i=t.displaced({magnitude:this.width/2,direction:this.direction+Math.PI/2}).displaced({magnitude:this.height/2,direction:this.direction+Math.PI}),n=t.displaced({magnitude:this.height/2-this.tailsHeight,direction:this.direction+Math.PI});return`M ${e.x} ${e.y} L ${i.x} ${i.y} L ${n.x} ${n.y} L ${r.x} ${r.y} Z`}}var x,S,M,P,A=function(t,e,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(t):i?i.value:e.get(t)};class F{static create(){let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.id="id-"+a();let e=new F(t);return e.centerX=0,e.centerY=0,e.direction=-Math.PI/2,e.width=6.5,e.height=6.5,e.tailsHeight=0,e.domNode.setAttribute("stroke","black"),e.domNode.setAttribute("stroke-width","1"),e.domNode.setAttribute("stroke-opacity","1"),e.domNode.setAttribute("stroke-linejoin",""),e.domNode.setAttribute("stroke-dasharray",""),e.domNode.setAttribute("stroke-linecap",""),e.domNode.setAttribute("fill","white"),e.domNode.setAttribute("fill-opacity","1"),e}constructor(t){x.add(this),this.domNode=t,t.dataset.centerX||A(this,x,"m",S).call(this),t.dataset.centerY||A(this,x,"m",M).call(this)}get id(){return this.domNode.id}get centerX(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.centerX)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set centerX(t){Number.isFinite(t)?(this.domNode.dataset.centerX=`${t}`,A(this,x,"m",P).call(this)):console.error(`The specified center X coordinate is nonfinite: ${t}.`)}get centerY(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.centerY)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set centerY(t){Number.isFinite(t)?(this.domNode.dataset.centerY=`${t}`,A(this,x,"m",P).call(this)):console.error(`The specified center Y coordinate is nonfinite: ${t}.`)}drag(t,e){this.centerX+=t,this.centerY+=e}get direction(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.direction)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set direction(t){Number.isFinite(t)?(this.domNode.dataset.direction=`${t}`,A(this,x,"m",P).call(this)):console.error(`The specified direction angle is nonfinite: ${t}.`)}get width(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.width)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set width(t){Number.isFinite(t)?(this.domNode.dataset.width=`${t}`,A(this,x,"m",P).call(this)):console.error(`The specified width is nonfinite: ${t}.`)}get height(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.height)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set height(t){Number.isFinite(t)?(this.domNode.dataset.height=`${t}`,A(this,x,"m",P).call(this)):console.error(`The specified height is nonfinite: ${t}.`)}get tailsHeight(){var t;let e=Number.parseFloat(null!==(t=this.domNode.dataset.tailsHeight)&&void 0!==t?t:"");return Number.isFinite(e)?e:0}set tailsHeight(t){Number.isFinite(t)?(this.domNode.dataset.tailsHeight=`${t}`,A(this,x,"m",P).call(this)):console.error(`The specified tails height is nonfinite: ${t}.`)}get bbox(){return u.Box.matching(this.domNode.getBBox())}serialized(){if(!this.id)throw new Error("Triangle ID is falsy.");return{id:this.id}}static recreate(t,e){if(!(0,h.isNonNullObject)(t))throw new Error(`Saved triangle is not an object: ${t}.`);if(!t.id)throw new Error("Saved triangle ID is falsy.");if(!(0,h.isString)(t.id))throw new Error(`Saved triangle ID is not a string: ${t.id}.`);let r=e.domNode.querySelector("#"+t.id);if(!r)throw new Error("Unable to find saved triangle DOM node in parent drawing by ID.");if(!(r instanceof SVGPathElement))throw new Error(`DOM node found for saved triangle is not an SVG path element: ${r}.`);let i=new F(r);return(0,h.isFiniteNumber)(t.width)&&(i.width=t.width),(0,h.isFiniteNumber)(t.height)&&(i.height=t.height),(0,h.isFiniteNumber)(t.tailsHeight)&&(i.tailsHeight=t.tailsHeight),(0,h.isFiniteNumber)(t.rotation)&&(i.direction=t.rotation-Math.PI/2),i}}x=new WeakSet,S=function(){let t=u.Box.matching(this.domNode.getBBox());this.domNode.dataset.centerX=`${t.centerX}`},M=function(){let t=u.Box.matching(this.domNode.getBBox());this.domNode.dataset.centerY=`${t.centerY}`},P=function(){let t=new v;t.centerX=this.centerX,t.centerY=this.centerY,t.direction=this.direction,t.width=this.width,t.height=this.height,t.tailsHeight=this.tailsHeight,this.domNode.setAttribute("d",t.toString())}})(),i})());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnacanvas/draw.floating",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Draw floating elements",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,9 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@rnacanvas/boxes": "^5.0.1",
|
|
33
|
+
"@rnacanvas/draw.strung": "^2.0.1",
|
|
33
34
|
"@rnacanvas/draw.svg.text": "^1.3.0",
|
|
34
35
|
"@rnacanvas/points.oopified": "^2.1.0",
|
|
35
|
-
"@rnacanvas/value-check": "^
|
|
36
|
+
"@rnacanvas/value-check": "^2.7.0",
|
|
36
37
|
"jquery": "^4.0.0",
|
|
37
38
|
"uuid": "^13.0.0"
|
|
38
39
|
}
|