bruce-models 0.7.5 → 0.7.7

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 (102) hide show
  1. package/dist/bruce-models.es5.js +183 -16
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +180 -14
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account.js +244 -244
  6. package/dist/lib/ann-document/ann-document.js +116 -116
  7. package/dist/lib/api/abstract-api.js +269 -267
  8. package/dist/lib/api/abstract-api.js.map +1 -1
  9. package/dist/lib/api/api.js +85 -85
  10. package/dist/lib/api/bruce-api.js +228 -202
  11. package/dist/lib/api/bruce-api.js.map +1 -1
  12. package/dist/lib/api/cam-api.js +132 -132
  13. package/dist/lib/api/cam-api.js.map +1 -1
  14. package/dist/lib/api/global-api.js +131 -131
  15. package/dist/lib/api/global-api.js.map +1 -1
  16. package/dist/lib/api/idm-api.js +132 -132
  17. package/dist/lib/api/idm-api.js.map +1 -1
  18. package/dist/lib/bruce-models.js +84 -83
  19. package/dist/lib/bruce-models.js.map +1 -1
  20. package/dist/lib/calculator/calculator.js +158 -158
  21. package/dist/lib/client-file/client-file.js +188 -188
  22. package/dist/lib/common/bounds.js +2 -2
  23. package/dist/lib/common/bruce-event.js +48 -48
  24. package/dist/lib/common/bruce-variable.js +54 -54
  25. package/dist/lib/common/cache.js +86 -86
  26. package/dist/lib/common/camera.js +11 -11
  27. package/dist/lib/common/cartes.js +55 -55
  28. package/dist/lib/common/carto.js +60 -60
  29. package/dist/lib/common/color.js +86 -86
  30. package/dist/lib/common/delay-queue.js +60 -60
  31. package/dist/lib/common/dictionary.js +2 -2
  32. package/dist/lib/common/geometry.js +120 -120
  33. package/dist/lib/common/transform.js +2 -2
  34. package/dist/lib/common/utc.js +39 -39
  35. package/dist/lib/custom-form/custom-form.js +136 -136
  36. package/dist/lib/data-lab/data-lab.js +90 -90
  37. package/dist/lib/entity/entity-attachment-type.js +132 -132
  38. package/dist/lib/entity/entity-attachment.js +208 -208
  39. package/dist/lib/entity/entity-comment.js +132 -132
  40. package/dist/lib/entity/entity-coords.js +181 -181
  41. package/dist/lib/entity/entity-link.js +132 -132
  42. package/dist/lib/entity/entity-lod.js +189 -189
  43. package/dist/lib/entity/entity-relation-type.js +150 -150
  44. package/dist/lib/entity/entity-relation.js +189 -189
  45. package/dist/lib/entity/entity-source.js +176 -176
  46. package/dist/lib/entity/entity-tag.js +229 -229
  47. package/dist/lib/entity/entity-type.js +163 -163
  48. package/dist/lib/entity/entity.js +358 -358
  49. package/dist/lib/entity/getters/batched-data-getter.js +91 -91
  50. package/dist/lib/entity/getters/entity-filter-getter.js +344 -344
  51. package/dist/lib/entity/getters/entity-globe.js +135 -135
  52. package/dist/lib/entity/getters/view-monitor.js +2 -2
  53. package/dist/lib/import/import-cad.js +82 -82
  54. package/dist/lib/import/import-csv.js +51 -51
  55. package/dist/lib/import/import-json.js +51 -51
  56. package/dist/lib/import/import-kml.js +51 -51
  57. package/dist/lib/import/imported-file.js +121 -121
  58. package/dist/lib/markup/markup.js +40 -40
  59. package/dist/lib/program-key/program-key.js +152 -152
  60. package/dist/lib/project/menu-item.js +115 -115
  61. package/dist/lib/project/project-view-bookmark.js +183 -172
  62. package/dist/lib/project/project-view-bookmark.js.map +1 -1
  63. package/dist/lib/project/{project-view-tile-source.js → project-view-legacy-tile.js} +116 -116
  64. package/dist/lib/project/project-view-legacy-tile.js.map +1 -0
  65. package/dist/lib/project/project-view-tile.js +120 -0
  66. package/dist/lib/project/project-view-tile.js.map +1 -0
  67. package/dist/lib/project/project-view.js +177 -166
  68. package/dist/lib/project/project-view.js.map +1 -1
  69. package/dist/lib/project/zoom-control.js +17 -17
  70. package/dist/lib/server/pending-action.js +106 -106
  71. package/dist/lib/server/task.js +113 -113
  72. package/dist/lib/style/style.js +152 -152
  73. package/dist/lib/tileset/tileset-cad.js +2 -2
  74. package/dist/lib/tileset/tileset-entities-map-tiles.js +18 -18
  75. package/dist/lib/tileset/tileset-entities.js +2 -2
  76. package/dist/lib/tileset/tileset-ext-map-tiles.js +17 -17
  77. package/dist/lib/tileset/tileset-ext-terrain-tiles.js +2 -2
  78. package/dist/lib/tileset/tileset-map-tiles.js +2 -2
  79. package/dist/lib/tileset/tileset-pointcloud.js +2 -2
  80. package/dist/lib/tileset/tileset-terrain-tiles.js +2 -2
  81. package/dist/lib/tileset/tileset.js +403 -403
  82. package/dist/lib/user/permission.js +20 -20
  83. package/dist/lib/user/session.js +160 -160
  84. package/dist/lib/user/user-group.js +139 -139
  85. package/dist/lib/user/user.js +451 -451
  86. package/dist/lib/util/encrypt-utils.js +20 -20
  87. package/dist/lib/util/math-utils.js +41 -41
  88. package/dist/lib/util/object-utils.js +17 -17
  89. package/dist/lib/util/path-utils.js +61 -61
  90. package/dist/lib/util/url-utils.js +107 -107
  91. package/dist/types/api/abstract-api.d.ts +1 -1
  92. package/dist/types/api/bruce-api.d.ts +22 -2
  93. package/dist/types/api/cam-api.d.ts +1 -1
  94. package/dist/types/api/global-api.d.ts +1 -1
  95. package/dist/types/api/idm-api.d.ts +1 -1
  96. package/dist/types/bruce-models.d.ts +2 -1
  97. package/dist/types/project/project-view-bookmark.d.ts +85 -36
  98. package/dist/types/project/{project-view-tile-source.d.ts → project-view-legacy-tile.d.ts} +1 -1
  99. package/dist/types/project/project-view-tile.d.ts +68 -0
  100. package/dist/types/project/project-view.d.ts +64 -39
  101. package/package.json +1 -1
  102. package/dist/lib/project/project-view-tile-source.js.map +0 -1
