chunk-7XXXCK2A.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import {
  2. l,
  3. o as o2,
  4. r as r2
  5. } from "./chunk-JXW4QTJA.js";
  6. import {
  7. o2 as o
  8. } from "./chunk-XNLG7T2T.js";
  9. import {
  10. s
  11. } from "./chunk-IHXECKQQ.js";
  12. import {
  13. r
  14. } from "./chunk-GZT4BVFP.js";
  15. // node_modules/@arcgis/core/Color.js
  16. function n(t) {
  17. return o(s(t), 0, 255);
  18. }
  19. function o3(t, r3, s2) {
  20. return t = Number(t), isNaN(t) ? s2 : t < r3 ? r3 : t > s2 ? s2 : t;
  21. }
  22. var h = class {
  23. constructor(t) {
  24. this.r = 255, this.g = 255, this.b = 255, this.a = 1, t && this.setColor(t);
  25. }
  26. static blendColors(t, r3, s2, i = new h()) {
  27. return i.r = Math.round(t.r + (r3.r - t.r) * s2), i.g = Math.round(t.g + (r3.g - t.g) * s2), i.b = Math.round(t.b + (r3.b - t.b) * s2), i.a = t.a + (r3.a - t.a) * s2, i._sanitize();
  28. }
  29. static fromRgb(r3, s2) {
  30. const i = r3.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);
  31. if (i) {
  32. const r4 = i[2].split(/\s*,\s*/), e = i[1];
  33. if (e === "rgb" && r4.length === 3 || e === "rgba" && r4.length === 4) {
  34. const t = r4[0];
  35. if (t.charAt(t.length - 1) === "%") {
  36. const t2 = r4.map((t3) => 2.56 * parseFloat(t3));
  37. return r4.length === 4 && (t2[3] = parseFloat(r4[3])), h.fromArray(t2, s2);
  38. }
  39. return h.fromArray(r4.map((t2) => parseFloat(t2)), s2);
  40. }
  41. if (e === "hsl" && r4.length === 3 || e === "hsla" && r4.length === 4)
  42. return h.fromArray(o2(parseFloat(r4[0]), parseFloat(r4[1]) / 100, parseFloat(r4[2]) / 100, parseFloat(r4[3])), s2);
  43. }
  44. return null;
  45. }
  46. static fromHex(t, r3 = new h()) {
  47. if (t.length !== 4 && t.length !== 7 || t[0] !== "#")
  48. return null;
  49. const s2 = t.length === 4 ? 4 : 8, i = (1 << s2) - 1;
  50. let e = Number("0x" + t.substr(1));
  51. return isNaN(e) ? null : (["b", "g", "r"].forEach((t2) => {
  52. const a = e & i;
  53. e >>= s2, r3[t2] = s2 === 4 ? 17 * a : a;
  54. }), r3.a = 1, r3);
  55. }
  56. static fromArray(t, r3 = new h()) {
  57. return r3._set(Number(t[0]), Number(t[1]), Number(t[2]), Number(t[3])), isNaN(r3.a) && (r3.a = 1), r3._sanitize();
  58. }
  59. static fromString(t, i) {
  60. const e = r2(t) ? l(t) : null;
  61. return e && h.fromArray(e, i) || h.fromRgb(t, i) || h.fromHex(t, i);
  62. }
  63. static fromJSON(t) {
  64. return t && new h([t[0], t[1], t[2], t[3] / 255]);
  65. }
  66. static toUnitRGB(t) {
  67. return r(t) ? [t.r / 255, t.g / 255, t.b / 255] : null;
  68. }
  69. static toUnitRGBA(t) {
  70. return r(t) ? [t.r / 255, t.g / 255, t.b / 255, t.a != null ? t.a : 1] : null;
  71. }
  72. get isBright() {
  73. return 0.299 * this.r + 0.587 * this.g + 0.114 * this.b >= 127;
  74. }
  75. setColor(t) {
  76. return typeof t == "string" ? h.fromString(t, this) : Array.isArray(t) ? h.fromArray(t, this) : (this._set(t.r ?? 0, t.g ?? 0, t.b ?? 0, t.a ?? 1), t instanceof h || this._sanitize()), this;
  77. }
  78. toRgb() {
  79. return [this.r, this.g, this.b];
  80. }
  81. toRgba() {
  82. return [this.r, this.g, this.b, this.a];
  83. }
  84. toHex() {
  85. const t = this.r.toString(16), r3 = this.g.toString(16), s2 = this.b.toString(16);
  86. return `#${t.length < 2 ? "0" + t : t}${r3.length < 2 ? "0" + r3 : r3}${s2.length < 2 ? "0" + s2 : s2}`;
  87. }
  88. toCss(t = false) {
  89. const r3 = this.r + ", " + this.g + ", " + this.b;
  90. return t ? `rgba(${r3}, ${this.a})` : `rgb(${r3})`;
  91. }
  92. toString() {
  93. return this.toCss(true);
  94. }
  95. toJSON() {
  96. return this.toArray();
  97. }
  98. toArray(t = h.AlphaMode.ALWAYS) {
  99. const r3 = n(this.r), s2 = n(this.g), i = n(this.b);
  100. return t === h.AlphaMode.ALWAYS || this.a !== 1 ? [r3, s2, i, n(255 * this.a)] : [r3, s2, i];
  101. }
  102. clone() {
  103. return new h(this.toRgba());
  104. }
  105. hash() {
  106. return this.r << 24 | this.g << 16 | this.b << 8 | 255 * this.a;
  107. }
  108. equals(t) {
  109. return r(t) && t.r === this.r && t.g === this.g && t.b === this.b && t.a === this.a;
  110. }
  111. _sanitize() {
  112. return this.r = Math.round(o3(this.r, 0, 255)), this.g = Math.round(o3(this.g, 0, 255)), this.b = Math.round(o3(this.b, 0, 255)), this.a = o3(this.a, 0, 1), this;
  113. }
  114. _set(t, r3, s2, i) {
  115. this.r = t, this.g = r3, this.b = s2, this.a = i;
  116. }
  117. };
  118. h.prototype.declaredClass = "esri.Color", function(t) {
  119. var r3;
  120. (r3 = t.AlphaMode || (t.AlphaMode = {}))[r3.ALWAYS = 0] = "ALWAYS", r3[r3.UNLESS_OPAQUE = 1] = "UNLESS_OPAQUE";
  121. }(h || (h = {}));
  122. var l2 = h;
  123. export {
  124. l2 as l
  125. };
  126. //# sourceMappingURL=chunk-7XXXCK2A.js.map