@auaust/jaune 0.0.3 → 0.0.5
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/dist/chunk-Q3GK6DZM.js +2 -0
- package/dist/chunk-Q3GK6DZM.js.map +1 -0
- package/dist/chunk-X6GMJCOG.cjs +2 -0
- package/dist/chunk-X6GMJCOG.cjs.map +1 -0
- package/dist/{index-VyiURM-J.d.cts → index-7Xs589Bo.d.cts} +37 -90
- package/dist/{index-VyiURM-J.d.ts → index-7Xs589Bo.d.ts} +37 -90
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +115 -26
- package/dist/utils.d.ts +115 -26
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +14 -10
- package/src/classes/Color.ts +26 -14
- package/src/data/fallbackColor.ts +10 -0
- package/src/{utils → data}/namedColors.ts +5 -109
- package/src/types/index.ts +2 -0
- package/src/utils/brightness.ts +17 -0
- package/src/utils/closestNamedColor.ts +25 -0
- package/src/utils/contrast.ts +17 -0
- package/src/utils/couldBeRgb.ts +13 -0
- package/src/utils/grayscale.ts +12 -0
- package/src/utils/index.ts +45 -34
- package/src/utils/invert.ts +11 -0
- package/src/utils/isAliasToNamedColor.ts +12 -0
- package/src/utils/isAlphaChannel.ts +5 -0
- package/src/utils/isBright.ts +7 -0
- package/src/utils/isColor.ts +7 -0
- package/src/utils/isColorChannels.ts +13 -0
- package/src/utils/isDark.ts +7 -0
- package/src/utils/isHex.ts +27 -0
- package/src/utils/isNamedColor.ts +12 -0
- package/src/utils/isOpaque.ts +6 -0
- package/src/utils/isRgb.ts +15 -0
- package/src/utils/isRgbChannel.ts +5 -0
- package/src/utils/isTranslucent.ts +7 -0
- package/src/utils/isTransparent.ts +6 -0
- package/src/utils/linearTosRGB.ts +10 -0
- package/src/utils/luminance.ts +1 -77
- package/src/utils/namedColorAliases.ts +33 -0
- package/src/utils/namedColorChannels.ts +13 -0
- package/src/utils/namedColorToHex.ts +11 -0
- package/src/utils/parseColor.ts +44 -0
- package/src/utils/parseHex.ts +23 -0
- package/src/utils/parseNamedColor.ts +13 -0
- package/src/utils/parseRgb.ts +14 -0
- package/src/utils/random.ts +2 -29
- package/src/utils/randomAlphaChannel.ts +15 -0
- package/src/utils/randomRgbChannel.ts +15 -0
- package/src/utils/sRGBtoLinear.ts +12 -0
- package/src/utils/toAlphaChannel.ts +5 -0
- package/src/utils/{channels.ts → toColorChannels.ts} +4 -31
- package/src/utils/toHex.ts +29 -0
- package/src/utils/toRgb.ts +13 -0
- package/src/utils/toRgbChannel.ts +5 -0
- package/src/utils/type.ts +32 -0
- package/src/utils/colors.ts +0 -72
- package/src/utils/hex.ts +0 -75
- package/src/utils/opacity.ts +0 -16
- package/src/utils/rgb.ts +0 -51
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var t=Symbol("Color.channels"),u=Symbol("Color.cache");var i=Object.freeze({r:0,g:0,b:0,a:1,isTransformed:!1,isFallback:!0});var x=Object.freeze({aliceblue:"#f0f8ffff",antiquewhite:"#faebd7ff",aqua:"#00ffffff",aquamarine:"#7fffd4ff",azure:"#f0ffffff",beige:"#f5f5dcff",bisque:"#ffe4c4ff",black:"#000000ff",blanchedalmond:"#ffebcdff",blue:"#0000ffff",blueviolet:"#8a2be2ff",brown:"#a52a2aff",burlywood:"#deb887ff",cadetblue:"#5f9ea0ff",chartreuse:"#7fff00ff",chocolate:"#d2691eff",coral:"#ff7f50ff",cornflowerblue:"#6495edff",cornsilk:"#fff8dcff",crimson:"#dc143cff",cyan:"#00ffffff",darkblue:"#00008bff",darkcyan:"#008b8bff",darkgoldenrod:"#b8860bff",darkgray:"#a9a9a9ff",darkgreen:"#006400ff",darkgrey:"#a9a9a9ff",darkkhaki:"#bdb76bff",darkmagenta:"#8b008bff",darkolivegreen:"#556b2fff",darkorange:"#ff8c00ff",darkorchid:"#9932ccff",darkred:"#8b0000ff",darksalmon:"#e9967aff",darkseagreen:"#8fbc8fff",darkslateblue:"#483d8bff",darkslategray:"#2f4f4fff",darkslategrey:"#2f4f4fff",darkturquoise:"#00ced1ff",darkviolet:"#9400d3ff",deeppink:"#ff1493ff",deepskyblue:"#00bfffff",dimgray:"#696969ff",dimgrey:"#696969ff",dodgerblue:"#1e90ffff",firebrick:"#b22222ff",floralwhite:"#fffaf0ff",forestgreen:"#228b22ff",fuchsia:"#ff00ffff",gainsboro:"#dcdcdcff",ghostwhite:"#f8f8ffff",gold:"#ffd700ff",goldenrod:"#daa520ff",gray:"#808080ff",green:"#008000ff",greenyellow:"#adff2fff",grey:"#808080ff",honeydew:"#f0fff0ff",hotpink:"#ff69b4ff",indianred:"#cd5c5cff",indigo:"#4b0082ff",ivory:"#fffff0ff",khaki:"#f0e68cff",lavender:"#e6e6faff",lavenderblush:"#fff0f5ff",lawngreen:"#7cfc00ff",lemonchiffon:"#fffacdff",lightblue:"#add8e6ff",lightcoral:"#f08080ff",lightcyan:"#e0ffffff",lightgoldenrodyellow:"#fafad2ff",lightgray:"#d3d3d3ff",lightgreen:"#90ee90ff",lightgrey:"#d3d3d3ff",lightpink:"#ffb6c1ff",lightsalmon:"#ffa07aff",lightseagreen:"#20b2aaff",lightskyblue:"#87cefaff",lightslategray:"#778899ff",lightslategrey:"#778899ff",lightsteelblue:"#b0c4deff",lightyellow:"#ffffe0ff",lime:"#00ff00ff",limegreen:"#32cd32ff",linen:"#faf0e6ff",magenta:"#ff00ffff",maroon:"#800000ff",mediumaquamarine:"#66cdaaff",mediumblue:"#0000cdff",mediumorchid:"#ba55d3ff",mediumpurple:"#9370dbff",mediumseagreen:"#3cb371ff",mediumslateblue:"#7b68eeff",mediumspringgreen:"#00fa9aff",mediumturquoise:"#48d1ccff",mediumvioletred:"#c71585ff",midnightblue:"#191970ff",mintcream:"#f5fffaff",mistyrose:"#ffe4e1ff",moccasin:"#ffe4b5ff",navajowhite:"#ffdeadff",navy:"#000080ff",oldlace:"#fdf5e6ff",olive:"#808000ff",olivedrab:"#6b8e23ff",orange:"#ffa500ff",orangered:"#ff4500ff",orchid:"#da70d6ff",palegoldenrod:"#eee8aaff",palegreen:"#98fb98ff",paleturquoise:"#afeeeeff",palevioletred:"#db7093ff",papayawhip:"#ffefd5ff",peachpuff:"#ffdab9ff",peru:"#cd853fff",pink:"#ffc0cbff",plum:"#dda0ddff",powderblue:"#b0e0e6ff",purple:"#800080ff",rebeccapurple:"#663399ff",red:"#ff0000ff",rosybrown:"#bc8f8fff",royalblue:"#4169e1ff",saddlebrown:"#8b4513ff",salmon:"#fa8072ff",sandybrown:"#f4a460ff",seagreen:"#2e8b57ff",seashell:"#fff5eeff",sienna:"#a0522dff",silver:"#c0c0c0ff",skyblue:"#87ceebff",slateblue:"#6a5acdff",slategray:"#708090ff",slategrey:"#708090ff",snow:"#fffafaff",springgreen:"#00ff7fff",steelblue:"#4682b4ff",tan:"#d2b48cff",teal:"#008080ff",thistle:"#d8bfd8ff",tomato:"#ff6347ff",transparent:"#00000000",turquoise:"#40e0d0ff",violet:"#ee82eeff",wheat:"#f5deb3ff",white:"#ffffffff",whitesmoke:"#f5f5f5ff",yellow:"#ffff00ff",yellowgreen:"#9acd32ff"}),R=new Set(Object.keys(x));function d(e){let r=p(e);return r<=216/24389?r*(24389/27)/100:(Math.pow(r,1/3)*116-16)/100}function V(e){let r,o=1/0;for(let n of R){let f=A(n),m=k(f,e,f.a===1);m<o&&(r=n,o=m)}return r}import{minMax as ne}from"@auaust/primitive-kit/numbers";function I(e,r){let[o,n]=ne(p(e),p(r));return(n+.05)/(o+.05)}import{isArray as te}from"@auaust/primitive-kit/arrays";import{isBetween as fe,isNumber as ae}from"@auaust/primitive-kit/numbers";function D(e){return te(e)&&fe(e.length,3,4)&&e.every(ae)}function k(e,r,o=!1){return Math.sqrt(Math.pow(e.r-r.r,2)+Math.pow(e.g-r.g,2)+Math.pow(e.b-r.b,2)+(o?Math.pow((e.a??1)-(r.a??1),2):0))}function P(e){let r=W(p(e))*255;return a(r,r,r,e.a)}import{isObject as se}from"@auaust/primitive-kit/objects";function a(e,r,o,n,f,m){se(e,!1)&&({r:e,g:r,b:o,a:n,isTransformed:f,isFallback:m}=e);let C=s(e),j=s(r),L=s(o);if(isNaN(C)||isNaN(j)||isNaN(L))return i;let re=h(n);return Object.freeze({r:C,g:j,b:L,a:re,isTransformed:!!(f||C!==e||j!==r||L!==o||re!==(n??1)),isFallback:!!m})}function J(e){return a(255-e.r,255-e.g,255-e.b,e.a)}function K(e,r){return T(e).includes(r.toLowerCase())}import{isBetween as ie,isNumber as le}from"@auaust/primitive-kit/numbers";function H(e){return le(e)&&ie(e,0,1)}function $(e,r=.5){return d(e)>r}function F(e){return B(e)!==void 0}import{isObject as me}from"@auaust/primitive-kit/objects";function c(e){return me(e,!1)&&b(e.r)&&b(e.g)&&b(e.b)&&H(e.a??1)}function E(e,r=.5){return d(e)<=r}import{isStrictString as pe,isString as Ce}from"@auaust/primitive-kit/strings";var ue=/^[0-9A-Fa-f]+$/;function g(e){if(e=Ce(e)&&(e.startsWith("#")?e.slice(1):e),!pe(e))return!1;switch(e.length){case 3:case 4:case 6:case 8:return ue.test(e);default:return!1}}import{isString as de}from"@auaust/primitive-kit/strings";function l(e){return de(e)&&R.has(e.toLowerCase())}function M(e){return e.a===1||e.a==null}import{isArray as he}from"@auaust/primitive-kit/arrays";import{isBetween as be}from"@auaust/primitive-kit/numbers";function q(e){return he(e)&&be(e.length,3,4)&&e.every((r,o)=>o===3?H(r):b(r))}import{isBetween as ce,isNumber as ge}from"@auaust/primitive-kit/numbers";function b(e){return ge(e)&&ce(e,0,255)}function Q(e){return!M(e)}function U(e){return e.a===0}function W(e){return e<=.04045/12.92?e*12.92:1.055*Math.pow(e,1/2.4)-.055}function p(e){let{r,g:o,b:n}=e;return[r,o,n]=[r,o,n].map(f=>X(f/255)),r*.2126+o*.7152+n*.0722}import{entries as ye}from"@auaust/primitive-kit/objects";var Y={};function T(e){if(e=e.toLowerCase(),!l(e))return[];if(Y[e])return Y[e];let r=[],o=z(e);for(let[n,f]of ye(x))f===o&&r.push(n);return Y[e]=Object.freeze(r)}var xe={};function A(e){return xe[e]??=y(z(e))}function z(e){return x[e.toLowerCase()]||void 0}import{isNumber as Ne}from"@auaust/primitive-kit/numbers";var w=class e{[t]=void 0;[u]=new Map;constructor(r){this[t]={...a(r)}}static from(r,...o){return Ne(r)?new e({r,g:o[0],b:o[1],a:o[2]}):new e(N(r??i))}static fromChannels(r){return new e(r)}static fromRgb(r){return new e(O(r))}static fromHex(r){return new e(y(r))}static fromName(r){return new e(S(r))}static parse(r){let o=N(r);return o.isFallback?void 0:o}static random(r={}){return new e(Z(r))}static type=B;static isColor=F;static is=F;static isHex=g;static isNamedColor=l;static isColorChannels=c;static isRgb=q;static namedColorAliases=T;static isAliasToNamedColor=K;clone(){return e.fromChannels(this[t])}with(r){return e.fromChannels({...this[t],...r,isFallback:!1,isTransformed:!1})}withRed(r){return this.with({r})}withGreen(r){return this.with({g:r})}withBlue(r){return this.with({b:r})}withAlpha(r){return this.with({a:r})}updated(){return this[u].clear(),this[t].isFallback=!1,this[t].isTransformed=!1,this}set(r,o){return this[t][r]=r==="a"?h(o):s(o),this.updated()}get red(){return this[t].r}get r(){return this[t].r}set red(r){this.setRed(r)}setRed(r){return this.set("r",r)}get green(){return this[t].g}get g(){return this[t].g}set green(r){this.setGreen(r)}setGreen(r){return this.set("g",r)}get blue(){return this[t].b}get b(){return this[t].b}set blue(r){this.setBlue(r)}setBlue(r){return this.set("b",r)}get alpha(){return this[t].a}get a(){return this[t].a}set alpha(r){this.setAlpha(r)}setAlpha(r){return this.set("a",r)}get isFallback(){return this[t].isFallback}get isTransformed(){return this[t].isTransformed}memoize(r,o){let n=o??r;return this[u].has(n)||this[u].set(n,r(this[t])),this[u].get(n)}get isOpaque(){return this.memoize(M)}get isTransparent(){return this.memoize(U)}get isTranslucent(){return this.memoize(Q)}get closestNamedColor(){return this.memoize(V)}get brightness(){return this.memoize(d)}get isBright(){return this.memoize($)}get isDark(){return this.memoize(E)}isBrighterThan(r){return this.brightness>(r instanceof e?r.brightness:r)}isDarkerThan(r){return this.brightness<(r instanceof e?r.brightness:r)}get luminance(){return this.memoize(p)}contrast(r){return I(this[t],N(r))}distance(r,o=!1){return k(this[t],N(r),o)}toGrayscale(){return e.fromChannels(P(this[t]))}toInvert(){return e.fromChannels(J(this[t]))}toHex(){return this.memoize(_)}toRgb(){return this.memoize(v)}toChannels(){return this.memoize(a)}toString(){return this.toHex()}valueOf(){return this.toString()}[Symbol.toPrimitive](){return this.toString()}toJSON(){return this.toString()}};function N(e){return e?e instanceof w?e[t]:c(e)?e:l(e)?S(e):g(e)?y(e):D(e)?O(e):i:i}function y(e){e=e.startsWith("#")?e.slice(1):e;let r=e.length<6,o=r?e.length===4:e.length===8,n=parseInt(r?e[0].repeat(2):e.slice(0,2),16),f=parseInt(r?e[1].repeat(2):e.slice(2,4),16),m=parseInt(r?e[2].repeat(2):e.slice(4,6),16),C=o?parseInt(r?e[3].repeat(2):e.slice(6,8),16)/255:1;return a(n,f,m,C)}function S(e){return l(e)?A(e.toLowerCase()):i}import{isArray as we}from"@auaust/primitive-kit/arrays";function O(e){return we(e)?a(e[0],e[1],e[2],e[3]):i}function Z({r:e,g:r,b:o,a:n}={}){return a(G(e),G(r),G(o),ee(n))}import{isArray as Re}from"@auaust/primitive-kit/arrays";import{isNumber as ke,randomFloat as Ae}from"@auaust/primitive-kit/numbers";function ee(e){return ke(e)?e:Re(e)?Ae(e[0],e[1]):1}import{isArray as Te}from"@auaust/primitive-kit/arrays";import{isNumber as He,randomInteger as oe}from"@auaust/primitive-kit/numbers";function G(e){return He(e)?e:Te(e)?oe(e[0],e[1]):oe(0,255)}function X(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}import{clamp as Be,isNumber as Me}from"@auaust/primitive-kit/numbers";function h(e){return Me(e)?Be(e,0,1):1}import{isNumber as qe,max as ze,round as Se}from"@auaust/primitive-kit/numbers";function _(e){let{r,g:o,b:n,a:f}=e;return"#"+((1<<24)+(s(r)<<16)+(s(o)<<8)+s(n)).toString(16).substring(1)+(qe(f)&&f<1?Se(ze(0,f)*255).toString(16).padStart(2,"0"):"")}function v(e){let{r,g:o,b:n,a:f}=e;return Array.from([r,o,n,f],(m,C)=>C===3?h(m):s(m))}import{clamp as Oe,round as Ge}from"@auaust/primitive-kit/numbers";function s(e){return Oe(Ge(e),0,255)}function B(e){if(e){if(e instanceof w)return"color";if(l(e))return"named";if(g(e))return"hex";if(q(e))return"rgb";if(c(e))return"channels"}}export{t as a,u as b,i as c,x as d,R as e,d as f,V as g,I as h,D as i,k as j,P as k,a as l,J as m,K as n,H as o,$ as p,F as q,c as r,E as s,g as t,l as u,M as v,q as w,b as x,Q as y,U as z,W as A,p as B,T as C,A as D,z as E,N as F,y as G,S as H,O as I,Z as J,ee as K,G as L,X as M,h as N,_ as O,v as P,s as Q,B as R,w as S};
|
|
2
|
+
//# sourceMappingURL=chunk-Q3GK6DZM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/symbols.ts","../src/data/fallbackColor.ts","../src/data/namedColors.ts","../src/utils/brightness.ts","../src/utils/closestNamedColor.ts","../src/utils/contrast.ts","../src/utils/couldBeRgb.ts","../src/utils/distance.ts","../src/utils/grayscale.ts","../src/utils/toColorChannels.ts","../src/utils/invert.ts","../src/utils/isAliasToNamedColor.ts","../src/utils/isAlphaChannel.ts","../src/utils/isBright.ts","../src/utils/isColor.ts","../src/utils/isColorChannels.ts","../src/utils/isDark.ts","../src/utils/isHex.ts","../src/utils/isNamedColor.ts","../src/utils/isOpaque.ts","../src/utils/isRgb.ts","../src/utils/isRgbChannel.ts","../src/utils/isTranslucent.ts","../src/utils/isTransparent.ts","../src/utils/linearTosRGB.ts","../src/utils/luminance.ts","../src/utils/namedColorAliases.ts","../src/utils/namedColorChannels.ts","../src/utils/namedColorToHex.ts","../src/classes/Color.ts","../src/utils/parseColor.ts","../src/utils/parseHex.ts","../src/utils/parseNamedColor.ts","../src/utils/parseRgb.ts","../src/utils/random.ts","../src/utils/randomAlphaChannel.ts","../src/utils/randomRgbChannel.ts","../src/utils/sRGBtoLinear.ts","../src/utils/toAlphaChannel.ts","../src/utils/toHex.ts","../src/utils/toRgb.ts","../src/utils/toRgbChannel.ts","../src/utils/type.ts"],"sourcesContent":["/**\n * Used to privately store the cached channels of a color.\n */\nexport const channels = Symbol(\"Color.channels\");\n\n/**\n * Used to privately store the cached data of a color.\n */\nexport const cache = Symbol(\"Color.cache\");\n","import type { ColorChannels } from \"~/types\";\n\nexport const fallbackColor: Required<ColorChannels> = Object.freeze({\n r: 0,\n g: 0,\n b: 0,\n a: 1,\n isTransformed: false,\n isFallback: true,\n});\n","import type { NamedColor } from \"~/types\";\n\n/**\n * A map of named colors and their HEX values.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/named-color\n */\nexport const namedColorsMap = Object.freeze({\n aliceblue: \"#f0f8ffff\",\n antiquewhite: \"#faebd7ff\",\n aqua: \"#00ffffff\",\n aquamarine: \"#7fffd4ff\",\n azure: \"#f0ffffff\",\n beige: \"#f5f5dcff\",\n bisque: \"#ffe4c4ff\",\n black: \"#000000ff\",\n blanchedalmond: \"#ffebcdff\",\n blue: \"#0000ffff\",\n blueviolet: \"#8a2be2ff\",\n brown: \"#a52a2aff\",\n burlywood: \"#deb887ff\",\n cadetblue: \"#5f9ea0ff\",\n chartreuse: \"#7fff00ff\",\n chocolate: \"#d2691eff\",\n coral: \"#ff7f50ff\",\n cornflowerblue: \"#6495edff\",\n cornsilk: \"#fff8dcff\",\n crimson: \"#dc143cff\",\n cyan: \"#00ffffff\",\n darkblue: \"#00008bff\",\n darkcyan: \"#008b8bff\",\n darkgoldenrod: \"#b8860bff\",\n darkgray: \"#a9a9a9ff\",\n darkgreen: \"#006400ff\",\n darkgrey: \"#a9a9a9ff\",\n darkkhaki: \"#bdb76bff\",\n darkmagenta: \"#8b008bff\",\n darkolivegreen: \"#556b2fff\",\n darkorange: \"#ff8c00ff\",\n darkorchid: \"#9932ccff\",\n darkred: \"#8b0000ff\",\n darksalmon: \"#e9967aff\",\n darkseagreen: \"#8fbc8fff\",\n darkslateblue: \"#483d8bff\",\n darkslategray: \"#2f4f4fff\",\n darkslategrey: \"#2f4f4fff\",\n darkturquoise: \"#00ced1ff\",\n darkviolet: \"#9400d3ff\",\n deeppink: \"#ff1493ff\",\n deepskyblue: \"#00bfffff\",\n dimgray: \"#696969ff\",\n dimgrey: \"#696969ff\",\n dodgerblue: \"#1e90ffff\",\n firebrick: \"#b22222ff\",\n floralwhite: \"#fffaf0ff\",\n forestgreen: \"#228b22ff\",\n fuchsia: \"#ff00ffff\",\n gainsboro: \"#dcdcdcff\",\n ghostwhite: \"#f8f8ffff\",\n gold: \"#ffd700ff\",\n goldenrod: \"#daa520ff\",\n gray: \"#808080ff\",\n green: \"#008000ff\",\n greenyellow: \"#adff2fff\",\n grey: \"#808080ff\",\n honeydew: \"#f0fff0ff\",\n hotpink: \"#ff69b4ff\",\n indianred: \"#cd5c5cff\",\n indigo: \"#4b0082ff\",\n ivory: \"#fffff0ff\",\n khaki: \"#f0e68cff\",\n lavender: \"#e6e6faff\",\n lavenderblush: \"#fff0f5ff\",\n lawngreen: \"#7cfc00ff\",\n lemonchiffon: \"#fffacdff\",\n lightblue: \"#add8e6ff\",\n lightcoral: \"#f08080ff\",\n lightcyan: \"#e0ffffff\",\n lightgoldenrodyellow: \"#fafad2ff\",\n lightgray: \"#d3d3d3ff\",\n lightgreen: \"#90ee90ff\",\n lightgrey: \"#d3d3d3ff\",\n lightpink: \"#ffb6c1ff\",\n lightsalmon: \"#ffa07aff\",\n lightseagreen: \"#20b2aaff\",\n lightskyblue: \"#87cefaff\",\n lightslategray: \"#778899ff\",\n lightslategrey: \"#778899ff\",\n lightsteelblue: \"#b0c4deff\",\n lightyellow: \"#ffffe0ff\",\n lime: \"#00ff00ff\",\n limegreen: \"#32cd32ff\",\n linen: \"#faf0e6ff\",\n magenta: \"#ff00ffff\",\n maroon: \"#800000ff\",\n mediumaquamarine: \"#66cdaaff\",\n mediumblue: \"#0000cdff\",\n mediumorchid: \"#ba55d3ff\",\n mediumpurple: \"#9370dbff\",\n mediumseagreen: \"#3cb371ff\",\n mediumslateblue: \"#7b68eeff\",\n mediumspringgreen: \"#00fa9aff\",\n mediumturquoise: \"#48d1ccff\",\n mediumvioletred: \"#c71585ff\",\n midnightblue: \"#191970ff\",\n mintcream: \"#f5fffaff\",\n mistyrose: \"#ffe4e1ff\",\n moccasin: \"#ffe4b5ff\",\n navajowhite: \"#ffdeadff\",\n navy: \"#000080ff\",\n oldlace: \"#fdf5e6ff\",\n olive: \"#808000ff\",\n olivedrab: \"#6b8e23ff\",\n orange: \"#ffa500ff\",\n orangered: \"#ff4500ff\",\n orchid: \"#da70d6ff\",\n palegoldenrod: \"#eee8aaff\",\n palegreen: \"#98fb98ff\",\n paleturquoise: \"#afeeeeff\",\n palevioletred: \"#db7093ff\",\n papayawhip: \"#ffefd5ff\",\n peachpuff: \"#ffdab9ff\",\n peru: \"#cd853fff\",\n pink: \"#ffc0cbff\",\n plum: \"#dda0ddff\",\n powderblue: \"#b0e0e6ff\",\n purple: \"#800080ff\",\n rebeccapurple: \"#663399ff\",\n red: \"#ff0000ff\",\n rosybrown: \"#bc8f8fff\",\n royalblue: \"#4169e1ff\",\n saddlebrown: \"#8b4513ff\",\n salmon: \"#fa8072ff\",\n sandybrown: \"#f4a460ff\",\n seagreen: \"#2e8b57ff\",\n seashell: \"#fff5eeff\",\n sienna: \"#a0522dff\",\n silver: \"#c0c0c0ff\",\n skyblue: \"#87ceebff\",\n slateblue: \"#6a5acdff\",\n slategray: \"#708090ff\",\n slategrey: \"#708090ff\",\n snow: \"#fffafaff\",\n springgreen: \"#00ff7fff\",\n steelblue: \"#4682b4ff\",\n tan: \"#d2b48cff\",\n teal: \"#008080ff\",\n thistle: \"#d8bfd8ff\",\n tomato: \"#ff6347ff\",\n transparent: \"#00000000\",\n turquoise: \"#40e0d0ff\",\n violet: \"#ee82eeff\",\n wheat: \"#f5deb3ff\",\n white: \"#ffffffff\",\n whitesmoke: \"#f5f5f5ff\",\n yellow: \"#ffff00ff\",\n yellowgreen: \"#9acd32ff\",\n});\n\nexport const namedColors = new Set<NamedColor>(\n Object.keys(namedColorsMap) as NamedColor[]\n);\n","import type { ColorChannels } from \"~/types\";\nimport { luminance } from \"~/utils\";\n\n/**\n * Returns the perceived brightness of a color normalized to the range [0, 1].\n *\n * @see https://stackoverflow.com/a/56678483\n */\nexport function brightness(channels: ColorChannels): number {\n const l = luminance(channels);\n\n if (l <= 216 / 24389) {\n return (l * (24389 / 27)) / 100;\n }\n\n return (Math.pow(l, 1 / 3) * 116 - 16) / 100;\n}\n","import type { ColorChannels, NamedColor } from \"~/types\";\nimport { distance, namedColorChannels, namedColors } from \"~/utils\";\n\n/** Returns the closest named color to the passed color channels. */\nexport function closestNamedColor(channels: ColorChannels): NamedColor {\n let closest: NamedColor | undefined;\n let smallestDistance = Infinity;\n\n for (const name of namedColors) {\n const value = namedColorChannels(name);\n\n const d = distance(\n value,\n channels,\n value.a === 1 // Ignore alpha channel only if it's 1 -> allows to match transparent/black correctly\n );\n\n if (d < smallestDistance) {\n closest = name;\n smallestDistance = d;\n }\n }\n\n return closest!;\n}\n","import { minMax } from \"@auaust/primitive-kit/numbers\";\nimport type { ColorChannels } from \"~/types\";\nimport { luminance } from \"~/utils\";\n\n/**\n * Returns the contrast ratio between two colors.\n *\n * @see https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef\n */\nexport function contrast(channelsA: ColorChannels, channelsB: ColorChannels) {\n const [darkest, brightest] = minMax(\n luminance(channelsA),\n luminance(channelsB)\n );\n\n return (brightest + 0.05) / (darkest + 0.05);\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport { isBetween, isNumber } from \"@auaust/primitive-kit/numbers\";\nimport type { Rgb } from \"~/types\";\n\n/**\n * Whether the input could be a valid RGB color.\n * As in, it checks if the input is an array of numbers without validating the values range.\n */\nexport function couldBeRgb(value: unknown): value is Rgb {\n return (\n isArray(value) && isBetween(value.length, 3, 4) && value.every(isNumber)\n );\n}\n","import type { ColorChannels } from \"~/types\";\n\n/** Calculate the distance between two colors. It is mostly useful for comparing distances between colors, but the value itself is not very meaningful. */\nexport function distance(\n a: ColorChannels,\n b: ColorChannels,\n alpha = false\n): number {\n return Math.sqrt(\n Math.pow(a.r - b.r, 2) +\n Math.pow(a.g - b.g, 2) +\n Math.pow(a.b - b.b, 2) +\n (alpha ? Math.pow((a.a ?? 1) - (b.a ?? 1), 2) : 0)\n );\n}\n","import type { ColorChannels } from \"~/types\";\nimport { linearTosRGB, luminance, toColorChannels } from \"~/utils\";\n\n/**\n * Returns the grayscale equivalent of a color as a new color channels object.\n */\nexport function grayscale(channels: ColorChannels): ColorChannels {\n // Reverse gamma correction from luminance\n const gray = linearTosRGB(luminance(channels)) * 255;\n\n return toColorChannels(gray, gray, gray, channels.a);\n}\n","import { isObject } from \"@auaust/primitive-kit/objects\";\nimport type { ColorChannels } from \"~/types\";\nimport { fallbackColor, toAlphaChannel, toRgbChannel } from \"~/utils\";\n\n/**\n * Formats the input into a readonly object of color channels.\n *\n * It clamps the values to the valid range and sets the alpha channel to 1 if not provided.\n * If the passed `isTransformed` isn't already `true`, it will set it to `true` if any of the values were clamped.\n * If some channels are missing, it will return the fallback color.\n */\nexport function toColorChannels(value: ColorChannels): Required<ColorChannels>;\nexport function toColorChannels(\n r: number,\n g: number,\n b: number,\n a?: number | null,\n isTransformed?: boolean,\n isFallback?: boolean\n): Required<ColorChannels>;\nexport function toColorChannels(\n r: number | ColorChannels,\n g?: number,\n b?: number,\n a?: number | null,\n isTransformed?: boolean,\n isFallback?: boolean\n): Required<ColorChannels> {\n if (isObject(r, false)) {\n ({ r, g, b, a, isTransformed, isFallback } = r);\n }\n\n const finalR = toRgbChannel(r);\n const finalG = toRgbChannel(g);\n const finalB = toRgbChannel(b);\n\n if (isNaN(finalR) || isNaN(finalG) || isNaN(finalB)) {\n return fallbackColor;\n }\n\n const finalA = toAlphaChannel(a);\n\n return Object.freeze({\n r: finalR,\n g: finalG,\n b: finalB,\n a: finalA,\n isTransformed: !!(\n isTransformed ||\n finalR !== r ||\n finalG !== g ||\n finalB !== b ||\n finalA !== (a ?? 1)\n ),\n isFallback: !!isFallback,\n });\n}\n","import type { ColorChannels } from \"~/types\";\nimport { toColorChannels } from \"~/utils/toColorChannels\";\n\nexport function invert(channels: ColorChannels): ColorChannels {\n return toColorChannels(\n 255 - channels.r,\n 255 - channels.g,\n 255 - channels.b,\n channels.a\n );\n}\n","import type { NamedColor } from \"~/types\";\nimport { namedColorAliases } from \"~/utils\";\n\n/**\n * Returns a boolean indicating whether two named colors are aliases.\n */\nexport function isAliasToNamedColor(\n name: NamedColor,\n alias: NamedColor\n): boolean {\n return namedColorAliases(name).includes(<NamedColor>alias.toLowerCase());\n}\n","import { isBetween, isNumber } from \"@auaust/primitive-kit/numbers\";\n\nexport function isAlphaChannel(value: unknown): value is number {\n return isNumber(value) && isBetween(value, 0, 1);\n}\n","import type { ColorChannels } from \"~/types\";\nimport { brightness } from \"~/utils\";\n\n/** Returns whether the color is bright, as in its brightness is greater than 0.5 or the provided threshold. */\nexport function isBright(channels: ColorChannels, threshold = 0.5): boolean {\n return brightness(channels) > threshold;\n}\n","import type { ColorValue } from \"~/types\";\nimport { type } from \"~/utils\";\n\n/** Returns true if the value is any format of supported color. */\nexport function isColor(value: unknown): value is ColorValue {\n return type(value) !== undefined;\n}\n","import { isObject } from \"@auaust/primitive-kit/objects\";\nimport type { ColorChannels } from \"~/types\";\nimport { isAlphaChannel, isRgbChannel } from \"~/utils\";\n\nexport function isColorChannels(value: unknown): value is ColorChannels {\n return (\n isObject(value, false) &&\n isRgbChannel(value.r) &&\n isRgbChannel(value.g) &&\n isRgbChannel(value.b) &&\n isAlphaChannel(value.a ?? 1)\n );\n}\n","import type { ColorChannels } from \"~/types\";\nimport { brightness } from \"~/utils\";\n\n/** Returns whether the color is dark, as in its brightness is less than or equal to 0.5 or the provided threshold. */\nexport function isDark(channels: ColorChannels, threshold = 0.5): boolean {\n return brightness(channels) <= threshold;\n}\n","import { isStrictString, isString } from \"@auaust/primitive-kit/strings\";\nimport type { Hex } from \"~/types\";\n\nconst hexadecimalRegex = /^[0-9A-Fa-f]+$/;\n\n/**\n * Whether the input is a valid HEX color. With or without the alpha channel, and with single or double digits.\n *\n * It may or may not start with a hash character, which will be ignored.\n */\nexport function isHex(value: unknown): value is Hex {\n value = isString(value) && (value.startsWith(\"#\") ? value.slice(1) : value);\n\n if (!isStrictString(value)) {\n return false;\n }\n\n switch (value.length) {\n case 3: // RGB\n case 4: // RGBA\n case 6: // RRGGBB\n case 8: // RRGGBBAA\n return hexadecimalRegex.test(value);\n default:\n return false;\n }\n}\n","import { isString } from \"@auaust/primitive-kit/strings\";\nimport { namedColors } from \"~/data/namedColors\";\nimport type { NamedColor } from \"~/types\";\n\n/**\n * Whether the input is a valid named color.\n *\n * The check is case-insensitive.\n */\nexport function isNamedColor(value: unknown): value is NamedColor {\n return isString(value) && namedColors.has(<NamedColor>value.toLowerCase());\n}\n","import type { ColorChannels } from \"~/types\";\n\n/** Checks if the color is fully opaque. */\nexport function isOpaque(channels: ColorChannels) {\n return channels.a === 1 || channels.a == undefined;\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport { isBetween } from \"@auaust/primitive-kit/numbers\";\nimport type { Rgb } from \"~/types\";\nimport { isAlphaChannel, isRgbChannel } from \"~/utils\";\n\n/**\n * Whether the input is a valid RGB color.\n */\nexport function isRgb(value: unknown): value is Rgb {\n return (\n isArray(value) &&\n isBetween(value.length, 3, 4) &&\n value.every((n, i) => (i === 3 ? isAlphaChannel(n) : isRgbChannel(n)))\n );\n}\n","import { isBetween, isNumber } from \"@auaust/primitive-kit/numbers\";\n\nexport function isRgbChannel(value: unknown): value is number {\n return isNumber(value) && isBetween(value, 0, 255);\n}\n","import type { ColorChannels } from \"~/types\";\nimport { isOpaque } from \"~/utils\";\n\n/** Checks if the color is at least partially transparent. */\nexport function isTranslucent(channels: ColorChannels) {\n return !isOpaque(channels);\n}\n","import type { ColorChannels } from \"~/types\";\n\n/** Checks if the color is fully transparent. */\nexport function isTransparent(channels: ColorChannels) {\n return channels.a === 0;\n}\n","/**\n * Returns the gamma corrected sRGB value of a linear channel.\n */\nexport function linearTosRGB(channel: number) {\n if (channel <= 0.04045 / 12.92) {\n return channel * 12.92;\n }\n\n return 1.055 * Math.pow(channel, 1 / 2.4) - 0.055;\n}\n","import type { ColorChannels } from \"~/types\";\nimport { sRGBtoLinear } from \"~/utils\";\n\n/**\n * Returns the luminance of a color normalized to the range [0, 1].\n *\n * @see https://stackoverflow.com/a/56678483\n * @see https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef\n */\nexport function luminance(channels: ColorChannels) {\n let { r, g, b } = channels;\n\n [r, g, b] = [r, g, b].map((v) => sRGBtoLinear(v / 255));\n\n return r * 0.2126 + g * 0.7152 + b * 0.0722;\n}\n","import { entries } from \"@auaust/primitive-kit/objects\";\nimport type { NamedColor } from \"~/types\";\nimport { isNamedColor, namedColorToHex, namedColorsMap } from \"~/utils\";\n\nconst namedColorsAliasesCache: Partial<\n Record<NamedColor, readonly NamedColor[]>\n> = {};\n\n/**\n * Returns all the aliases of a named color.\n */\nexport function namedColorAliases(name: NamedColor): readonly NamedColor[] {\n name = <NamedColor>name.toLowerCase();\n\n if (!isNamedColor(name)) {\n return [];\n }\n\n if (namedColorsAliasesCache[name]) {\n return namedColorsAliasesCache[name]!;\n }\n\n const aliases: NamedColor[] = [];\n const targetHex = namedColorToHex(name);\n\n for (const [name, hex] of entries(namedColorsMap)) {\n if (hex === targetHex) {\n aliases.push(name);\n }\n }\n\n return (namedColorsAliasesCache[name] = Object.freeze(aliases));\n}\n","import type { ColorChannels, NamedColor } from \"~/types\";\nimport { namedColorToHex, parseHex } from \"~/utils\";\n\nconst namedColorsChannelsCache: Partial<Record<NamedColor, ColorChannels>> = {};\n\n/**\n * Returns the color channels from a named color. Must be a valid named color, already lowercased.\n *\n * @internal\n */\nexport function namedColorChannels(name: NamedColor): ColorChannels {\n return (namedColorsChannelsCache[name] ??= parseHex(namedColorToHex(name)!));\n}\n","import { namedColorsMap } from \"~/data/namedColors\";\nimport type { MaybeNamedColor, NamedColor } from \"~/types\";\n\n/**\n * Returns the corresponding HEX value of a named color.\n */\nexport function namedColorToHex(name: NamedColor): string;\nexport function namedColorToHex(name: MaybeNamedColor): string | undefined;\nexport function namedColorToHex(name: MaybeNamedColor): string | undefined {\n return namedColorsMap[<NamedColor>name.toLowerCase()] || undefined;\n}\n","import { isNumber } from \"@auaust/primitive-kit/numbers\";\nimport type { Writable } from \"type-fest\";\nimport type {\n ColorChannels,\n ColorValue,\n MaybeNamedColor,\n NamedColor,\n Rgb,\n} from \"~/index\";\nimport {\n brightness,\n cache,\n channels,\n closestNamedColor,\n contrast,\n distance,\n fallbackColor,\n grayscale,\n invert,\n isAliasToNamedColor,\n isBright,\n isColor,\n isColorChannels,\n isDark,\n isHex,\n isNamedColor,\n isOpaque,\n isRgb,\n isTranslucent,\n isTransparent,\n luminance,\n namedColorAliases,\n parseColor,\n parseHex,\n parseNamedColor,\n parseRgb,\n random,\n toAlphaChannel,\n toColorChannels,\n toHex,\n toRgb,\n toRgbChannel,\n type,\n} from \"~/utils\";\n\nexport class Color {\n protected [channels]: Required<Writable<ColorChannels>> = undefined!;\n protected [cache]: Map<string | Function, any> = new Map();\n\n constructor(value: ColorChannels) {\n this[channels] = { ...toColorChannels(value) };\n }\n\n static from(value: ColorValue): Color;\n static from(red: number, green: number, blue: number, alpha?: number): Color;\n static from(value: ColorValue | number, ...rest: number[]): Color {\n if (isNumber(value)) {\n return new Color({ r: value, g: rest[0], b: rest[1], a: rest[2] });\n }\n\n return new Color(parseColor(value ?? fallbackColor));\n }\n\n static fromChannels(channels: ColorChannels): Color {\n return new Color(channels);\n }\n\n static fromRgb(rgb: Rgb): Color {\n return new Color(parseRgb(rgb));\n }\n\n static fromHex(hex: string): Color {\n return new Color(parseHex(hex));\n }\n\n static fromName(name: MaybeNamedColor): Color {\n return new Color(parseNamedColor(name));\n }\n\n static parse(value: ColorValue): ColorChannels | undefined {\n const color = parseColor(value);\n\n return color.isFallback ? undefined : color;\n }\n\n static random(presets: Parameters<typeof random>[0] = {}): Color {\n return new Color(random(presets));\n }\n\n /**\n * Returns the color type of the passed value, or `undefined` if it's not a color.\n *\n * It is slightly stricter than the logic used to parse colors.\n * It would return false for an array of channels which values are not within the expected range, where `parseColor` would return a color with the invalid values clamped.\n */\n static type = type;\n\n /** Returns a boolean indicating whether the passed value is a color. */\n static isColor = isColor;\n\n /** @alias Color#isColor */\n static is = isColor;\n\n /** Returns a boolean indicating whether the passed value is a HEX color string. */\n static isHex = isHex;\n\n /** Returns a boolean indicating whether the passed value is a named color. */\n static isNamedColor = isNamedColor;\n\n /** Returns a boolean indicating whether the passed value is a color channel object. */\n static isColorChannels = isColorChannels;\n\n /** Returns a boolean indicating whether the passed value is a RGB color tuple. */\n static isRgb = isRgb;\n\n /** Returns all the aliases of a named color, including the name itself. */\n static namedColorAliases = namedColorAliases;\n\n /** Returns a boolean whether two named colors are aliases, meaning they have the same HEX value. */\n static isAliasToNamedColor = isAliasToNamedColor;\n\n /**\n * Returns a new `Color` instance with the same channels as the current one.\n * If you want the clone to have different channels, use the `with` method.\n */\n clone(): Color {\n return Color.fromChannels(this[channels]);\n }\n\n /** Returns a new `Color` instance with the passed channels overriding the current ones. */\n with(value: Partial<Pick<ColorChannels, \"r\" | \"g\" | \"b\" | \"a\">>): Color {\n return Color.fromChannels({\n ...this[channels],\n ...value,\n isFallback: false,\n isTransformed: false,\n });\n }\n\n /** Returns a new `Color` instance with the specified red channel. */\n withRed(value: number): Color {\n return this.with({ r: value });\n }\n\n /** Returns a new `Color` instance with the specified green channel. */\n withGreen(value: number): Color {\n return this.with({ g: value });\n }\n\n /** Returns a new `Color` instance with the specified blue channel. */\n withBlue(value: number): Color {\n return this.with({ b: value });\n }\n\n /** Returns a new `Color` instance with the specified alpha channel. */\n withAlpha(value: number): Color {\n return this.with({ a: value });\n }\n\n private updated(): this {\n this[cache].clear();\n this[channels].isFallback = false; // once updated, it's no longer a fallback\n this[channels].isTransformed = false;\n return this;\n }\n\n set(channel: \"r\" | \"g\" | \"b\" | \"a\", value: number): this {\n this[channels][channel] =\n channel === \"a\" ? toAlphaChannel(value) : toRgbChannel(value);\n return this.updated();\n }\n\n /** The red channel of the color. */\n get red(): number {\n return this[channels].r;\n }\n\n /** @see Color#red */\n get r(): number {\n return this[channels].r;\n }\n\n set red(value: number) {\n this.setRed(value);\n }\n\n setRed(value: number): this {\n return this.set(\"r\", value);\n }\n\n /** The green channel of the color. */\n get green(): number {\n return this[channels].g;\n }\n\n /** @see Color#green */\n get g(): number {\n return this[channels].g;\n }\n\n set green(value: number) {\n this.setGreen(value);\n }\n\n setGreen(value: number): this {\n return this.set(\"g\", value);\n }\n\n /** The blue channel of the color. */\n get blue(): number {\n return this[channels].b;\n }\n\n /** @see Color#blue */\n get b(): number {\n return this[channels].b;\n }\n\n set blue(value: number) {\n this.setBlue(value);\n }\n\n setBlue(value: number): this {\n return this.set(\"b\", value);\n }\n\n /** The alpha channel of the color. */\n get alpha(): number {\n return this[channels].a;\n }\n\n /** @see Color#alpha */\n get a(): number {\n return this[channels].a;\n }\n\n set alpha(value: number) {\n this.setAlpha(value);\n }\n\n setAlpha(value: number): this {\n return this.set(\"a\", value);\n }\n\n /**\n * Whether the color is the fallback color, which is used when the input is invalid.\n * As soon as a color channel is updated, this will always be `false`.\n */\n get isFallback(): boolean {\n return this[channels].isFallback;\n }\n\n /**\n * Whether any of the channels have been transformed by the color parser.\n * As soon as a color channel is updated, this will always be `false`.\n */\n get isTransformed(): boolean {\n return this[channels].isTransformed;\n }\n\n /** Helper to cache data until the channels are updated. */\n private memoize<T>(getter: (channels: ColorChannels) => T, key?: string): T {\n // If no key is passed, we use the getter function as the key\n // This means no key is required when the getter is a named function, while allowing to use anonymous functions within getters as well by passing a key\n const cacheKey = key ?? getter;\n\n if (!this[cache].has(cacheKey)) {\n this[cache].set(cacheKey, getter(this[channels]));\n }\n\n return this[cache].get(cacheKey);\n }\n\n /** Checks if the color is fully opaque. */\n get isOpaque(): boolean {\n return this.memoize(isOpaque);\n }\n\n /** Checks if the color is fully transparent. */\n get isTransparent(): boolean {\n return this.memoize(isTransparent);\n }\n\n /** Checks if the color is at least partially transparent. */\n get isTranslucent(): boolean {\n return this.memoize(isTranslucent);\n }\n\n /**\n * Returns the closest named color. If aliases exist, which one is returned is not guaranteed.\n * In some cases, calling `namedColorAliases()` on the result might help achieve the desired result.\n */\n get closestNamedColor(): NamedColor {\n return this.memoize(closestNamedColor);\n }\n\n /** The relative brightness of the color. */\n get brightness(): number {\n return this.memoize(brightness);\n }\n\n /** Whether the color is considered bright. */\n get isBright(): boolean {\n return this.memoize(isBright);\n }\n\n /** Whether the color is considered dark. */\n get isDark(): boolean {\n return this.memoize(isDark);\n }\n\n /** Whether the color is brighter than the passed threshold or color. */\n isBrighterThan(threshold: Color | number): boolean {\n return (\n this.brightness >\n (threshold instanceof Color ? threshold.brightness : threshold)\n );\n }\n\n /** Whether the color is darker than the passed threshold or color. */\n isDarkerThan(threshold: Color | number): boolean {\n return (\n this.brightness <\n (threshold instanceof Color ? threshold.brightness : threshold)\n );\n }\n\n /** Returns the relative luminance of the color. */\n get luminance(): number {\n return this.memoize(luminance);\n }\n\n /** Returns the contrast ratio between this color and another. */\n contrast(color: ColorValue): number {\n return contrast(this[channels], parseColor(color));\n }\n\n /** Returns the distance between this color and another. If `alpha` is `true`, the alpha channel is included in the calculation. */\n distance(color: ColorValue, alpha = false): number {\n return distance(this[channels], parseColor(color), alpha);\n }\n\n /** Returns a new color with the grayscale equivalent of the current color, preserving the alpha channel. */\n toGrayscale(): Color {\n return Color.fromChannels(grayscale(this[channels]));\n }\n\n toInvert(): Color {\n return Color.fromChannels(invert(this[channels]));\n }\n\n toHex(): string {\n return this.memoize(toHex);\n }\n\n toRgb(): Rgb {\n return this.memoize(toRgb);\n }\n\n toChannels(): ColorChannels {\n return this.memoize(toColorChannels); // can't return `this[channels]` directly as it's writable, and could cause unexpected behavior\n }\n\n toString(): string {\n return this.toHex();\n }\n\n valueOf(): string {\n return this.toString();\n }\n\n [Symbol.toPrimitive](): string {\n return this.toString();\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n","import { Color } from \"~/classes/Color\";\nimport type { ColorChannels } from \"~/types\";\nimport {\n channels,\n couldBeRgb,\n fallbackColor,\n isColorChannels,\n isHex,\n isNamedColor,\n parseHex,\n parseNamedColor,\n parseRgb,\n} from \"~/utils\";\n\n/** Tries to parse the value as a color. If it fails, returns the fallback color. */\nexport function parseColor(value: unknown): ColorChannels {\n if (!value) {\n return fallbackColor;\n }\n\n if (value instanceof Color) {\n return value[channels];\n }\n\n if (isColorChannels(value)) {\n return value;\n }\n\n if (isNamedColor(value)) {\n return parseNamedColor(value);\n }\n\n if (isHex(value)) {\n return parseHex(value);\n }\n\n if (couldBeRgb(value)) {\n // It might not be a valid RGB, in which case `parseRgb` is responsible for returning the fallback color\n // In case more color types are added, it might be required to only return the result of `parseRgb` if `isFallback` is false\n return parseRgb(value);\n }\n\n return fallbackColor;\n}\n","import type { ColorChannels, Hex } from \"~/types\";\nimport { toColorChannels } from \"~/utils\";\n\n/**\n * Parses a hex string into an object of color channels.\n *\n * The input must already be a valid HEX color, otherwise the result will be unexpected.\n */\nexport function parseHex(value: Hex): ColorChannels {\n value = value.startsWith(\"#\") ? value.slice(1) : value;\n\n const isShort = value.length < 6;\n const hasAlpha = isShort ? value.length === 4 : value.length === 8;\n\n const r = parseInt(isShort ? value[0].repeat(2) : value.slice(0, 2), 16);\n const g = parseInt(isShort ? value[1].repeat(2) : value.slice(2, 4), 16);\n const b = parseInt(isShort ? value[2].repeat(2) : value.slice(4, 6), 16);\n const a = hasAlpha\n ? parseInt(isShort ? value[3].repeat(2) : value.slice(6, 8), 16) / 255\n : 1;\n\n return toColorChannels(r, g, b, a);\n}\n","import type { ColorChannels, MaybeNamedColor, NamedColor } from \"~/types\";\nimport { fallbackColor, isNamedColor, namedColorChannels } from \"~/utils\";\n\n/**\n * Returns the color channels from a named color.\n */\nexport function parseNamedColor(name: MaybeNamedColor): ColorChannels {\n if (!isNamedColor(name)) {\n return fallbackColor;\n }\n\n return namedColorChannels(<NamedColor>name.toLowerCase());\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport type { ColorChannels, Rgb } from \"~/types\";\nimport { fallbackColor, toColorChannels } from \"~/utils\";\n\n/**\n * Parses a RGB tuple into an object of color channels.\n *\n * The input must already be a valid RGB tuple, otherwise the result will be unexpected.\n */\nexport function parseRgb(value: Rgb): ColorChannels {\n return isArray(value)\n ? toColorChannels(value[0], value[1], value[2], value[3]) // Don't spread to avoid mistakenly forwarding `isTransformed` and `isFallback`\n : fallbackColor;\n}\n","import type { ChannelRange, ColorChannels } from \"~/types\";\nimport { randomAlphaChannel, randomRgbChannel, toColorChannels } from \"~/utils\";\n\n/**\n * Generates a random color.\n *\n * Specific values or ranges can be provided for each channel.\n * If a range is provided, the value will be randomly selected from within that range.\n * If a single value is provided, that value will be used for the channel.\n * If no value is provided, the channel will be randomly selected from 0 to 255 for RGB channels and be set to 1 for the alpha channel.\n */\nexport function random({\n r,\n g,\n b,\n a,\n}: {\n r?: ChannelRange;\n g?: ChannelRange;\n b?: ChannelRange;\n a?: ChannelRange;\n} = {}): ColorChannels {\n return toColorChannels(\n randomRgbChannel(r),\n randomRgbChannel(g),\n randomRgbChannel(b),\n randomAlphaChannel(a)\n );\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport { isNumber, randomFloat } from \"@auaust/primitive-kit/numbers\";\nimport type { ChannelRange } from \"~/types\";\n\nexport function randomAlphaChannel(range?: ChannelRange | undefined): number {\n if (isNumber(range)) {\n return range;\n }\n\n if (isArray(range)) {\n return randomFloat(range[0], range[1]);\n }\n\n return 1;\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport { isNumber, randomInteger } from \"@auaust/primitive-kit/numbers\";\nimport type { ChannelRange } from \"~/types\";\n\nexport function randomRgbChannel(range?: ChannelRange | undefined): number {\n if (isNumber(range)) {\n return range;\n }\n\n if (isArray(range)) {\n return randomInteger(range[0], range[1]);\n }\n\n return randomInteger(0, 255);\n}\n","/**\n * Returns the linearized value of a sRGB channel.\n *\n * @see https://stackoverflow.com/a/56678483\n */\nexport function sRGBtoLinear(channel: number) {\n if (channel <= 0.04045) {\n return channel / 12.92;\n }\n\n return Math.pow((channel + 0.055) / 1.055, 2.4);\n}\n","import { clamp, isNumber } from \"@auaust/primitive-kit/numbers\";\n\nexport function toAlphaChannel(value: number | undefined | null): number {\n return isNumber(value) ? clamp(value, 0, 1) : 1;\n}\n","import { isNumber, max, round } from \"@auaust/primitive-kit/numbers\";\nimport type { ColorChannels, Hex } from \"~/types\";\nimport { toRgbChannel } from \"~/utils\";\n\n/**\n * Returns the corresponding hex string of a color channels object.\n *\n * If the alpha channel is 1, it will be omitted.\n */\nexport function toHex(channels: ColorChannels): Hex {\n const { r, g, b, a } = channels;\n\n return (\n \"#\" +\n (\n (1 << 24) +\n (toRgbChannel(r) << 16) +\n (toRgbChannel(g) << 8) +\n toRgbChannel(b)\n )\n .toString(16)\n .substring(1) +\n (isNumber(a) && a < 1\n ? round(max(0, a) * 255)\n .toString(16)\n .padStart(2, \"0\")\n : \"\")\n );\n}\n","import type { ColorChannels, Rgb } from \"~/types\";\nimport { toAlphaChannel, toRgbChannel } from \"~/utils\";\n\n/**\n * Returns the corresponding RGB tuple of a color channels object.\n */\nexport function toRgb(channels: ColorChannels): Rgb {\n const { r, g, b, a } = channels;\n\n return Array.from([r, g, b, a], (value, i) =>\n i === 3 ? toAlphaChannel(value) : toRgbChannel(value)\n );\n}\n","import { clamp, round } from \"@auaust/primitive-kit/numbers\";\n\nexport function toRgbChannel(value: number | undefined | null): number {\n return clamp(round(value), 0, 255);\n}\n","import { Color } from \"~/classes/Color\";\nimport type { ColorType } from \"~/types\";\nimport { isColorChannels, isHex, isNamedColor, isRgb } from \"~/utils\";\n\n/** Returns the color type of the value, or undefined if it's not a color. */\nexport function type(value: unknown): ColorType | undefined {\n if (!value) {\n return undefined;\n }\n\n if (value instanceof Color) {\n return \"color\";\n }\n\n if (isNamedColor(value)) {\n return \"named\";\n }\n\n if (isHex(value)) {\n return \"hex\";\n }\n\n if (isRgb(value)) {\n return \"rgb\";\n }\n\n if (isColorChannels(value)) {\n return \"channels\";\n }\n\n return undefined;\n}\n"],"mappings":"AAGO,IAAMA,EAAW,OAAO,gBAAgB,EAKlCC,EAAQ,OAAO,aAAa,ECNlC,IAAMC,EAAyC,OAAO,OAAO,CAClE,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,cAAe,GACf,WAAY,EACd,CAAC,ECFM,IAAMC,EAAiB,OAAO,OAAO,CAC1C,UAAW,YACX,aAAc,YACd,KAAM,YACN,WAAY,YACZ,MAAO,YACP,MAAO,YACP,OAAQ,YACR,MAAO,YACP,eAAgB,YAChB,KAAM,YACN,WAAY,YACZ,MAAO,YACP,UAAW,YACX,UAAW,YACX,WAAY,YACZ,UAAW,YACX,MAAO,YACP,eAAgB,YAChB,SAAU,YACV,QAAS,YACT,KAAM,YACN,SAAU,YACV,SAAU,YACV,cAAe,YACf,SAAU,YACV,UAAW,YACX,SAAU,YACV,UAAW,YACX,YAAa,YACb,eAAgB,YAChB,WAAY,YACZ,WAAY,YACZ,QAAS,YACT,WAAY,YACZ,aAAc,YACd,cAAe,YACf,cAAe,YACf,cAAe,YACf,cAAe,YACf,WAAY,YACZ,SAAU,YACV,YAAa,YACb,QAAS,Y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EACvB,MAAO,WAIX","names":["channels","cache","fallbackColor","namedColorsMap","namedColors","brightness","channels","l","luminance","closestNamedColor","channels","closest","smallestDistance","name","namedColors","value","namedColorChannels","d","distance","minMax","contrast","channelsA","channelsB","darkest","brightest","minMax","luminance","isArray","isBetween","isNumber","couldBeRgb","value","distance","a","b","alpha","grayscale","channels","gray","linearTosRGB","luminance","toColorChannels","isObject","toColorChannels","r","g","b","a","isTransformed","isFallback","isObject","finalR","toRgbChannel","finalG","finalB","fallbackColor","finalA","toAlphaChannel","invert","channels","toColorChannels","isAliasToNamedColor","name","alias","namedColorAliases","isBetween","isNumber","isAlphaChannel","value","isBright","channels","threshold","brightness","isColor","value","type","isObject","isColorChannels","value","isObject","isRgbChannel","isAlphaChannel","isDark","channels","threshold","brightness","isStrictString","isString","hexadecimalRegex","isHex","value","isString","isNamedColor","value","isString","namedColors","isOpaque","channels","isArray","isBetween","isRgb","value","isArray","isBetween","n","i","isAlphaChannel","isRgbChannel","isBetween","isNumber","isRgbChannel","value","isTranslucent","channels","isOpaque","isTransparent","channels","linearTosRGB","channel","luminance","channels","g","b","v","sRGBtoLinear","entries","namedColorsAliasesCache","namedColorAliases","name","isNamedColor","aliases","targetHex","namedColorToHex","hex","entries","namedColorsMap","namedColorsChannelsCache","namedColorChannels","name","parseHex","namedColorToHex","namedColorToHex","name","namedColorsMap","isNumber","Color","_Color","channels","cache","value","toColorChannels","rest","isNumber","parseColor","fallbackColor","rgb","parseRgb","hex","parseHex","name","parseNamedColor","color","presets","random","type","isColor","isHex","isNamedColor","isColorChannels","isRgb","namedColorAliases","isAliasToNamedColor","channel","toAlphaChannel","toRgbChannel","getter","key","cacheKey","isOpaque","isTransparent","isTranslucent","closestNamedColor","brightness","isBright","isDark","threshold","luminance","contrast","alpha","distance","grayscale","invert","toHex","toRgb","parseColor","value","Color","channels","isColorChannels","isNamedColor","parseNamedColor","isHex","parseHex","couldBeRgb","parseRgb","fallbackColor","parseHex","value","isShort","hasAlpha","r","g","b","a","toColorChannels","parseNamedColor","name","isNamedColor","namedColorChannels","fallbackColor","isArray","parseRgb","value","isArray","toColorChannels","fallbackColor","random","r","g","b","a","toColorChannels","randomRgbChannel","randomAlphaChannel","isArray","isNumber","randomFloat","randomAlphaChannel","range","isArray","isNumber","randomInteger","randomRgbChannel","range","sRGBtoLinear","channel","clamp","isNumber","toAlphaChannel","value","isNumber","max","round","toHex","channels","g","b","a","toRgbChannel","isNumber","round","max","toRgb","channels","g","b","a","value","i","toAlphaChannel","toRgbChannel","clamp","round","toRgbChannel","value","type","value","Color","isNamedColor","isHex","isRgb","isColorChannels"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;var t=Symbol("Color.channels"),u= exports.b =Symbol("Color.cache");var i=Object.freeze({r:0,g:0,b:0,a:1,isTransformed:!1,isFallback:!0});var x=Object.freeze({aliceblue:"#f0f8ffff",antiquewhite:"#faebd7ff",aqua:"#00ffffff",aquamarine:"#7fffd4ff",azure:"#f0ffffff",beige:"#f5f5dcff",bisque:"#ffe4c4ff",black:"#000000ff",blanchedalmond:"#ffebcdff",blue:"#0000ffff",blueviolet:"#8a2be2ff",brown:"#a52a2aff",burlywood:"#deb887ff",cadetblue:"#5f9ea0ff",chartreuse:"#7fff00ff",chocolate:"#d2691eff",coral:"#ff7f50ff",cornflowerblue:"#6495edff",cornsilk:"#fff8dcff",crimson:"#dc143cff",cyan:"#00ffffff",darkblue:"#00008bff",darkcyan:"#008b8bff",darkgoldenrod:"#b8860bff",darkgray:"#a9a9a9ff",darkgreen:"#006400ff",darkgrey:"#a9a9a9ff",darkkhaki:"#bdb76bff",darkmagenta:"#8b008bff",darkolivegreen:"#556b2fff",darkorange:"#ff8c00ff",darkorchid:"#9932ccff",darkred:"#8b0000ff",darksalmon:"#e9967aff",darkseagreen:"#8fbc8fff",darkslateblue:"#483d8bff",darkslategray:"#2f4f4fff",darkslategrey:"#2f4f4fff",darkturquoise:"#00ced1ff",darkviolet:"#9400d3ff",deeppink:"#ff1493ff",deepskyblue:"#00bfffff",dimgray:"#696969ff",dimgrey:"#696969ff",dodgerblue:"#1e90ffff",firebrick:"#b22222ff",floralwhite:"#fffaf0ff",forestgreen:"#228b22ff",fuchsia:"#ff00ffff",gainsboro:"#dcdcdcff",ghostwhite:"#f8f8ffff",gold:"#ffd700ff",goldenrod:"#daa520ff",gray:"#808080ff",green:"#008000ff",greenyellow:"#adff2fff",grey:"#808080ff",honeydew:"#f0fff0ff",hotpink:"#ff69b4ff",indianred:"#cd5c5cff",indigo:"#4b0082ff",ivory:"#fffff0ff",khaki:"#f0e68cff",lavender:"#e6e6faff",lavenderblush:"#fff0f5ff",lawngreen:"#7cfc00ff",lemonchiffon:"#fffacdff",lightblue:"#add8e6ff",lightcoral:"#f08080ff",lightcyan:"#e0ffffff",lightgoldenrodyellow:"#fafad2ff",lightgray:"#d3d3d3ff",lightgreen:"#90ee90ff",lightgrey:"#d3d3d3ff",lightpink:"#ffb6c1ff",lightsalmon:"#ffa07aff",lightseagreen:"#20b2aaff",lightskyblue:"#87cefaff",lightslategray:"#778899ff",lightslategrey:"#778899ff",lightsteelblue:"#b0c4deff",lightyellow:"#ffffe0ff",lime:"#00ff00ff",limegreen:"#32cd32ff",linen:"#faf0e6ff",magenta:"#ff00ffff",maroon:"#800000ff",mediumaquamarine:"#66cdaaff",mediumblue:"#0000cdff",mediumorchid:"#ba55d3ff",mediumpurple:"#9370dbff",mediumseagreen:"#3cb371ff",mediumslateblue:"#7b68eeff",mediumspringgreen:"#00fa9aff",mediumturquoise:"#48d1ccff",mediumvioletred:"#c71585ff",midnightblue:"#191970ff",mintcream:"#f5fffaff",mistyrose:"#ffe4e1ff",moccasin:"#ffe4b5ff",navajowhite:"#ffdeadff",navy:"#000080ff",oldlace:"#fdf5e6ff",olive:"#808000ff",olivedrab:"#6b8e23ff",orange:"#ffa500ff",orangered:"#ff4500ff",orchid:"#da70d6ff",palegoldenrod:"#eee8aaff",palegreen:"#98fb98ff",paleturquoise:"#afeeeeff",palevioletred:"#db7093ff",papayawhip:"#ffefd5ff",peachpuff:"#ffdab9ff",peru:"#cd853fff",pink:"#ffc0cbff",plum:"#dda0ddff",powderblue:"#b0e0e6ff",purple:"#800080ff",rebeccapurple:"#663399ff",red:"#ff0000ff",rosybrown:"#bc8f8fff",royalblue:"#4169e1ff",saddlebrown:"#8b4513ff",salmon:"#fa8072ff",sandybrown:"#f4a460ff",seagreen:"#2e8b57ff",seashell:"#fff5eeff",sienna:"#a0522dff",silver:"#c0c0c0ff",skyblue:"#87ceebff",slateblue:"#6a5acdff",slategray:"#708090ff",slategrey:"#708090ff",snow:"#fffafaff",springgreen:"#00ff7fff",steelblue:"#4682b4ff",tan:"#d2b48cff",teal:"#008080ff",thistle:"#d8bfd8ff",tomato:"#ff6347ff",transparent:"#00000000",turquoise:"#40e0d0ff",violet:"#ee82eeff",wheat:"#f5deb3ff",white:"#ffffffff",whitesmoke:"#f5f5f5ff",yellow:"#ffff00ff",yellowgreen:"#9acd32ff"}),R= exports.e =new Set(Object.keys(x));function d(e){let r=p(e);return r<=216/24389?r*(24389/27)/100:(Math.pow(r,1/3)*116-16)/100}function V(e){let r,o=1/0;for(let n of R){let f=A(n),m=k(f,e,f.a===1);m<o&&(r=n,o=m)}return r}var _numbers = require('@auaust/primitive-kit/numbers');function I(e,r){let[o,n]=_numbers.minMax.call(void 0, p(e),p(r));return(n+.05)/(o+.05)}var _arrays = require('@auaust/primitive-kit/arrays');function D(e){return _arrays.isArray.call(void 0, e)&&_numbers.isBetween.call(void 0, e.length,3,4)&&e.every(_numbers.isNumber)}function k(e,r,o=!1){return Math.sqrt(Math.pow(e.r-r.r,2)+Math.pow(e.g-r.g,2)+Math.pow(e.b-r.b,2)+(o?Math.pow((_nullishCoalesce(e.a, () => (1)))-(_nullishCoalesce(r.a, () => (1))),2):0))}function P(e){let r=W(p(e))*255;return a(r,r,r,e.a)}var _objects = require('@auaust/primitive-kit/objects');function a(e,r,o,n,f,m){_objects.isObject.call(void 0, e,!1)&&({r:e,g:r,b:o,a:n,isTransformed:f,isFallback:m}=e);let C=s(e),j=s(r),L=s(o);if(isNaN(C)||isNaN(j)||isNaN(L))return i;let re=h(n);return Object.freeze({r:C,g:j,b:L,a:re,isTransformed:!!(f||C!==e||j!==r||L!==o||re!==(_nullishCoalesce(n, () => (1)))),isFallback:!!m})}function J(e){return a(255-e.r,255-e.g,255-e.b,e.a)}function K(e,r){return T(e).includes(r.toLowerCase())}function H(e){return _numbers.isNumber.call(void 0, e)&&_numbers.isBetween.call(void 0, e,0,1)}function $(e,r=.5){return d(e)>r}function F(e){return B(e)!==void 0}function c(e){return _objects.isObject.call(void 0, e,!1)&&b(e.r)&&b(e.g)&&b(e.b)&&H(_nullishCoalesce(e.a, () => (1)))}function E(e,r=.5){return d(e)<=r}var _strings = require('@auaust/primitive-kit/strings');var ue=/^[0-9A-Fa-f]+$/;function g(e){if(e=_strings.isString.call(void 0, e)&&(e.startsWith("#")?e.slice(1):e),!_strings.isStrictString.call(void 0, e))return!1;switch(e.length){case 3:case 4:case 6:case 8:return ue.test(e);default:return!1}}function l(e){return _strings.isString.call(void 0, e)&&R.has(e.toLowerCase())}function M(e){return e.a===1||e.a==null}function q(e){return _arrays.isArray.call(void 0, e)&&_numbers.isBetween.call(void 0, e.length,3,4)&&e.every((r,o)=>o===3?H(r):b(r))}function b(e){return _numbers.isNumber.call(void 0, e)&&_numbers.isBetween.call(void 0, e,0,255)}function Q(e){return!M(e)}function U(e){return e.a===0}function W(e){return e<=.04045/12.92?e*12.92:1.055*Math.pow(e,1/2.4)-.055}function p(e){let{r,g:o,b:n}=e;return[r,o,n]=[r,o,n].map(f=>X(f/255)),r*.2126+o*.7152+n*.0722}var Y={};function T(e){if(e=e.toLowerCase(),!l(e))return[];if(Y[e])return Y[e];let r=[],o=z(e);for(let[n,f]of _objects.entries.call(void 0, x))f===o&&r.push(n);return Y[e]=Object.freeze(r)}var xe={};function A(e){return xe[e]??=y(z(e))}function z(e){return x[e.toLowerCase()]||void 0}var w= (_class =class e{__init() {this[t]=void 0}__init2() {this[u]=new Map}constructor(r){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);this[t]={...a(r)}}static from(r,...o){return _numbers.isNumber.call(void 0, r)?new e({r,g:o[0],b:o[1],a:o[2]}):new e(N(_nullishCoalesce(r, () => (i))))}static fromChannels(r){return new e(r)}static fromRgb(r){return new e(O(r))}static fromHex(r){return new e(y(r))}static fromName(r){return new e(S(r))}static parse(r){let o=N(r);return o.isFallback?void 0:o}static random(r={}){return new e(Z(r))}static __initStatic() {this.type=B}static __initStatic2() {this.isColor=F}static __initStatic3() {this.is=F}static __initStatic4() {this.isHex=g}static __initStatic5() {this.isNamedColor=l}static __initStatic6() {this.isColorChannels=c}static __initStatic7() {this.isRgb=q}static __initStatic8() {this.namedColorAliases=T}static __initStatic9() {this.isAliasToNamedColor=K}clone(){return e.fromChannels(this[t])}with(r){return e.fromChannels({...this[t],...r,isFallback:!1,isTransformed:!1})}withRed(r){return this.with({r})}withGreen(r){return this.with({g:r})}withBlue(r){return this.with({b:r})}withAlpha(r){return this.with({a:r})}updated(){return this[u].clear(),this[t].isFallback=!1,this[t].isTransformed=!1,this}set(r,o){return this[t][r]=r==="a"?h(o):s(o),this.updated()}get red(){return this[t].r}get r(){return this[t].r}set red(r){this.setRed(r)}setRed(r){return this.set("r",r)}get green(){return this[t].g}get g(){return this[t].g}set green(r){this.setGreen(r)}setGreen(r){return this.set("g",r)}get blue(){return this[t].b}get b(){return this[t].b}set blue(r){this.setBlue(r)}setBlue(r){return this.set("b",r)}get alpha(){return this[t].a}get a(){return this[t].a}set alpha(r){this.setAlpha(r)}setAlpha(r){return this.set("a",r)}get isFallback(){return this[t].isFallback}get isTransformed(){return this[t].isTransformed}memoize(r,o){let n=_nullishCoalesce(o, () => (r));return this[u].has(n)||this[u].set(n,r(this[t])),this[u].get(n)}get isOpaque(){return this.memoize(M)}get isTransparent(){return this.memoize(U)}get isTranslucent(){return this.memoize(Q)}get closestNamedColor(){return this.memoize(V)}get brightness(){return this.memoize(d)}get isBright(){return this.memoize($)}get isDark(){return this.memoize(E)}isBrighterThan(r){return this.brightness>(r instanceof e?r.brightness:r)}isDarkerThan(r){return this.brightness<(r instanceof e?r.brightness:r)}get luminance(){return this.memoize(p)}contrast(r){return I(this[t],N(r))}distance(r,o=!1){return k(this[t],N(r),o)}toGrayscale(){return e.fromChannels(P(this[t]))}toInvert(){return e.fromChannels(J(this[t]))}toHex(){return this.memoize(_)}toRgb(){return this.memoize(v)}toChannels(){return this.memoize(a)}toString(){return this.toHex()}valueOf(){return this.toString()}[Symbol.toPrimitive](){return this.toString()}toJSON(){return this.toString()}}, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class.__initStatic4(), _class.__initStatic5(), _class.__initStatic6(), _class.__initStatic7(), _class.__initStatic8(), _class.__initStatic9(), _class);function N(e){return e?e instanceof w?e[t]:c(e)?e:l(e)?S(e):g(e)?y(e):D(e)?O(e):i:i}function y(e){e=e.startsWith("#")?e.slice(1):e;let r=e.length<6,o=r?e.length===4:e.length===8,n=parseInt(r?e[0].repeat(2):e.slice(0,2),16),f=parseInt(r?e[1].repeat(2):e.slice(2,4),16),m=parseInt(r?e[2].repeat(2):e.slice(4,6),16),C=o?parseInt(r?e[3].repeat(2):e.slice(6,8),16)/255:1;return a(n,f,m,C)}function S(e){return l(e)?A(e.toLowerCase()):i}function O(e){return _arrays.isArray.call(void 0, e)?a(e[0],e[1],e[2],e[3]):i}function Z({r:e,g:r,b:o,a:n}={}){return a(G(e),G(r),G(o),ee(n))}function ee(e){return _numbers.isNumber.call(void 0, e)?e:_arrays.isArray.call(void 0, e)?_numbers.randomFloat.call(void 0, e[0],e[1]):1}function G(e){return _numbers.isNumber.call(void 0, e)?e:_arrays.isArray.call(void 0, e)?_numbers.randomInteger.call(void 0, e[0],e[1]):_numbers.randomInteger.call(void 0, 0,255)}function X(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function h(e){return _numbers.isNumber.call(void 0, e)?_numbers.clamp.call(void 0, e,0,1):1}function _(e){let{r,g:o,b:n,a:f}=e;return"#"+((1<<24)+(s(r)<<16)+(s(o)<<8)+s(n)).toString(16).substring(1)+(_numbers.isNumber.call(void 0, f)&&f<1?_numbers.round.call(void 0, _numbers.max.call(void 0, 0,f)*255).toString(16).padStart(2,"0"):"")}function v(e){let{r,g:o,b:n,a:f}=e;return Array.from([r,o,n,f],(m,C)=>C===3?h(m):s(m))}function s(e){return _numbers.clamp.call(void 0, _numbers.round.call(void 0, e),0,255)}function B(e){if(e){if(e instanceof w)return"color";if(l(e))return"named";if(g(e))return"hex";if(q(e))return"rgb";if(c(e))return"channels"}}exports.a = t; exports.b = u; exports.c = i; exports.d = x; exports.e = R; exports.f = d; exports.g = V; exports.h = I; exports.i = D; exports.j = k; exports.k = P; exports.l = a; exports.m = J; exports.n = K; exports.o = H; exports.p = $; exports.q = F; exports.r = c; exports.s = E; exports.t = g; exports.u = l; exports.v = M; exports.w = q; exports.x = b; exports.y = Q; exports.z = U; exports.A = W; exports.B = p; exports.C = T; exports.D = A; exports.E = z; exports.F = N; exports.G = y; exports.H = S; exports.I = O; exports.J = Z; exports.K = ee; exports.L = G; exports.M = X; exports.N = h; exports.O = _; exports.P = v; exports.Q = s; exports.R = B; exports.S = w;
|
|
2
|
+
//# sourceMappingURL=chunk-X6GMJCOG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/symbols.ts","../src/data/fallbackColor.ts","../src/data/namedColors.ts","../src/utils/brightness.ts","../src/utils/closestNamedColor.ts","../src/utils/contrast.ts","../src/utils/couldBeRgb.ts","../src/utils/distance.ts","../src/utils/grayscale.ts","../src/utils/toColorChannels.ts","../src/utils/invert.ts","../src/utils/isAliasToNamedColor.ts","../src/utils/isAlphaChannel.ts","../src/utils/isBright.ts","../src/utils/isColor.ts","../src/utils/isColorChannels.ts","../src/utils/isDark.ts","../src/utils/isHex.ts","../src/utils/isNamedColor.ts","../src/utils/isOpaque.ts","../src/utils/isRgb.ts","../src/utils/isRgbChannel.ts","../src/utils/isTranslucent.ts","../src/utils/isTransparent.ts","../src/utils/linearTosRGB.ts","../src/utils/luminance.ts","../src/utils/namedColorAliases.ts","../src/utils/namedColorChannels.ts","../src/utils/namedColorToHex.ts","../src/classes/Color.ts","../src/utils/parseColor.ts","../src/utils/parseHex.ts","../src/utils/parseNamedColor.ts","../src/utils/parseRgb.ts","../src/utils/random.ts","../src/utils/randomAlphaChannel.ts","../src/utils/randomRgbChannel.ts","../src/utils/sRGBtoLinear.ts","../src/utils/toAlphaChannel.ts","../src/utils/toHex.ts","../src/utils/toRgb.ts","../src/utils/toRgbChannel.ts","../src/utils/type.ts"],"names":["channels","cache","fallbackColor","namedColorsMap","namedColors","brightness","l","luminance","closestNamedColor","closest","smallestDistance","name","value","namedColorChannels","d","distance","contrast","channelsA","channelsB","darkest","brightest","minMax","couldBeRgb","isArray","isBetween","isNumber","a","b","alpha","grayscale","gray","linearTosRGB","toColorChannels","r","g","isTransformed","isFallback","isObject","finalR","toRgbChannel","finalG","finalB","finalA","toAlphaChannel","invert","isAliasToNamedColor","alias","namedColorAliases","isAlphaChannel","isBright","threshold","isColor","type","isColorChannels","isRgbChannel","isDark","hexadecimalRegex","isHex","isString","isStrictString","isNamedColor","isOpaque","isRgb","n","i","isTranslucent","isTransparent","channel","v","sRGBtoLinear","namedColorsAliasesCache","aliases","targetHex","namedColorToHex","hex","entries","namedColorsChannelsCache","parseHex","Color","_Color","rest","parseColor","rgb","parseRgb","parseNamedColor","color","presets","random","getter","key","cacheKey","toHex","toRgb","isShort","hasAlpha","randomRgbChannel","randomAlphaChannel","range","randomFloat","randomInteger","clamp","round","max"],"mappings":"AAGO,6LAAMA,CAAAA,CAAW,MAAA,CAAO,gBAAgB,CAAA,CAKlCC,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AAA,CAA0C,CACrE,OAAOwF,4BAAAA,4BAAMC,CAAW,CAAA,CAAG,CAAA,CAAG,GAAG,CACnC,CCCO,SAASjD,CAAAA,CAAKxC,CAAAA,CAAuC,CAC1D,EAAA,CAAKA,CAAAA,CAIL,CAAA,EAAA,CAAIA,EAAAA,WAAiBkE,CAAAA,CACnB,MAAO,OAAA,CAGT,EAAA,CAAIlB,CAAAA,CAAahD,CAAK,CAAA,CACpB,MAAO,OAAA,CAGT,EAAA,CAAI6C,CAAAA,CAAM7C,CAAK,CAAA,CACb,MAAO,KAAA,CAGT,EAAA,CAAIkD,CAAAA,CAAMlD,CAAK,CAAA,CACb,MAAO,KAAA,CAGT,EAAA,CAAIyC,CAAAA,CAAgBzC,CAAK,CAAA,CACvB,MAAO,UAAA,CAIX,CAAA,mqBAAA","file":"/home/runner/work/lib-js-jaune/lib-js-jaune/dist/chunk-X6GMJCOG.cjs","sourcesContent":["/**\n * Used to privately store the cached channels of a color.\n */\nexport const channels = Symbol(\"Color.channels\");\n\n/**\n * Used to privately store the cached data of a color.\n */\nexport const cache = Symbol(\"Color.cache\");\n","import type { ColorChannels } from \"~/types\";\n\nexport const fallbackColor: Required<ColorChannels> = Object.freeze({\n r: 0,\n g: 0,\n b: 0,\n a: 1,\n isTransformed: false,\n isFallback: true,\n});\n","import type { NamedColor } from \"~/types\";\n\n/**\n * A map of named colors and their HEX values.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/named-color\n */\nexport const namedColorsMap = Object.freeze({\n aliceblue: \"#f0f8ffff\",\n antiquewhite: \"#faebd7ff\",\n aqua: \"#00ffffff\",\n aquamarine: \"#7fffd4ff\",\n azure: \"#f0ffffff\",\n beige: \"#f5f5dcff\",\n bisque: \"#ffe4c4ff\",\n black: \"#000000ff\",\n blanchedalmond: \"#ffebcdff\",\n blue: \"#0000ffff\",\n blueviolet: \"#8a2be2ff\",\n brown: \"#a52a2aff\",\n burlywood: \"#deb887ff\",\n cadetblue: \"#5f9ea0ff\",\n chartreuse: \"#7fff00ff\",\n chocolate: \"#d2691eff\",\n coral: \"#ff7f50ff\",\n cornflowerblue: \"#6495edff\",\n cornsilk: \"#fff8dcff\",\n crimson: \"#dc143cff\",\n cyan: \"#00ffffff\",\n darkblue: \"#00008bff\",\n darkcyan: \"#008b8bff\",\n darkgoldenrod: \"#b8860bff\",\n darkgray: \"#a9a9a9ff\",\n darkgreen: \"#006400ff\",\n darkgrey: \"#a9a9a9ff\",\n darkkhaki: \"#bdb76bff\",\n darkmagenta: \"#8b008bff\",\n darkolivegreen: \"#556b2fff\",\n darkorange: \"#ff8c00ff\",\n darkorchid: \"#9932ccff\",\n darkred: \"#8b0000ff\",\n darksalmon: \"#e9967aff\",\n darkseagreen: \"#8fbc8fff\",\n darkslateblue: \"#483d8bff\",\n darkslategray: \"#2f4f4fff\",\n darkslategrey: \"#2f4f4fff\",\n darkturquoise: \"#00ced1ff\",\n darkviolet: \"#9400d3ff\",\n deeppink: \"#ff1493ff\",\n deepskyblue: \"#00bfffff\",\n dimgray: \"#696969ff\",\n dimgrey: \"#696969ff\",\n dodgerblue: \"#1e90ffff\",\n firebrick: \"#b22222ff\",\n floralwhite: \"#fffaf0ff\",\n forestgreen: \"#228b22ff\",\n fuchsia: \"#ff00ffff\",\n gainsboro: \"#dcdcdcff\",\n ghostwhite: \"#f8f8ffff\",\n gold: \"#ffd700ff\",\n goldenrod: \"#daa520ff\",\n gray: \"#808080ff\",\n green: \"#008000ff\",\n greenyellow: \"#adff2fff\",\n grey: \"#808080ff\",\n honeydew: \"#f0fff0ff\",\n hotpink: \"#ff69b4ff\",\n indianred: \"#cd5c5cff\",\n indigo: \"#4b0082ff\",\n ivory: \"#fffff0ff\",\n khaki: \"#f0e68cff\",\n lavender: \"#e6e6faff\",\n lavenderblush: \"#fff0f5ff\",\n lawngreen: \"#7cfc00ff\",\n lemonchiffon: \"#fffacdff\",\n lightblue: \"#add8e6ff\",\n lightcoral: \"#f08080ff\",\n lightcyan: \"#e0ffffff\",\n lightgoldenrodyellow: \"#fafad2ff\",\n lightgray: \"#d3d3d3ff\",\n lightgreen: \"#90ee90ff\",\n lightgrey: \"#d3d3d3ff\",\n lightpink: \"#ffb6c1ff\",\n lightsalmon: \"#ffa07aff\",\n lightseagreen: \"#20b2aaff\",\n lightskyblue: \"#87cefaff\",\n lightslategray: \"#778899ff\",\n lightslategrey: \"#778899ff\",\n lightsteelblue: \"#b0c4deff\",\n lightyellow: \"#ffffe0ff\",\n lime: \"#00ff00ff\",\n limegreen: \"#32cd32ff\",\n linen: \"#faf0e6ff\",\n magenta: \"#ff00ffff\",\n maroon: \"#800000ff\",\n mediumaquamarine: \"#66cdaaff\",\n mediumblue: \"#0000cdff\",\n mediumorchid: \"#ba55d3ff\",\n mediumpurple: \"#9370dbff\",\n mediumseagreen: \"#3cb371ff\",\n mediumslateblue: \"#7b68eeff\",\n mediumspringgreen: \"#00fa9aff\",\n mediumturquoise: \"#48d1ccff\",\n mediumvioletred: \"#c71585ff\",\n midnightblue: \"#191970ff\",\n mintcream: \"#f5fffaff\",\n mistyrose: \"#ffe4e1ff\",\n moccasin: \"#ffe4b5ff\",\n navajowhite: \"#ffdeadff\",\n navy: \"#000080ff\",\n oldlace: \"#fdf5e6ff\",\n olive: \"#808000ff\",\n olivedrab: \"#6b8e23ff\",\n orange: \"#ffa500ff\",\n orangered: \"#ff4500ff\",\n orchid: \"#da70d6ff\",\n palegoldenrod: \"#eee8aaff\",\n palegreen: \"#98fb98ff\",\n paleturquoise: \"#afeeeeff\",\n palevioletred: \"#db7093ff\",\n papayawhip: \"#ffefd5ff\",\n peachpuff: \"#ffdab9ff\",\n peru: \"#cd853fff\",\n pink: \"#ffc0cbff\",\n plum: \"#dda0ddff\",\n powderblue: \"#b0e0e6ff\",\n purple: \"#800080ff\",\n rebeccapurple: \"#663399ff\",\n red: \"#ff0000ff\",\n rosybrown: \"#bc8f8fff\",\n royalblue: \"#4169e1ff\",\n saddlebrown: \"#8b4513ff\",\n salmon: \"#fa8072ff\",\n sandybrown: \"#f4a460ff\",\n seagreen: \"#2e8b57ff\",\n seashell: \"#fff5eeff\",\n sienna: \"#a0522dff\",\n silver: \"#c0c0c0ff\",\n skyblue: \"#87ceebff\",\n slateblue: \"#6a5acdff\",\n slategray: \"#708090ff\",\n slategrey: \"#708090ff\",\n snow: \"#fffafaff\",\n springgreen: \"#00ff7fff\",\n steelblue: \"#4682b4ff\",\n tan: \"#d2b48cff\",\n teal: \"#008080ff\",\n thistle: \"#d8bfd8ff\",\n tomato: \"#ff6347ff\",\n transparent: \"#00000000\",\n turquoise: \"#40e0d0ff\",\n violet: \"#ee82eeff\",\n wheat: \"#f5deb3ff\",\n white: \"#ffffffff\",\n whitesmoke: \"#f5f5f5ff\",\n yellow: \"#ffff00ff\",\n yellowgreen: \"#9acd32ff\",\n});\n\nexport const namedColors = new Set<NamedColor>(\n Object.keys(namedColorsMap) as NamedColor[]\n);\n","import type { ColorChannels } from \"~/types\";\nimport { luminance } from \"~/utils\";\n\n/**\n * Returns the perceived brightness of a color normalized to the range [0, 1].\n *\n * @see https://stackoverflow.com/a/56678483\n */\nexport function brightness(channels: ColorChannels): number {\n const l = luminance(channels);\n\n if (l <= 216 / 24389) {\n return (l * (24389 / 27)) / 100;\n }\n\n return (Math.pow(l, 1 / 3) * 116 - 16) / 100;\n}\n","import type { ColorChannels, NamedColor } from \"~/types\";\nimport { distance, namedColorChannels, namedColors } from \"~/utils\";\n\n/** Returns the closest named color to the passed color channels. */\nexport function closestNamedColor(channels: ColorChannels): NamedColor {\n let closest: NamedColor | undefined;\n let smallestDistance = Infinity;\n\n for (const name of namedColors) {\n const value = namedColorChannels(name);\n\n const d = distance(\n value,\n channels,\n value.a === 1 // Ignore alpha channel only if it's 1 -> allows to match transparent/black correctly\n );\n\n if (d < smallestDistance) {\n closest = name;\n smallestDistance = d;\n }\n }\n\n return closest!;\n}\n","import { minMax } from \"@auaust/primitive-kit/numbers\";\nimport type { ColorChannels } from \"~/types\";\nimport { luminance } from \"~/utils\";\n\n/**\n * Returns the contrast ratio between two colors.\n *\n * @see https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef\n */\nexport function contrast(channelsA: ColorChannels, channelsB: ColorChannels) {\n const [darkest, brightest] = minMax(\n luminance(channelsA),\n luminance(channelsB)\n );\n\n return (brightest + 0.05) / (darkest + 0.05);\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport { isBetween, isNumber } from \"@auaust/primitive-kit/numbers\";\nimport type { Rgb } from \"~/types\";\n\n/**\n * Whether the input could be a valid RGB color.\n * As in, it checks if the input is an array of numbers without validating the values range.\n */\nexport function couldBeRgb(value: unknown): value is Rgb {\n return (\n isArray(value) && isBetween(value.length, 3, 4) && value.every(isNumber)\n );\n}\n","import type { ColorChannels } from \"~/types\";\n\n/** Calculate the distance between two colors. It is mostly useful for comparing distances between colors, but the value itself is not very meaningful. */\nexport function distance(\n a: ColorChannels,\n b: ColorChannels,\n alpha = false\n): number {\n return Math.sqrt(\n Math.pow(a.r - b.r, 2) +\n Math.pow(a.g - b.g, 2) +\n Math.pow(a.b - b.b, 2) +\n (alpha ? Math.pow((a.a ?? 1) - (b.a ?? 1), 2) : 0)\n );\n}\n","import type { ColorChannels } from \"~/types\";\nimport { linearTosRGB, luminance, toColorChannels } from \"~/utils\";\n\n/**\n * Returns the grayscale equivalent of a color as a new color channels object.\n */\nexport function grayscale(channels: ColorChannels): ColorChannels {\n // Reverse gamma correction from luminance\n const gray = linearTosRGB(luminance(channels)) * 255;\n\n return toColorChannels(gray, gray, gray, channels.a);\n}\n","import { isObject } from \"@auaust/primitive-kit/objects\";\nimport type { ColorChannels } from \"~/types\";\nimport { fallbackColor, toAlphaChannel, toRgbChannel } from \"~/utils\";\n\n/**\n * Formats the input into a readonly object of color channels.\n *\n * It clamps the values to the valid range and sets the alpha channel to 1 if not provided.\n * If the passed `isTransformed` isn't already `true`, it will set it to `true` if any of the values were clamped.\n * If some channels are missing, it will return the fallback color.\n */\nexport function toColorChannels(value: ColorChannels): Required<ColorChannels>;\nexport function toColorChannels(\n r: number,\n g: number,\n b: number,\n a?: number | null,\n isTransformed?: boolean,\n isFallback?: boolean\n): Required<ColorChannels>;\nexport function toColorChannels(\n r: number | ColorChannels,\n g?: number,\n b?: number,\n a?: number | null,\n isTransformed?: boolean,\n isFallback?: boolean\n): Required<ColorChannels> {\n if (isObject(r, false)) {\n ({ r, g, b, a, isTransformed, isFallback } = r);\n }\n\n const finalR = toRgbChannel(r);\n const finalG = toRgbChannel(g);\n const finalB = toRgbChannel(b);\n\n if (isNaN(finalR) || isNaN(finalG) || isNaN(finalB)) {\n return fallbackColor;\n }\n\n const finalA = toAlphaChannel(a);\n\n return Object.freeze({\n r: finalR,\n g: finalG,\n b: finalB,\n a: finalA,\n isTransformed: !!(\n isTransformed ||\n finalR !== r ||\n finalG !== g ||\n finalB !== b ||\n finalA !== (a ?? 1)\n ),\n isFallback: !!isFallback,\n });\n}\n","import type { ColorChannels } from \"~/types\";\nimport { toColorChannels } from \"~/utils/toColorChannels\";\n\nexport function invert(channels: ColorChannels): ColorChannels {\n return toColorChannels(\n 255 - channels.r,\n 255 - channels.g,\n 255 - channels.b,\n channels.a\n );\n}\n","import type { NamedColor } from \"~/types\";\nimport { namedColorAliases } from \"~/utils\";\n\n/**\n * Returns a boolean indicating whether two named colors are aliases.\n */\nexport function isAliasToNamedColor(\n name: NamedColor,\n alias: NamedColor\n): boolean {\n return namedColorAliases(name).includes(<NamedColor>alias.toLowerCase());\n}\n","import { isBetween, isNumber } from \"@auaust/primitive-kit/numbers\";\n\nexport function isAlphaChannel(value: unknown): value is number {\n return isNumber(value) && isBetween(value, 0, 1);\n}\n","import type { ColorChannels } from \"~/types\";\nimport { brightness } from \"~/utils\";\n\n/** Returns whether the color is bright, as in its brightness is greater than 0.5 or the provided threshold. */\nexport function isBright(channels: ColorChannels, threshold = 0.5): boolean {\n return brightness(channels) > threshold;\n}\n","import type { ColorValue } from \"~/types\";\nimport { type } from \"~/utils\";\n\n/** Returns true if the value is any format of supported color. */\nexport function isColor(value: unknown): value is ColorValue {\n return type(value) !== undefined;\n}\n","import { isObject } from \"@auaust/primitive-kit/objects\";\nimport type { ColorChannels } from \"~/types\";\nimport { isAlphaChannel, isRgbChannel } from \"~/utils\";\n\nexport function isColorChannels(value: unknown): value is ColorChannels {\n return (\n isObject(value, false) &&\n isRgbChannel(value.r) &&\n isRgbChannel(value.g) &&\n isRgbChannel(value.b) &&\n isAlphaChannel(value.a ?? 1)\n );\n}\n","import type { ColorChannels } from \"~/types\";\nimport { brightness } from \"~/utils\";\n\n/** Returns whether the color is dark, as in its brightness is less than or equal to 0.5 or the provided threshold. */\nexport function isDark(channels: ColorChannels, threshold = 0.5): boolean {\n return brightness(channels) <= threshold;\n}\n","import { isStrictString, isString } from \"@auaust/primitive-kit/strings\";\nimport type { Hex } from \"~/types\";\n\nconst hexadecimalRegex = /^[0-9A-Fa-f]+$/;\n\n/**\n * Whether the input is a valid HEX color. With or without the alpha channel, and with single or double digits.\n *\n * It may or may not start with a hash character, which will be ignored.\n */\nexport function isHex(value: unknown): value is Hex {\n value = isString(value) && (value.startsWith(\"#\") ? value.slice(1) : value);\n\n if (!isStrictString(value)) {\n return false;\n }\n\n switch (value.length) {\n case 3: // RGB\n case 4: // RGBA\n case 6: // RRGGBB\n case 8: // RRGGBBAA\n return hexadecimalRegex.test(value);\n default:\n return false;\n }\n}\n","import { isString } from \"@auaust/primitive-kit/strings\";\nimport { namedColors } from \"~/data/namedColors\";\nimport type { NamedColor } from \"~/types\";\n\n/**\n * Whether the input is a valid named color.\n *\n * The check is case-insensitive.\n */\nexport function isNamedColor(value: unknown): value is NamedColor {\n return isString(value) && namedColors.has(<NamedColor>value.toLowerCase());\n}\n","import type { ColorChannels } from \"~/types\";\n\n/** Checks if the color is fully opaque. */\nexport function isOpaque(channels: ColorChannels) {\n return channels.a === 1 || channels.a == undefined;\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport { isBetween } from \"@auaust/primitive-kit/numbers\";\nimport type { Rgb } from \"~/types\";\nimport { isAlphaChannel, isRgbChannel } from \"~/utils\";\n\n/**\n * Whether the input is a valid RGB color.\n */\nexport function isRgb(value: unknown): value is Rgb {\n return (\n isArray(value) &&\n isBetween(value.length, 3, 4) &&\n value.every((n, i) => (i === 3 ? isAlphaChannel(n) : isRgbChannel(n)))\n );\n}\n","import { isBetween, isNumber } from \"@auaust/primitive-kit/numbers\";\n\nexport function isRgbChannel(value: unknown): value is number {\n return isNumber(value) && isBetween(value, 0, 255);\n}\n","import type { ColorChannels } from \"~/types\";\nimport { isOpaque } from \"~/utils\";\n\n/** Checks if the color is at least partially transparent. */\nexport function isTranslucent(channels: ColorChannels) {\n return !isOpaque(channels);\n}\n","import type { ColorChannels } from \"~/types\";\n\n/** Checks if the color is fully transparent. */\nexport function isTransparent(channels: ColorChannels) {\n return channels.a === 0;\n}\n","/**\n * Returns the gamma corrected sRGB value of a linear channel.\n */\nexport function linearTosRGB(channel: number) {\n if (channel <= 0.04045 / 12.92) {\n return channel * 12.92;\n }\n\n return 1.055 * Math.pow(channel, 1 / 2.4) - 0.055;\n}\n","import type { ColorChannels } from \"~/types\";\nimport { sRGBtoLinear } from \"~/utils\";\n\n/**\n * Returns the luminance of a color normalized to the range [0, 1].\n *\n * @see https://stackoverflow.com/a/56678483\n * @see https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef\n */\nexport function luminance(channels: ColorChannels) {\n let { r, g, b } = channels;\n\n [r, g, b] = [r, g, b].map((v) => sRGBtoLinear(v / 255));\n\n return r * 0.2126 + g * 0.7152 + b * 0.0722;\n}\n","import { entries } from \"@auaust/primitive-kit/objects\";\nimport type { NamedColor } from \"~/types\";\nimport { isNamedColor, namedColorToHex, namedColorsMap } from \"~/utils\";\n\nconst namedColorsAliasesCache: Partial<\n Record<NamedColor, readonly NamedColor[]>\n> = {};\n\n/**\n * Returns all the aliases of a named color.\n */\nexport function namedColorAliases(name: NamedColor): readonly NamedColor[] {\n name = <NamedColor>name.toLowerCase();\n\n if (!isNamedColor(name)) {\n return [];\n }\n\n if (namedColorsAliasesCache[name]) {\n return namedColorsAliasesCache[name]!;\n }\n\n const aliases: NamedColor[] = [];\n const targetHex = namedColorToHex(name);\n\n for (const [name, hex] of entries(namedColorsMap)) {\n if (hex === targetHex) {\n aliases.push(name);\n }\n }\n\n return (namedColorsAliasesCache[name] = Object.freeze(aliases));\n}\n","import type { ColorChannels, NamedColor } from \"~/types\";\nimport { namedColorToHex, parseHex } from \"~/utils\";\n\nconst namedColorsChannelsCache: Partial<Record<NamedColor, ColorChannels>> = {};\n\n/**\n * Returns the color channels from a named color. Must be a valid named color, already lowercased.\n *\n * @internal\n */\nexport function namedColorChannels(name: NamedColor): ColorChannels {\n return (namedColorsChannelsCache[name] ??= parseHex(namedColorToHex(name)!));\n}\n","import { namedColorsMap } from \"~/data/namedColors\";\nimport type { MaybeNamedColor, NamedColor } from \"~/types\";\n\n/**\n * Returns the corresponding HEX value of a named color.\n */\nexport function namedColorToHex(name: NamedColor): string;\nexport function namedColorToHex(name: MaybeNamedColor): string | undefined;\nexport function namedColorToHex(name: MaybeNamedColor): string | undefined {\n return namedColorsMap[<NamedColor>name.toLowerCase()] || undefined;\n}\n","import { isNumber } from \"@auaust/primitive-kit/numbers\";\nimport type { Writable } from \"type-fest\";\nimport type {\n ColorChannels,\n ColorValue,\n MaybeNamedColor,\n NamedColor,\n Rgb,\n} from \"~/index\";\nimport {\n brightness,\n cache,\n channels,\n closestNamedColor,\n contrast,\n distance,\n fallbackColor,\n grayscale,\n invert,\n isAliasToNamedColor,\n isBright,\n isColor,\n isColorChannels,\n isDark,\n isHex,\n isNamedColor,\n isOpaque,\n isRgb,\n isTranslucent,\n isTransparent,\n luminance,\n namedColorAliases,\n parseColor,\n parseHex,\n parseNamedColor,\n parseRgb,\n random,\n toAlphaChannel,\n toColorChannels,\n toHex,\n toRgb,\n toRgbChannel,\n type,\n} from \"~/utils\";\n\nexport class Color {\n protected [channels]: Required<Writable<ColorChannels>> = undefined!;\n protected [cache]: Map<string | Function, any> = new Map();\n\n constructor(value: ColorChannels) {\n this[channels] = { ...toColorChannels(value) };\n }\n\n static from(value: ColorValue): Color;\n static from(red: number, green: number, blue: number, alpha?: number): Color;\n static from(value: ColorValue | number, ...rest: number[]): Color {\n if (isNumber(value)) {\n return new Color({ r: value, g: rest[0], b: rest[1], a: rest[2] });\n }\n\n return new Color(parseColor(value ?? fallbackColor));\n }\n\n static fromChannels(channels: ColorChannels): Color {\n return new Color(channels);\n }\n\n static fromRgb(rgb: Rgb): Color {\n return new Color(parseRgb(rgb));\n }\n\n static fromHex(hex: string): Color {\n return new Color(parseHex(hex));\n }\n\n static fromName(name: MaybeNamedColor): Color {\n return new Color(parseNamedColor(name));\n }\n\n static parse(value: ColorValue): ColorChannels | undefined {\n const color = parseColor(value);\n\n return color.isFallback ? undefined : color;\n }\n\n static random(presets: Parameters<typeof random>[0] = {}): Color {\n return new Color(random(presets));\n }\n\n /**\n * Returns the color type of the passed value, or `undefined` if it's not a color.\n *\n * It is slightly stricter than the logic used to parse colors.\n * It would return false for an array of channels which values are not within the expected range, where `parseColor` would return a color with the invalid values clamped.\n */\n static type = type;\n\n /** Returns a boolean indicating whether the passed value is a color. */\n static isColor = isColor;\n\n /** @alias Color#isColor */\n static is = isColor;\n\n /** Returns a boolean indicating whether the passed value is a HEX color string. */\n static isHex = isHex;\n\n /** Returns a boolean indicating whether the passed value is a named color. */\n static isNamedColor = isNamedColor;\n\n /** Returns a boolean indicating whether the passed value is a color channel object. */\n static isColorChannels = isColorChannels;\n\n /** Returns a boolean indicating whether the passed value is a RGB color tuple. */\n static isRgb = isRgb;\n\n /** Returns all the aliases of a named color, including the name itself. */\n static namedColorAliases = namedColorAliases;\n\n /** Returns a boolean whether two named colors are aliases, meaning they have the same HEX value. */\n static isAliasToNamedColor = isAliasToNamedColor;\n\n /**\n * Returns a new `Color` instance with the same channels as the current one.\n * If you want the clone to have different channels, use the `with` method.\n */\n clone(): Color {\n return Color.fromChannels(this[channels]);\n }\n\n /** Returns a new `Color` instance with the passed channels overriding the current ones. */\n with(value: Partial<Pick<ColorChannels, \"r\" | \"g\" | \"b\" | \"a\">>): Color {\n return Color.fromChannels({\n ...this[channels],\n ...value,\n isFallback: false,\n isTransformed: false,\n });\n }\n\n /** Returns a new `Color` instance with the specified red channel. */\n withRed(value: number): Color {\n return this.with({ r: value });\n }\n\n /** Returns a new `Color` instance with the specified green channel. */\n withGreen(value: number): Color {\n return this.with({ g: value });\n }\n\n /** Returns a new `Color` instance with the specified blue channel. */\n withBlue(value: number): Color {\n return this.with({ b: value });\n }\n\n /** Returns a new `Color` instance with the specified alpha channel. */\n withAlpha(value: number): Color {\n return this.with({ a: value });\n }\n\n private updated(): this {\n this[cache].clear();\n this[channels].isFallback = false; // once updated, it's no longer a fallback\n this[channels].isTransformed = false;\n return this;\n }\n\n set(channel: \"r\" | \"g\" | \"b\" | \"a\", value: number): this {\n this[channels][channel] =\n channel === \"a\" ? toAlphaChannel(value) : toRgbChannel(value);\n return this.updated();\n }\n\n /** The red channel of the color. */\n get red(): number {\n return this[channels].r;\n }\n\n /** @see Color#red */\n get r(): number {\n return this[channels].r;\n }\n\n set red(value: number) {\n this.setRed(value);\n }\n\n setRed(value: number): this {\n return this.set(\"r\", value);\n }\n\n /** The green channel of the color. */\n get green(): number {\n return this[channels].g;\n }\n\n /** @see Color#green */\n get g(): number {\n return this[channels].g;\n }\n\n set green(value: number) {\n this.setGreen(value);\n }\n\n setGreen(value: number): this {\n return this.set(\"g\", value);\n }\n\n /** The blue channel of the color. */\n get blue(): number {\n return this[channels].b;\n }\n\n /** @see Color#blue */\n get b(): number {\n return this[channels].b;\n }\n\n set blue(value: number) {\n this.setBlue(value);\n }\n\n setBlue(value: number): this {\n return this.set(\"b\", value);\n }\n\n /** The alpha channel of the color. */\n get alpha(): number {\n return this[channels].a;\n }\n\n /** @see Color#alpha */\n get a(): number {\n return this[channels].a;\n }\n\n set alpha(value: number) {\n this.setAlpha(value);\n }\n\n setAlpha(value: number): this {\n return this.set(\"a\", value);\n }\n\n /**\n * Whether the color is the fallback color, which is used when the input is invalid.\n * As soon as a color channel is updated, this will always be `false`.\n */\n get isFallback(): boolean {\n return this[channels].isFallback;\n }\n\n /**\n * Whether any of the channels have been transformed by the color parser.\n * As soon as a color channel is updated, this will always be `false`.\n */\n get isTransformed(): boolean {\n return this[channels].isTransformed;\n }\n\n /** Helper to cache data until the channels are updated. */\n private memoize<T>(getter: (channels: ColorChannels) => T, key?: string): T {\n // If no key is passed, we use the getter function as the key\n // This means no key is required when the getter is a named function, while allowing to use anonymous functions within getters as well by passing a key\n const cacheKey = key ?? getter;\n\n if (!this[cache].has(cacheKey)) {\n this[cache].set(cacheKey, getter(this[channels]));\n }\n\n return this[cache].get(cacheKey);\n }\n\n /** Checks if the color is fully opaque. */\n get isOpaque(): boolean {\n return this.memoize(isOpaque);\n }\n\n /** Checks if the color is fully transparent. */\n get isTransparent(): boolean {\n return this.memoize(isTransparent);\n }\n\n /** Checks if the color is at least partially transparent. */\n get isTranslucent(): boolean {\n return this.memoize(isTranslucent);\n }\n\n /**\n * Returns the closest named color. If aliases exist, which one is returned is not guaranteed.\n * In some cases, calling `namedColorAliases()` on the result might help achieve the desired result.\n */\n get closestNamedColor(): NamedColor {\n return this.memoize(closestNamedColor);\n }\n\n /** The relative brightness of the color. */\n get brightness(): number {\n return this.memoize(brightness);\n }\n\n /** Whether the color is considered bright. */\n get isBright(): boolean {\n return this.memoize(isBright);\n }\n\n /** Whether the color is considered dark. */\n get isDark(): boolean {\n return this.memoize(isDark);\n }\n\n /** Whether the color is brighter than the passed threshold or color. */\n isBrighterThan(threshold: Color | number): boolean {\n return (\n this.brightness >\n (threshold instanceof Color ? threshold.brightness : threshold)\n );\n }\n\n /** Whether the color is darker than the passed threshold or color. */\n isDarkerThan(threshold: Color | number): boolean {\n return (\n this.brightness <\n (threshold instanceof Color ? threshold.brightness : threshold)\n );\n }\n\n /** Returns the relative luminance of the color. */\n get luminance(): number {\n return this.memoize(luminance);\n }\n\n /** Returns the contrast ratio between this color and another. */\n contrast(color: ColorValue): number {\n return contrast(this[channels], parseColor(color));\n }\n\n /** Returns the distance between this color and another. If `alpha` is `true`, the alpha channel is included in the calculation. */\n distance(color: ColorValue, alpha = false): number {\n return distance(this[channels], parseColor(color), alpha);\n }\n\n /** Returns a new color with the grayscale equivalent of the current color, preserving the alpha channel. */\n toGrayscale(): Color {\n return Color.fromChannels(grayscale(this[channels]));\n }\n\n toInvert(): Color {\n return Color.fromChannels(invert(this[channels]));\n }\n\n toHex(): string {\n return this.memoize(toHex);\n }\n\n toRgb(): Rgb {\n return this.memoize(toRgb);\n }\n\n toChannels(): ColorChannels {\n return this.memoize(toColorChannels); // can't return `this[channels]` directly as it's writable, and could cause unexpected behavior\n }\n\n toString(): string {\n return this.toHex();\n }\n\n valueOf(): string {\n return this.toString();\n }\n\n [Symbol.toPrimitive](): string {\n return this.toString();\n }\n\n toJSON(): string {\n return this.toString();\n }\n}\n","import { Color } from \"~/classes/Color\";\nimport type { ColorChannels } from \"~/types\";\nimport {\n channels,\n couldBeRgb,\n fallbackColor,\n isColorChannels,\n isHex,\n isNamedColor,\n parseHex,\n parseNamedColor,\n parseRgb,\n} from \"~/utils\";\n\n/** Tries to parse the value as a color. If it fails, returns the fallback color. */\nexport function parseColor(value: unknown): ColorChannels {\n if (!value) {\n return fallbackColor;\n }\n\n if (value instanceof Color) {\n return value[channels];\n }\n\n if (isColorChannels(value)) {\n return value;\n }\n\n if (isNamedColor(value)) {\n return parseNamedColor(value);\n }\n\n if (isHex(value)) {\n return parseHex(value);\n }\n\n if (couldBeRgb(value)) {\n // It might not be a valid RGB, in which case `parseRgb` is responsible for returning the fallback color\n // In case more color types are added, it might be required to only return the result of `parseRgb` if `isFallback` is false\n return parseRgb(value);\n }\n\n return fallbackColor;\n}\n","import type { ColorChannels, Hex } from \"~/types\";\nimport { toColorChannels } from \"~/utils\";\n\n/**\n * Parses a hex string into an object of color channels.\n *\n * The input must already be a valid HEX color, otherwise the result will be unexpected.\n */\nexport function parseHex(value: Hex): ColorChannels {\n value = value.startsWith(\"#\") ? value.slice(1) : value;\n\n const isShort = value.length < 6;\n const hasAlpha = isShort ? value.length === 4 : value.length === 8;\n\n const r = parseInt(isShort ? value[0].repeat(2) : value.slice(0, 2), 16);\n const g = parseInt(isShort ? value[1].repeat(2) : value.slice(2, 4), 16);\n const b = parseInt(isShort ? value[2].repeat(2) : value.slice(4, 6), 16);\n const a = hasAlpha\n ? parseInt(isShort ? value[3].repeat(2) : value.slice(6, 8), 16) / 255\n : 1;\n\n return toColorChannels(r, g, b, a);\n}\n","import type { ColorChannels, MaybeNamedColor, NamedColor } from \"~/types\";\nimport { fallbackColor, isNamedColor, namedColorChannels } from \"~/utils\";\n\n/**\n * Returns the color channels from a named color.\n */\nexport function parseNamedColor(name: MaybeNamedColor): ColorChannels {\n if (!isNamedColor(name)) {\n return fallbackColor;\n }\n\n return namedColorChannels(<NamedColor>name.toLowerCase());\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport type { ColorChannels, Rgb } from \"~/types\";\nimport { fallbackColor, toColorChannels } from \"~/utils\";\n\n/**\n * Parses a RGB tuple into an object of color channels.\n *\n * The input must already be a valid RGB tuple, otherwise the result will be unexpected.\n */\nexport function parseRgb(value: Rgb): ColorChannels {\n return isArray(value)\n ? toColorChannels(value[0], value[1], value[2], value[3]) // Don't spread to avoid mistakenly forwarding `isTransformed` and `isFallback`\n : fallbackColor;\n}\n","import type { ChannelRange, ColorChannels } from \"~/types\";\nimport { randomAlphaChannel, randomRgbChannel, toColorChannels } from \"~/utils\";\n\n/**\n * Generates a random color.\n *\n * Specific values or ranges can be provided for each channel.\n * If a range is provided, the value will be randomly selected from within that range.\n * If a single value is provided, that value will be used for the channel.\n * If no value is provided, the channel will be randomly selected from 0 to 255 for RGB channels and be set to 1 for the alpha channel.\n */\nexport function random({\n r,\n g,\n b,\n a,\n}: {\n r?: ChannelRange;\n g?: ChannelRange;\n b?: ChannelRange;\n a?: ChannelRange;\n} = {}): ColorChannels {\n return toColorChannels(\n randomRgbChannel(r),\n randomRgbChannel(g),\n randomRgbChannel(b),\n randomAlphaChannel(a)\n );\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport { isNumber, randomFloat } from \"@auaust/primitive-kit/numbers\";\nimport type { ChannelRange } from \"~/types\";\n\nexport function randomAlphaChannel(range?: ChannelRange | undefined): number {\n if (isNumber(range)) {\n return range;\n }\n\n if (isArray(range)) {\n return randomFloat(range[0], range[1]);\n }\n\n return 1;\n}\n","import { isArray } from \"@auaust/primitive-kit/arrays\";\nimport { isNumber, randomInteger } from \"@auaust/primitive-kit/numbers\";\nimport type { ChannelRange } from \"~/types\";\n\nexport function randomRgbChannel(range?: ChannelRange | undefined): number {\n if (isNumber(range)) {\n return range;\n }\n\n if (isArray(range)) {\n return randomInteger(range[0], range[1]);\n }\n\n return randomInteger(0, 255);\n}\n","/**\n * Returns the linearized value of a sRGB channel.\n *\n * @see https://stackoverflow.com/a/56678483\n */\nexport function sRGBtoLinear(channel: number) {\n if (channel <= 0.04045) {\n return channel / 12.92;\n }\n\n return Math.pow((channel + 0.055) / 1.055, 2.4);\n}\n","import { clamp, isNumber } from \"@auaust/primitive-kit/numbers\";\n\nexport function toAlphaChannel(value: number | undefined | null): number {\n return isNumber(value) ? clamp(value, 0, 1) : 1;\n}\n","import { isNumber, max, round } from \"@auaust/primitive-kit/numbers\";\nimport type { ColorChannels, Hex } from \"~/types\";\nimport { toRgbChannel } from \"~/utils\";\n\n/**\n * Returns the corresponding hex string of a color channels object.\n *\n * If the alpha channel is 1, it will be omitted.\n */\nexport function toHex(channels: ColorChannels): Hex {\n const { r, g, b, a } = channels;\n\n return (\n \"#\" +\n (\n (1 << 24) +\n (toRgbChannel(r) << 16) +\n (toRgbChannel(g) << 8) +\n toRgbChannel(b)\n )\n .toString(16)\n .substring(1) +\n (isNumber(a) && a < 1\n ? round(max(0, a) * 255)\n .toString(16)\n .padStart(2, \"0\")\n : \"\")\n );\n}\n","import type { ColorChannels, Rgb } from \"~/types\";\nimport { toAlphaChannel, toRgbChannel } from \"~/utils\";\n\n/**\n * Returns the corresponding RGB tuple of a color channels object.\n */\nexport function toRgb(channels: ColorChannels): Rgb {\n const { r, g, b, a } = channels;\n\n return Array.from([r, g, b, a], (value, i) =>\n i === 3 ? toAlphaChannel(value) : toRgbChannel(value)\n );\n}\n","import { clamp, round } from \"@auaust/primitive-kit/numbers\";\n\nexport function toRgbChannel(value: number | undefined | null): number {\n return clamp(round(value), 0, 255);\n}\n","import { Color } from \"~/classes/Color\";\nimport type { ColorType } from \"~/types\";\nimport { isColorChannels, isHex, isNamedColor, isRgb } from \"~/utils\";\n\n/** Returns the color type of the value, or undefined if it's not a color. */\nexport function type(value: unknown): ColorType | undefined {\n if (!value) {\n return undefined;\n }\n\n if (value instanceof Color) {\n return \"color\";\n }\n\n if (isNamedColor(value)) {\n return \"named\";\n }\n\n if (isHex(value)) {\n return \"hex\";\n }\n\n if (isRgb(value)) {\n return \"rgb\";\n }\n\n if (isColorChannels(value)) {\n return \"channels\";\n }\n\n return undefined;\n}\n"]}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { Writable } from 'type-fest';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Used to privately store the cached channels of a color.
|
|
5
|
+
*/
|
|
6
|
+
declare const channels: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* Used to privately store the cached data of a color.
|
|
9
|
+
*/
|
|
10
|
+
declare const cache: unique symbol;
|
|
11
|
+
|
|
3
12
|
type ColorTypeMap = {
|
|
4
13
|
channels: ColorChannels;
|
|
5
14
|
color: Color;
|
|
@@ -68,48 +77,7 @@ type ColorChannels = {
|
|
|
68
77
|
*/
|
|
69
78
|
readonly isFallback?: boolean;
|
|
70
79
|
};
|
|
71
|
-
|
|
72
|
-
declare function isRgbChannel(value: unknown): value is number;
|
|
73
|
-
declare function toRgbChannel(value: number | undefined | null): number;
|
|
74
|
-
declare function isAlphaChannel(value: unknown): value is number;
|
|
75
|
-
declare function toAlphaChannel(value: number | undefined | null): number;
|
|
76
|
-
declare function isColorChannels(value: unknown): value is ColorChannels;
|
|
77
|
-
/**
|
|
78
|
-
* Formats the input into a readonly object of color channels.
|
|
79
|
-
*
|
|
80
|
-
* It clamps the values to the valid range and sets the alpha channel to 1 if not provided.
|
|
81
|
-
* If the passed `isTransformed` isn't already `true`, it will set it to `true` if any of the values were clamped.
|
|
82
|
-
* If some channels are missing, it will return the fallback color.
|
|
83
|
-
*/
|
|
84
|
-
declare function toColorChannels(value: ColorChannels): Required<ColorChannels>;
|
|
85
|
-
declare function toColorChannels(r: number, g: number, b: number, a?: number | null, isTransformed?: boolean, isFallback?: boolean): Required<ColorChannels>;
|
|
86
|
-
declare const fallbackColor: Required<ColorChannels>;
|
|
87
|
-
|
|
88
|
-
/** Returns true if the value is any format of supported color. */
|
|
89
|
-
declare function isColor(value: unknown): value is ColorValue;
|
|
90
|
-
/** Returns the color type of the value, or undefined if it's not a color. */
|
|
91
|
-
declare function type(value: unknown): ColorType | undefined;
|
|
92
|
-
/** Tries to parse the value as a color. If it fails, returns the fallback color. */
|
|
93
|
-
declare function parseColor(value: unknown): ColorChannels;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Whether the input is a valid HEX color. With or without the alpha channel, and with single or double digits.
|
|
97
|
-
*
|
|
98
|
-
* It may or may not start with a hash character, which will be ignored.
|
|
99
|
-
*/
|
|
100
|
-
declare function isHex(value: unknown): value is Hex;
|
|
101
|
-
/**
|
|
102
|
-
* Parses a hex string into an object of color channels.
|
|
103
|
-
*
|
|
104
|
-
* The input must already be a valid HEX color, otherwise the result will be unexpected.
|
|
105
|
-
*/
|
|
106
|
-
declare function parseHex(value: Hex): ColorChannels;
|
|
107
|
-
/**
|
|
108
|
-
* Returns the corresponding hex string of a color channels object.
|
|
109
|
-
*
|
|
110
|
-
* If the alpha channel is 1, it will be omitted.
|
|
111
|
-
*/
|
|
112
|
-
declare function toHex(channels: ColorChannels): Hex;
|
|
80
|
+
type ChannelRange = number | [min: number, max: number];
|
|
113
81
|
|
|
114
82
|
/**
|
|
115
83
|
* A map of named colors and their HEX values.
|
|
@@ -267,39 +235,42 @@ declare const namedColorsMap: Readonly<{
|
|
|
267
235
|
yellow: "#ffff00ff";
|
|
268
236
|
yellowgreen: "#9acd32ff";
|
|
269
237
|
}>;
|
|
238
|
+
declare const namedColors: Set<"aliceblue" | "antiquewhite" | "aqua" | "aquamarine" | "azure" | "beige" | "bisque" | "black" | "blanchedalmond" | "blue" | "blueviolet" | "brown" | "burlywood" | "cadetblue" | "chartreuse" | "chocolate" | "coral" | "cornflowerblue" | "cornsilk" | "crimson" | "cyan" | "darkblue" | "darkcyan" | "darkgoldenrod" | "darkgray" | "darkgreen" | "darkgrey" | "darkkhaki" | "darkmagenta" | "darkolivegreen" | "darkorange" | "darkorchid" | "darkred" | "darksalmon" | "darkseagreen" | "darkslateblue" | "darkslategray" | "darkslategrey" | "darkturquoise" | "darkviolet" | "deeppink" | "deepskyblue" | "dimgray" | "dimgrey" | "dodgerblue" | "firebrick" | "floralwhite" | "forestgreen" | "fuchsia" | "gainsboro" | "ghostwhite" | "gold" | "goldenrod" | "gray" | "green" | "greenyellow" | "grey" | "honeydew" | "hotpink" | "indianred" | "indigo" | "ivory" | "khaki" | "lavender" | "lavenderblush" | "lawngreen" | "lemonchiffon" | "lightblue" | "lightcoral" | "lightcyan" | "lightgoldenrodyellow" | "lightgray" | "lightgreen" | "lightgrey" | "lightpink" | "lightsalmon" | "lightseagreen" | "lightskyblue" | "lightslategray" | "lightslategrey" | "lightsteelblue" | "lightyellow" | "lime" | "limegreen" | "linen" | "magenta" | "maroon" | "mediumaquamarine" | "mediumblue" | "mediumorchid" | "mediumpurple" | "mediumseagreen" | "mediumslateblue" | "mediumspringgreen" | "mediumturquoise" | "mediumvioletred" | "midnightblue" | "mintcream" | "mistyrose" | "moccasin" | "navajowhite" | "navy" | "oldlace" | "olive" | "olivedrab" | "orange" | "orangered" | "orchid" | "palegoldenrod" | "palegreen" | "paleturquoise" | "palevioletred" | "papayawhip" | "peachpuff" | "peru" | "pink" | "plum" | "powderblue" | "purple" | "rebeccapurple" | "red" | "rosybrown" | "royalblue" | "saddlebrown" | "salmon" | "sandybrown" | "seagreen" | "seashell" | "sienna" | "silver" | "skyblue" | "slateblue" | "slategray" | "slategrey" | "snow" | "springgreen" | "steelblue" | "tan" | "teal" | "thistle" | "tomato" | "transparent" | "turquoise" | "violet" | "wheat" | "white" | "whitesmoke" | "yellow" | "yellowgreen">;
|
|
239
|
+
|
|
270
240
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
* The check is case-sensitive.
|
|
241
|
+
* Returns a boolean indicating whether two named colors are aliases.
|
|
274
242
|
*/
|
|
275
|
-
declare function
|
|
243
|
+
declare function isAliasToNamedColor(name: NamedColor, alias: NamedColor): boolean;
|
|
244
|
+
|
|
245
|
+
/** Returns true if the value is any format of supported color. */
|
|
246
|
+
declare function isColor(value: unknown): value is ColorValue;
|
|
247
|
+
|
|
248
|
+
declare function isColorChannels(value: unknown): value is ColorChannels;
|
|
249
|
+
|
|
276
250
|
/**
|
|
277
|
-
*
|
|
251
|
+
* Whether the input is a valid HEX color. With or without the alpha channel, and with single or double digits.
|
|
278
252
|
*
|
|
279
|
-
*
|
|
253
|
+
* It may or may not start with a hash character, which will be ignored.
|
|
280
254
|
*/
|
|
281
|
-
declare function
|
|
255
|
+
declare function isHex(value: unknown): value is Hex;
|
|
256
|
+
|
|
282
257
|
/**
|
|
283
|
-
*
|
|
258
|
+
* Whether the input is a valid named color.
|
|
259
|
+
*
|
|
260
|
+
* The check is case-insensitive.
|
|
284
261
|
*/
|
|
285
|
-
declare function
|
|
262
|
+
declare function isNamedColor(value: unknown): value is NamedColor;
|
|
263
|
+
|
|
286
264
|
/**
|
|
287
|
-
*
|
|
265
|
+
* Whether the input is a valid RGB color.
|
|
288
266
|
*/
|
|
289
|
-
declare function
|
|
290
|
-
|
|
291
|
-
/** Returns the closest named color to the passed color channels. */
|
|
292
|
-
declare function closestNamedColor(channels: ColorChannels): NamedColor;
|
|
267
|
+
declare function isRgb(value: unknown): value is Rgb;
|
|
268
|
+
|
|
293
269
|
/**
|
|
294
270
|
* Returns all the aliases of a named color.
|
|
295
271
|
*/
|
|
296
272
|
declare function namedColorAliases(name: NamedColor): readonly NamedColor[];
|
|
297
|
-
/**
|
|
298
|
-
* Returns a boolean indicating whether two named colors are aliases.
|
|
299
|
-
*/
|
|
300
|
-
declare function isAliasToNamedColor(name: NamedColor, alias: NamedColor): boolean;
|
|
301
273
|
|
|
302
|
-
type ChannelRange = number | [min: number, max: number];
|
|
303
274
|
/**
|
|
304
275
|
* Generates a random color.
|
|
305
276
|
*
|
|
@@ -315,34 +286,8 @@ declare function random({ r, g, b, a, }?: {
|
|
|
315
286
|
a?: ChannelRange;
|
|
316
287
|
}): ColorChannels;
|
|
317
288
|
|
|
318
|
-
/**
|
|
319
|
-
|
|
320
|
-
*/
|
|
321
|
-
declare function isRgb(value: unknown): value is Rgb;
|
|
322
|
-
/**
|
|
323
|
-
* Whether the input could be a valid RGB color.
|
|
324
|
-
* As in, it checks if the input is an array of numbers without validating the values range.
|
|
325
|
-
*/
|
|
326
|
-
declare function couldBeRgb(value: unknown): value is Rgb;
|
|
327
|
-
/**
|
|
328
|
-
* Parses a RGB tuple into an object of color channels.
|
|
329
|
-
*
|
|
330
|
-
* The input must already be a valid RGB tuple, otherwise the result will be unexpected.
|
|
331
|
-
*/
|
|
332
|
-
declare function parseRgb(value: Rgb): ColorChannels;
|
|
333
|
-
/**
|
|
334
|
-
* Returns the corresponding RGB tuple of a color channels object.
|
|
335
|
-
*/
|
|
336
|
-
declare function toRgb(channels: ColorChannels): Rgb;
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Used to privately store the cached channels of a color.
|
|
340
|
-
*/
|
|
341
|
-
declare const channels: unique symbol;
|
|
342
|
-
/**
|
|
343
|
-
* Used to privately store the cached data of a color.
|
|
344
|
-
*/
|
|
345
|
-
declare const cache: unique symbol;
|
|
289
|
+
/** Returns the color type of the value, or undefined if it's not a color. */
|
|
290
|
+
declare function type(value: unknown): ColorType | undefined;
|
|
346
291
|
|
|
347
292
|
declare class Color {
|
|
348
293
|
protected [channels]: Required<Writable<ColorChannels>>;
|
|
@@ -354,6 +299,7 @@ declare class Color {
|
|
|
354
299
|
static fromRgb(rgb: Rgb): Color;
|
|
355
300
|
static fromHex(hex: string): Color;
|
|
356
301
|
static fromName(name: MaybeNamedColor): Color;
|
|
302
|
+
static parse(value: ColorValue): ColorChannels | undefined;
|
|
357
303
|
static random(presets?: Parameters<typeof random>[0]): Color;
|
|
358
304
|
/**
|
|
359
305
|
* Returns the color type of the passed value, or `undefined` if it's not a color.
|
|
@@ -460,6 +406,7 @@ declare class Color {
|
|
|
460
406
|
distance(color: ColorValue, alpha?: boolean): number;
|
|
461
407
|
/** Returns a new color with the grayscale equivalent of the current color, preserving the alpha channel. */
|
|
462
408
|
toGrayscale(): Color;
|
|
409
|
+
toInvert(): Color;
|
|
463
410
|
toHex(): string;
|
|
464
411
|
toRgb(): Rgb;
|
|
465
412
|
toChannels(): ColorChannels;
|
|
@@ -469,4 +416,4 @@ declare class Color {
|
|
|
469
416
|
toJSON(): string;
|
|
470
417
|
}
|
|
471
418
|
|
|
472
|
-
export {
|
|
419
|
+
export { type ColorChannels as C, type Hex as H, type MaybeNamedColor as M, type NamedColor as N, type Rgb as R, type ChannelRange as a, channels as b, cache as c, namedColorsMap as d, isColor as e, isColorChannels as f, isHex as g, isNamedColor as h, isAliasToNamedColor as i, isRgb as j, namedColorAliases as k, Color as l, type ColorType as m, namedColors as n, type ColorValue as o, random as r, type as t };
|