bruce-models 1.9.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/bruce-models.es5.js +317 -74
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +317 -74
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account-settings.js +2 -2
  6. package/dist/lib/account/account.js +201 -185
  7. package/dist/lib/account/account.js.map +1 -1
  8. package/dist/lib/ann-document/ann-document.js +94 -86
  9. package/dist/lib/ann-document/ann-document.js.map +1 -1
  10. package/dist/lib/api/abstract-api.js +260 -246
  11. package/dist/lib/api/abstract-api.js.map +1 -1
  12. package/dist/lib/api/api-getters.js +134 -134
  13. package/dist/lib/api/api.js +93 -93
  14. package/dist/lib/api/bruce-api.js +216 -216
  15. package/dist/lib/api/cam-api.js +85 -82
  16. package/dist/lib/api/cam-api.js.map +1 -1
  17. package/dist/lib/api/global-api.js +81 -81
  18. package/dist/lib/api/idm-api.js +85 -82
  19. package/dist/lib/api/idm-api.js.map +1 -1
  20. package/dist/lib/bruce-models.js +86 -86
  21. package/dist/lib/calculator/calculator.js +341 -341
  22. package/dist/lib/client-file/client-file.js +249 -245
  23. package/dist/lib/client-file/client-file.js.map +1 -1
  24. package/dist/lib/common/bounds.js +61 -61
  25. package/dist/lib/common/bruce-event.js +46 -46
  26. package/dist/lib/common/bruce-variable.js +60 -60
  27. package/dist/lib/common/cache.js +165 -165
  28. package/dist/lib/common/camera.js +11 -11
  29. package/dist/lib/common/cartes.js +123 -123
  30. package/dist/lib/common/carto.js +60 -60
  31. package/dist/lib/common/color.js +86 -86
  32. package/dist/lib/common/delay-queue.js +56 -56
  33. package/dist/lib/common/dictionary.js +2 -2
  34. package/dist/lib/common/geometry.js +120 -120
  35. package/dist/lib/common/transform.js +2 -2
  36. package/dist/lib/common/utc.js +39 -39
  37. package/dist/lib/custom-form/custom-form-content.js +26 -26
  38. package/dist/lib/custom-form/custom-form.js +114 -106
  39. package/dist/lib/custom-form/custom-form.js.map +1 -1
  40. package/dist/lib/data-lab/data-lab.js +49 -49
  41. package/dist/lib/entity/entity-attachment-type.js +87 -83
  42. package/dist/lib/entity/entity-attachment-type.js.map +1 -1
  43. package/dist/lib/entity/entity-attachment.js +126 -122
  44. package/dist/lib/entity/entity-attachment.js.map +1 -1
  45. package/dist/lib/entity/entity-attribute.js +29 -29
  46. package/dist/lib/entity/entity-comment.js +86 -82
  47. package/dist/lib/entity/entity-comment.js.map +1 -1
  48. package/dist/lib/entity/entity-coords.js +153 -149
  49. package/dist/lib/entity/entity-coords.js.map +1 -1
  50. package/dist/lib/entity/entity-link.js +86 -82
  51. package/dist/lib/entity/entity-link.js.map +1 -1
  52. package/dist/lib/entity/entity-lod-category.js +108 -100
  53. package/dist/lib/entity/entity-lod-category.js.map +1 -1
  54. package/dist/lib/entity/entity-lod.js +197 -185
  55. package/dist/lib/entity/entity-lod.js.map +1 -1
  56. package/dist/lib/entity/entity-relation-type.js +117 -109
  57. package/dist/lib/entity/entity-relation-type.js.map +1 -1
  58. package/dist/lib/entity/entity-relation.js +140 -132
  59. package/dist/lib/entity/entity-relation.js.map +1 -1
  60. package/dist/lib/entity/entity-source.js +136 -136
  61. package/dist/lib/entity/entity-tag.js +157 -149
  62. package/dist/lib/entity/entity-tag.js.map +1 -1
  63. package/dist/lib/entity/entity-type-visual-settings.js +13 -13
  64. package/dist/lib/entity/entity-type.js +121 -113
  65. package/dist/lib/entity/entity-type.js.map +1 -1
  66. package/dist/lib/entity/entity.js +331 -319
  67. package/dist/lib/entity/entity.js.map +1 -1
  68. package/dist/lib/entity/getters/batched-data-getter.js +84 -84
  69. package/dist/lib/entity/getters/entity-filter-getter.js +306 -303
  70. package/dist/lib/entity/getters/entity-filter-getter.js.map +1 -1
  71. package/dist/lib/entity/getters/entity-globe.js +211 -211
  72. package/dist/lib/entity/getters/view-monitor.js +2 -2
  73. package/dist/lib/import/import-cad.js +53 -53
  74. package/dist/lib/import/import-csv.js +23 -23
  75. package/dist/lib/import/import-json.js +23 -23
  76. package/dist/lib/import/import-kml.js +23 -23
  77. package/dist/lib/import/imported-file.js +99 -91
  78. package/dist/lib/import/imported-file.js.map +1 -1
  79. package/dist/lib/internal/uploader.js +76 -76
  80. package/dist/lib/markup/markup.js +185 -185
  81. package/dist/lib/plugin/plugin.js +91 -83
  82. package/dist/lib/plugin/plugin.js.map +1 -1
  83. package/dist/lib/program-key/program-key.js +119 -111
  84. package/dist/lib/program-key/program-key.js.map +1 -1
  85. package/dist/lib/project/menu-item.js +121 -121
  86. package/dist/lib/project/project-view-bookmark.js +159 -147
  87. package/dist/lib/project/project-view-bookmark.js.map +1 -1
  88. package/dist/lib/project/project-view-legacy-tile.js +77 -77
  89. package/dist/lib/project/project-view-tile.js +125 -125
  90. package/dist/lib/project/project-view.js +141 -133
  91. package/dist/lib/project/project-view.js.map +1 -1
  92. package/dist/lib/project/zoom-control.js +17 -17
  93. package/dist/lib/server/message-broker.js +142 -142
  94. package/dist/lib/server/pending-action.js +71 -71
  95. package/dist/lib/server/task.js +63 -63
  96. package/dist/lib/style/style.js +125 -117
  97. package/dist/lib/style/style.js.map +1 -1
  98. package/dist/lib/tileset/tileset.js +431 -415
  99. package/dist/lib/tileset/tileset.js.map +1 -1
  100. package/dist/lib/user/permission.js +20 -20
  101. package/dist/lib/user/session.js +141 -137
  102. package/dist/lib/user/session.js.map +1 -1
  103. package/dist/lib/user/user-group.js +94 -94
  104. package/dist/lib/user/user.js +474 -446
  105. package/dist/lib/user/user.js.map +1 -1
  106. package/dist/lib/util/encrypt-utils.js +19 -19
  107. package/dist/lib/util/math-utils.js +40 -40
  108. package/dist/lib/util/object-utils.js +17 -17
  109. package/dist/lib/util/path-utils.js +61 -61
  110. package/dist/lib/util/url-utils.js +94 -94
  111. package/dist/types/api/abstract-api.d.ts +6 -0
  112. package/package.json +3 -2
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Camera = void 0;
4
- var Camera;
5
- (function (Camera) {
6
- let EFrustum;
7
- (function (EFrustum) {
8
- EFrustum[EFrustum["Perspective"] = 0] = "Perspective";
9
- EFrustum[EFrustum["Orthographic"] = 1] = "Orthographic";
10
- })(EFrustum = Camera.EFrustum || (Camera.EFrustum = {}));
11
- })(Camera = exports.Camera || (exports.Camera = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Camera = void 0;
4
+ var Camera;
5
+ (function (Camera) {
6
+ let EFrustum;
7
+ (function (EFrustum) {
8
+ EFrustum[EFrustum["Perspective"] = 0] = "Perspective";
9
+ EFrustum[EFrustum["Orthographic"] = 1] = "Orthographic";
10
+ })(EFrustum = Camera.EFrustum || (Camera.EFrustum = {}));
11
+ })(Camera = exports.Camera || (exports.Camera = {}));
12
12
  //# sourceMappingURL=camera.js.map
@@ -1,124 +1,124 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Cartes = void 0;
4
- /**
5
- * Describes 2d and 3d coordinates.
6
- *
7
- * In 2d the x/y typically refers to a window left/top offset.
8
- * In 3d the x/y/z, the units are in meters.
9
- */
10
- var Cartes;
11
- (function (Cartes) {
12
- function ValidateCartes2(cartes) {
13
- if (!cartes) {
14
- return false;
15
- }
16
- else if (!cartes.x && cartes.x != 0) {
17
- return false;
18
- }
19
- else if (!cartes.y && cartes.y != 0) {
20
- return false;
21
- }
22
- return true;
23
- }
24
- Cartes.ValidateCartes2 = ValidateCartes2;
25
- function ValidateCartes3(cartes) {
26
- if (!ValidateCartes2(cartes)) {
27
- return false;
28
- }
29
- else if (!cartes.z && cartes.z != 0) {
30
- return false;
31
- }
32
- return true;
33
- }
34
- Cartes.ValidateCartes3 = ValidateCartes3;
35
- function IsEqualCartes2(a, b) {
36
- if (a.x != b.x) {
37
- return false;
38
- }
39
- else if (a.y != b.y) {
40
- return false;
41
- }
42
- return true;
43
- }
44
- Cartes.IsEqualCartes2 = IsEqualCartes2;
45
- function IsEqualCartes3(a, b) {
46
- if (!IsEqualCartes2(a, b)) {
47
- return false;
48
- }
49
- else if (a.z != b.z) {
50
- return false;
51
- }
52
- return true;
53
- }
54
- Cartes.IsEqualCartes3 = IsEqualCartes3;
55
- /**
56
- * Returns true if the given ring is closed.
57
- * A ring is closed if the first and last point are equal.
58
- * A ring with less than 2 points is not closed.
59
- * @param points
60
- * @returns
61
- */
62
- function IsRing2Closed(points) {
63
- if (points.length < 2) {
64
- return false;
65
- }
66
- else if (!IsEqualCartes2(points[0], points[points.length - 1])) {
67
- return false;
68
- }
69
- return true;
70
- }
71
- Cartes.IsRing2Closed = IsRing2Closed;
72
- /**
73
- * Returns true if the given ring is closed.
74
- * A ring is closed if the first and last point are equal.
75
- * A ring with less than 2 points is not closed.
76
- * @param points
77
- * @returns
78
- */
79
- function IsRing3Closed(points) {
80
- if (points.length < 2) {
81
- return false;
82
- }
83
- else if (!IsEqualCartes3(points[0], points[points.length - 1])) {
84
- return false;
85
- }
86
- return true;
87
- }
88
- Cartes.IsRing3Closed = IsRing3Closed;
89
- /**
90
- * Closes given ring by adding the first point to the end of the array.
91
- * This will mutate the given array.
92
- * Will not do anything if the ring is already closed.
93
- * @param points
94
- * @returns
95
- */
96
- function CloseRing2(points) {
97
- if (points.length < 2) {
98
- return;
99
- }
100
- else if (IsRing2Closed(points)) {
101
- return;
102
- }
103
- points.push(points[0]);
104
- }
105
- Cartes.CloseRing2 = CloseRing2;
106
- /**
107
- * Closes given ring by adding the first point to the end of the array.
108
- * This will mutate the given array.
109
- * Will not do anything if the ring is already closed.
110
- * @param points
111
- * @returns
112
- */
113
- function CloseRing3(points) {
114
- if (points.length < 2) {
115
- return;
116
- }
117
- else if (IsRing3Closed(points)) {
118
- return;
119
- }
120
- points.push(points[0]);
121
- }
122
- Cartes.CloseRing3 = CloseRing3;
123
- })(Cartes = exports.Cartes || (exports.Cartes = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cartes = void 0;
4
+ /**
5
+ * Describes 2d and 3d coordinates.
6
+ *
7
+ * In 2d the x/y typically refers to a window left/top offset.
8
+ * In 3d the x/y/z, the units are in meters.
9
+ */
10
+ var Cartes;
11
+ (function (Cartes) {
12
+ function ValidateCartes2(cartes) {
13
+ if (!cartes) {
14
+ return false;
15
+ }
16
+ else if (!cartes.x && cartes.x != 0) {
17
+ return false;
18
+ }
19
+ else if (!cartes.y && cartes.y != 0) {
20
+ return false;
21
+ }
22
+ return true;
23
+ }
24
+ Cartes.ValidateCartes2 = ValidateCartes2;
25
+ function ValidateCartes3(cartes) {
26
+ if (!ValidateCartes2(cartes)) {
27
+ return false;
28
+ }
29
+ else if (!cartes.z && cartes.z != 0) {
30
+ return false;
31
+ }
32
+ return true;
33
+ }
34
+ Cartes.ValidateCartes3 = ValidateCartes3;
35
+ function IsEqualCartes2(a, b) {
36
+ if (a.x != b.x) {
37
+ return false;
38
+ }
39
+ else if (a.y != b.y) {
40
+ return false;
41
+ }
42
+ return true;
43
+ }
44
+ Cartes.IsEqualCartes2 = IsEqualCartes2;
45
+ function IsEqualCartes3(a, b) {
46
+ if (!IsEqualCartes2(a, b)) {
47
+ return false;
48
+ }
49
+ else if (a.z != b.z) {
50
+ return false;
51
+ }
52
+ return true;
53
+ }
54
+ Cartes.IsEqualCartes3 = IsEqualCartes3;
55
+ /**
56
+ * Returns true if the given ring is closed.
57
+ * A ring is closed if the first and last point are equal.
58
+ * A ring with less than 2 points is not closed.
59
+ * @param points
60
+ * @returns
61
+ */
62
+ function IsRing2Closed(points) {
63
+ if (points.length < 2) {
64
+ return false;
65
+ }
66
+ else if (!IsEqualCartes2(points[0], points[points.length - 1])) {
67
+ return false;
68
+ }
69
+ return true;
70
+ }
71
+ Cartes.IsRing2Closed = IsRing2Closed;
72
+ /**
73
+ * Returns true if the given ring is closed.
74
+ * A ring is closed if the first and last point are equal.
75
+ * A ring with less than 2 points is not closed.
76
+ * @param points
77
+ * @returns
78
+ */
79
+ function IsRing3Closed(points) {
80
+ if (points.length < 2) {
81
+ return false;
82
+ }
83
+ else if (!IsEqualCartes3(points[0], points[points.length - 1])) {
84
+ return false;
85
+ }
86
+ return true;
87
+ }
88
+ Cartes.IsRing3Closed = IsRing3Closed;
89
+ /**
90
+ * Closes given ring by adding the first point to the end of the array.
91
+ * This will mutate the given array.
92
+ * Will not do anything if the ring is already closed.
93
+ * @param points
94
+ * @returns
95
+ */
96
+ function CloseRing2(points) {
97
+ if (points.length < 2) {
98
+ return;
99
+ }
100
+ else if (IsRing2Closed(points)) {
101
+ return;
102
+ }
103
+ points.push(points[0]);
104
+ }
105
+ Cartes.CloseRing2 = CloseRing2;
106
+ /**
107
+ * Closes given ring by adding the first point to the end of the array.
108
+ * This will mutate the given array.
109
+ * Will not do anything if the ring is already closed.
110
+ * @param points
111
+ * @returns
112
+ */
113
+ function CloseRing3(points) {
114
+ if (points.length < 2) {
115
+ return;
116
+ }
117
+ else if (IsRing3Closed(points)) {
118
+ return;
119
+ }
120
+ points.push(points[0]);
121
+ }
122
+ Cartes.CloseRing3 = CloseRing3;
123
+ })(Cartes = exports.Cartes || (exports.Cartes = {}));
124
124
  //# sourceMappingURL=cartes.js.map
@@ -1,61 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Carto = void 0;
4
- /**
5
- * Describes a geographic point.
6
- * The units of the stored data should be in Degrees.
7
- * Utilities may use this in Radians for temporary calculations.
8
- */
9
- var Carto;
10
- (function (Carto) {
11
- function ValidateCarto(carto) {
12
- if (!carto) {
13
- return false;
14
- }
15
- else if (!carto.longitude && carto.longitude != 0) {
16
- return false;
17
- }
18
- else if (!carto.latitude && carto.latitude != 0) {
19
- return false;
20
- }
21
- return true;
22
- }
23
- Carto.ValidateCarto = ValidateCarto;
24
- function IsEqual(a, b) {
25
- if (a.longitude != b.longitude) {
26
- return false;
27
- }
28
- else if (a.latitude != b.latitude) {
29
- return false;
30
- }
31
- return true;
32
- }
33
- Carto.IsEqual = IsEqual;
34
- function GetCenter(list) {
35
- let center = {
36
- longitude: 0,
37
- latitude: 0,
38
- altitude: 0
39
- };
40
- for (let i = 0; i < list.length; i++) {
41
- const carto = list[i];
42
- center.longitude += carto.longitude;
43
- center.latitude += carto.latitude;
44
- if (carto.altitude) {
45
- center.altitude += carto.altitude;
46
- }
47
- }
48
- if (center.longitude) {
49
- center.longitude /= list.length;
50
- }
51
- if (center.latitude) {
52
- center.latitude /= list.length;
53
- }
54
- if (center.altitude) {
55
- center.altitude /= list.length;
56
- }
57
- return center;
58
- }
59
- Carto.GetCenter = GetCenter;
60
- })(Carto = exports.Carto || (exports.Carto = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Carto = void 0;
4
+ /**
5
+ * Describes a geographic point.
6
+ * The units of the stored data should be in Degrees.
7
+ * Utilities may use this in Radians for temporary calculations.
8
+ */
9
+ var Carto;
10
+ (function (Carto) {
11
+ function ValidateCarto(carto) {
12
+ if (!carto) {
13
+ return false;
14
+ }
15
+ else if (!carto.longitude && carto.longitude != 0) {
16
+ return false;
17
+ }
18
+ else if (!carto.latitude && carto.latitude != 0) {
19
+ return false;
20
+ }
21
+ return true;
22
+ }
23
+ Carto.ValidateCarto = ValidateCarto;
24
+ function IsEqual(a, b) {
25
+ if (a.longitude != b.longitude) {
26
+ return false;
27
+ }
28
+ else if (a.latitude != b.latitude) {
29
+ return false;
30
+ }
31
+ return true;
32
+ }
33
+ Carto.IsEqual = IsEqual;
34
+ function GetCenter(list) {
35
+ let center = {
36
+ longitude: 0,
37
+ latitude: 0,
38
+ altitude: 0
39
+ };
40
+ for (let i = 0; i < list.length; i++) {
41
+ const carto = list[i];
42
+ center.longitude += carto.longitude;
43
+ center.latitude += carto.latitude;
44
+ if (carto.altitude) {
45
+ center.altitude += carto.altitude;
46
+ }
47
+ }
48
+ if (center.longitude) {
49
+ center.longitude /= list.length;
50
+ }
51
+ if (center.latitude) {
52
+ center.latitude /= list.length;
53
+ }
54
+ if (center.altitude) {
55
+ center.altitude /= list.length;
56
+ }
57
+ return center;
58
+ }
59
+ Carto.GetCenter = GetCenter;
60
+ })(Carto = exports.Carto || (exports.Carto = {}));
61
61
  //# sourceMappingURL=carto.js.map
@@ -1,87 +1,87 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Color = void 0;
4
- var Color;
5
- (function (Color) {
6
- let EBlendMode;
7
- (function (EBlendMode) {
8
- EBlendMode[EBlendMode["HIGHLIGHT"] = 0] = "HIGHLIGHT";
9
- EBlendMode[EBlendMode["REPLACE"] = 1] = "REPLACE";
10
- EBlendMode[EBlendMode["MIX"] = 2] = "MIX";
11
- })(EBlendMode = Color.EBlendMode || (Color.EBlendMode = {}));
12
- function RandomColor() {
13
- // https://stackoverflow.com/a/7352887
14
- const brightness = 4;
15
- const rgb = [Math.random() * 256, Math.random() * 256, Math.random() * 256];
16
- const mix = [brightness * 51, brightness * 51, brightness * 51];
17
- const mixedrgb = [rgb[0] + mix[0], rgb[1] + mix[1], rgb[2] + mix[2]].map(function (x) {
18
- return Math.round(x / 2.0);
19
- });
20
- const str = "rgba(" + mixedrgb.join(",") + ",0.9" + ")";
21
- return ColorFromStr(str);
22
- }
23
- Color.RandomColor = RandomColor;
24
- /**
25
- * Attempts to parse a given color string into a model.
26
- * @param str
27
- * @returns
28
- */
29
- function ColorFromStr(str) {
30
- let r, g, b, a;
31
- const rgba = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([^\)]+)\s*)?\)$/.exec(str);
32
- if (rgba) {
33
- r = parseInt(rgba[1]);
34
- g = parseInt(rgba[2]);
35
- b = parseInt(rgba[3]);
36
- a = rgba[4] != null ? parseFloat(rgba[4]) : 1;
37
- return {
38
- red: r,
39
- green: g,
40
- blue: b,
41
- alpha: a
42
- };
43
- }
44
- if (str.charAt(0) == "#") {
45
- str = str.substring(1);
46
- }
47
- if (str.length == 6) {
48
- // rgb.
49
- const parsed = /^(.{2})(.{2})(.{2})/.exec(str);
50
- if (!parsed) {
51
- return null;
52
- }
53
- r = parseInt(parsed[1], 16);
54
- g = parseInt(parsed[2], 16);
55
- b = parseInt(parsed[3], 16);
56
- a = 1;
57
- }
58
- else if (str.length == 8) {
59
- // rgba.
60
- const parsed = /^(.{2})(.{2})(.{2})(.{2})/.exec(str);
61
- if (!parsed) {
62
- return null;
63
- }
64
- r = parseInt(parsed[1], 16);
65
- g = parseInt(parsed[2], 16);
66
- b = parseInt(parsed[3], 16);
67
- a = parseInt(parsed[4], 16);
68
- if (a != 0) {
69
- a = a / 255;
70
- }
71
- }
72
- else {
73
- return null;
74
- }
75
- if (a == null) {
76
- a = 1;
77
- }
78
- return {
79
- red: r,
80
- blue: b,
81
- green: g,
82
- alpha: a
83
- };
84
- }
85
- Color.ColorFromStr = ColorFromStr;
86
- })(Color = exports.Color || (exports.Color = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Color = void 0;
4
+ var Color;
5
+ (function (Color) {
6
+ let EBlendMode;
7
+ (function (EBlendMode) {
8
+ EBlendMode[EBlendMode["HIGHLIGHT"] = 0] = "HIGHLIGHT";
9
+ EBlendMode[EBlendMode["REPLACE"] = 1] = "REPLACE";
10
+ EBlendMode[EBlendMode["MIX"] = 2] = "MIX";
11
+ })(EBlendMode = Color.EBlendMode || (Color.EBlendMode = {}));
12
+ function RandomColor() {
13
+ // https://stackoverflow.com/a/7352887
14
+ const brightness = 4;
15
+ const rgb = [Math.random() * 256, Math.random() * 256, Math.random() * 256];
16
+ const mix = [brightness * 51, brightness * 51, brightness * 51];
17
+ const mixedrgb = [rgb[0] + mix[0], rgb[1] + mix[1], rgb[2] + mix[2]].map(function (x) {
18
+ return Math.round(x / 2.0);
19
+ });
20
+ const str = "rgba(" + mixedrgb.join(",") + ",0.9" + ")";
21
+ return ColorFromStr(str);
22
+ }
23
+ Color.RandomColor = RandomColor;
24
+ /**
25
+ * Attempts to parse a given color string into a model.
26
+ * @param str
27
+ * @returns
28
+ */
29
+ function ColorFromStr(str) {
30
+ let r, g, b, a;
31
+ const rgba = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([^\)]+)\s*)?\)$/.exec(str);
32
+ if (rgba) {
33
+ r = parseInt(rgba[1]);
34
+ g = parseInt(rgba[2]);
35
+ b = parseInt(rgba[3]);
36
+ a = rgba[4] != null ? parseFloat(rgba[4]) : 1;
37
+ return {
38
+ red: r,
39
+ green: g,
40
+ blue: b,
41
+ alpha: a
42
+ };
43
+ }
44
+ if (str.charAt(0) == "#") {
45
+ str = str.substring(1);
46
+ }
47
+ if (str.length == 6) {
48
+ // rgb.
49
+ const parsed = /^(.{2})(.{2})(.{2})/.exec(str);
50
+ if (!parsed) {
51
+ return null;
52
+ }
53
+ r = parseInt(parsed[1], 16);
54
+ g = parseInt(parsed[2], 16);
55
+ b = parseInt(parsed[3], 16);
56
+ a = 1;
57
+ }
58
+ else if (str.length == 8) {
59
+ // rgba.
60
+ const parsed = /^(.{2})(.{2})(.{2})(.{2})/.exec(str);
61
+ if (!parsed) {
62
+ return null;
63
+ }
64
+ r = parseInt(parsed[1], 16);
65
+ g = parseInt(parsed[2], 16);
66
+ b = parseInt(parsed[3], 16);
67
+ a = parseInt(parsed[4], 16);
68
+ if (a != 0) {
69
+ a = a / 255;
70
+ }
71
+ }
72
+ else {
73
+ return null;
74
+ }
75
+ if (a == null) {
76
+ a = 1;
77
+ }
78
+ return {
79
+ red: r,
80
+ blue: b,
81
+ green: g,
82
+ alpha: a
83
+ };
84
+ }
85
+ Color.ColorFromStr = ColorFromStr;
86
+ })(Color = exports.Color || (exports.Color = {}));
87
87
  //# sourceMappingURL=color.js.map