@@ -1,87 +1,87 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CacheControl = void 0;
4
- var CacheItem = /** @class */ (function () {
5
- function CacheItem(id, data, duration) {
6
- this.Id = id;
7
- this.Data = data;
8
- this.Duration = duration;
9
- this._created = duration > -1 ? new Date() : null;
10
- }
11
- CacheItem.prototype.IsExpired = function () {
12
- if (this._created == null) {
13
- return false;
14
- }
15
- return (new Date().getTime() - this._created.getTime()) / 1000 > this.Duration;
16
- };
17
- return CacheItem;
18
- }());
19
- /**
20
- * Simple local cache controller.
21
- */
22
- var CacheControl = /** @class */ (function () {
23
- function CacheControl() {
24
- this.data = {};
25
- this.Disabled = false;
26
- }
27
- CacheControl.prototype.Set = function (id, data, duration) {
28
- if (duration === void 0) { duration = -1; }
29
- this.data[id + ""] = new CacheItem(id + "", data, duration);
30
- };
31
- CacheControl.prototype.Get = function (id) {
32
- if (this.Disabled) {
33
- return null;
34
- }
35
- var item = this.data[id + ""];
36
- if (item == null) {
37
- return null;
38
- }
39
- if (item.IsExpired()) {
40
- delete this.data[id + ""];
41
- return null;
42
- }
43
- return item.Data;
44
- };
45
- CacheControl.prototype.Clear = function () {
46
- this.data = {};
47
- };
48
- CacheControl.prototype.Remove = function (id) {
49
- delete this.data[id + ""];
50
- };
51
- CacheControl.prototype.RemoveByStartsWith = function (text) {
52
- for (var key in this.data) {
53
- if (key.startsWith(text)) {
54
- delete this.data[key];
55
- }
56
- }
57
- };
58
- CacheControl.prototype.RemoveByContains = function (text) {
59
- for (var key in this.data) {
60
- if (key.includes(text)) {
61
- delete this.data[key];
62
- }
63
- }
64
- };
65
- CacheControl.prototype.GetKeys = function () {
66
- if (this.Disabled) {
67
- return [];
68
- }
69
- return Object.keys(this.data);
70
- };
71
- CacheControl.prototype.GetValues = function () {
72
- if (this.Disabled) {
73
- return [];
74
- }
75
- var values = [];
76
- for (var key in this.data) {
77
- var data = this.Get(key);
78
- if (data != null) {
79
- values.push(data);
80
- }
81
- }
82
- return values;
83
- };
84
- return CacheControl;
85
- }());
86
- exports.CacheControl = CacheControl;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CacheControl = void 0;
4
+ var CacheItem = /** @class */ (function () {
5
+ function CacheItem(id, data, duration) {
6
+ this.Id = id;
7
+ this.Data = data;
8
+ this.Duration = duration;
9
+ this._created = duration > -1 ? new Date() : null;
10
+ }
11
+ CacheItem.prototype.IsExpired = function () {
12
+ if (this._created == null) {
13
+ return false;
14
+ }
15
+ return (new Date().getTime() - this._created.getTime()) / 1000 > this.Duration;
16
+ };
17
+ return CacheItem;
18
+ }());
19
+ /**
20
+ * Simple local cache controller.
21
+ */
22
+ var CacheControl = /** @class */ (function () {
23
+ function CacheControl() {
24
+ this.data = {};
25
+ this.Disabled = false;
26
+ }
27
+ CacheControl.prototype.Set = function (id, data, duration) {
28
+ if (duration === void 0) { duration = -1; }
29
+ this.data[id + ""] = new CacheItem(id + "", data, duration);
30
+ };
31
+ CacheControl.prototype.Get = function (id) {
32
+ if (this.Disabled) {
33
+ return null;
34
+ }
35
+ var item = this.data[id + ""];
36
+ if (item == null) {
37
+ return null;
38
+ }
39
+ if (item.IsExpired()) {
40
+ delete this.data[id + ""];
41
+ return null;
42
+ }
43
+ return item.Data;
44
+ };
45
+ CacheControl.prototype.Clear = function () {
46
+ this.data = {};
47
+ };
48
+ CacheControl.prototype.Remove = function (id) {
49
+ delete this.data[id + ""];
50
+ };
51
+ CacheControl.prototype.RemoveByStartsWith = function (text) {
52
+ for (var key in this.data) {
53
+ if (key.startsWith(text)) {
54
+ delete this.data[key];
55
+ }
56
+ }
57
+ };
58
+ CacheControl.prototype.RemoveByContains = function (text) {
59
+ for (var key in this.data) {
60
+ if (key.includes(text)) {
61
+ delete this.data[key];
62
+ }
63
+ }
64
+ };
65
+ CacheControl.prototype.GetKeys = function () {
66
+ if (this.Disabled) {
67
+ return [];
68
+ }
69
+ return Object.keys(this.data);
70
+ };
71
+ CacheControl.prototype.GetValues = function () {
72
+ if (this.Disabled) {
73
+ return [];
74
+ }
75
+ var values = [];
76
+ for (var key in this.data) {
77
+ var data = this.Get(key);
78
+ if (data != null) {
79
+ values.push(data);
80
+ }
81
+ }
82
+ return values;
83
+ };
84
+ return CacheControl;
85
+ }());
86
+ exports.CacheControl = CacheControl;
87
87
  //# sourceMappingURL=cache.js.map
@@ -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
- var 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
+ var 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,56 +1,56 @@
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
- })(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
+ })(Cartes = exports.Cartes || (exports.Cartes = {}));
56
56
  //# 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
- var center = {
36
- longitude: 0,
37
- latitude: 0,
38
- altitude: 0
39
- };
40
- for (var i = 0; i < list.length; i++) {
41
- var 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
+ var center = {
36
+ longitude: 0,
37
+ latitude: 0,
38
+ altitude: 0
39
+ };
40
+ for (var i = 0; i < list.length; i++) {
41
+ var 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
- var 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
- var brightness = 4;
15
- var rgb = [Math.random() * 256, Math.random() * 256, Math.random() * 256];
16
- var mix = [brightness * 51, brightness * 51, brightness * 51];
17
- var 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
- var 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
- var r, g, b, a;
31
- var 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
- var 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
- var 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
+ var 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
+ var brightness = 4;
15
+ var rgb = [Math.random() * 256, Math.random() * 256, Math.random() * 256];
16
+ var mix = [brightness * 51, brightness * 51, brightness * 51];
17
+ var 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
+ var 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
+ var r, g, b, a;
31
+ var 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
+ var 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
+ var 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