123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import {
- l,
- o as o2,
- r as r2
- } from "./chunk-JXW4QTJA.js";
- import {
- o2 as o
- } from "./chunk-XNLG7T2T.js";
- import {
- s
- } from "./chunk-IHXECKQQ.js";
- import {
- r
- } from "./chunk-GZT4BVFP.js";
- // node_modules/@arcgis/core/Color.js
- function n(t) {
- return o(s(t), 0, 255);
- }
- function o3(t, r3, s2) {
- return t = Number(t), isNaN(t) ? s2 : t < r3 ? r3 : t > s2 ? s2 : t;
- }
- var h = class {
- constructor(t) {
- this.r = 255, this.g = 255, this.b = 255, this.a = 1, t && this.setColor(t);
- }
- static blendColors(t, r3, s2, i = new h()) {
- 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();
- }
- static fromRgb(r3, s2) {
- const i = r3.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);
- if (i) {
- const r4 = i[2].split(/\s*,\s*/), e = i[1];
- if (e === "rgb" && r4.length === 3 || e === "rgba" && r4.length === 4) {
- const t = r4[0];
- if (t.charAt(t.length - 1) === "%") {
- const t2 = r4.map((t3) => 2.56 * parseFloat(t3));
- return r4.length === 4 && (t2[3] = parseFloat(r4[3])), h.fromArray(t2, s2);
- }
- return h.fromArray(r4.map((t2) => parseFloat(t2)), s2);
- }
- if (e === "hsl" && r4.length === 3 || e === "hsla" && r4.length === 4)
- return h.fromArray(o2(parseFloat(r4[0]), parseFloat(r4[1]) / 100, parseFloat(r4[2]) / 100, parseFloat(r4[3])), s2);
- }
- return null;
- }
- static fromHex(t, r3 = new h()) {
- if (t.length !== 4 && t.length !== 7 || t[0] !== "#")
- return null;
- const s2 = t.length === 4 ? 4 : 8, i = (1 << s2) - 1;
- let e = Number("0x" + t.substr(1));
- return isNaN(e) ? null : (["b", "g", "r"].forEach((t2) => {
- const a = e & i;
- e >>= s2, r3[t2] = s2 === 4 ? 17 * a : a;
- }), r3.a = 1, r3);
- }
- static fromArray(t, r3 = new h()) {
- return r3._set(Number(t[0]), Number(t[1]), Number(t[2]), Number(t[3])), isNaN(r3.a) && (r3.a = 1), r3._sanitize();
- }
- static fromString(t, i) {
- const e = r2(t) ? l(t) : null;
- return e && h.fromArray(e, i) || h.fromRgb(t, i) || h.fromHex(t, i);
- }
- static fromJSON(t) {
- return t && new h([t[0], t[1], t[2], t[3] / 255]);
- }
- static toUnitRGB(t) {
- return r(t) ? [t.r / 255, t.g / 255, t.b / 255] : null;
- }
- static toUnitRGBA(t) {
- return r(t) ? [t.r / 255, t.g / 255, t.b / 255, t.a != null ? t.a : 1] : null;
- }
- get isBright() {
- return 0.299 * this.r + 0.587 * this.g + 0.114 * this.b >= 127;
- }
- setColor(t) {
- 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;
- }
- toRgb() {
- return [this.r, this.g, this.b];
- }
- toRgba() {
- return [this.r, this.g, this.b, this.a];
- }
- toHex() {
- const t = this.r.toString(16), r3 = this.g.toString(16), s2 = this.b.toString(16);
- return `#${t.length < 2 ? "0" + t : t}${r3.length < 2 ? "0" + r3 : r3}${s2.length < 2 ? "0" + s2 : s2}`;
- }
- toCss(t = false) {
- const r3 = this.r + ", " + this.g + ", " + this.b;
- return t ? `rgba(${r3}, ${this.a})` : `rgb(${r3})`;
- }
- toString() {
- return this.toCss(true);
- }
- toJSON() {
- return this.toArray();
- }
- toArray(t = h.AlphaMode.ALWAYS) {
- const r3 = n(this.r), s2 = n(this.g), i = n(this.b);
- return t === h.AlphaMode.ALWAYS || this.a !== 1 ? [r3, s2, i, n(255 * this.a)] : [r3, s2, i];
- }
- clone() {
- return new h(this.toRgba());
- }
- hash() {
- return this.r << 24 | this.g << 16 | this.b << 8 | 255 * this.a;
- }
- equals(t) {
- return r(t) && t.r === this.r && t.g === this.g && t.b === this.b && t.a === this.a;
- }
- _sanitize() {
- 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;
- }
- _set(t, r3, s2, i) {
- this.r = t, this.g = r3, this.b = s2, this.a = i;
- }
- };
- h.prototype.declaredClass = "esri.Color", function(t) {
- var r3;
- (r3 = t.AlphaMode || (t.AlphaMode = {}))[r3.ALWAYS = 0] = "ALWAYS", r3[r3.UNLESS_OPAQUE = 1] = "UNLESS_OPAQUE";
- }(h || (h = {}));
- var l2 = h;
- export {
- l2 as l
- };
- //# sourceMappingURL=chunk-7XXXCK2A.js.map
|