suyuan/public/admin/assets/color-convert.755d189f.js

2 lines
10 KiB
JavaScript
Raw Normal View History

2023-11-21 11:51:27 +08:00
import{c as k}from"./color-name.e7a4e1d3.js";var y={exports:{}},b=k,m={};for(var M in b)b.hasOwnProperty(M)&&(m[b[M]]=M);var s=y.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var o in s)if(s.hasOwnProperty(o)){if(!("channels"in s[o]))throw new Error("missing channels property: "+o);if(!("labels"in s[o]))throw new Error("missing channel labels property: "+o);if(s[o].labels.length!==s[o].channels)throw new Error("channel and label counts mismatch: "+o);var d=s[o].channels,F=s[o].labels;delete s[o].channels,delete s[o].labels,Object.defineProperty(s[o],"channels",{value:d}),Object.defineProperty(s[o],"labels",{value:F})}s.rgb.hsl=function(r){var e=r[0]/255,n=r[1]/255,a=r[2]/255,t=Math.min(e,n,a),v=Math.max(e,n,a),i=v-t,u,c,h;return v===t?u=0:e===v?u=(n-a)/i:n===v?u=2+(a-e)/i:a===v&&(u=4+(e-n)/i),u=Math.min(u*60,360),u<0&&(u+=360),h=(t+v)/2,v===t?c=0:h<=.5?c=i/(v+t):c=i/(2-v-t),[u,c*100,h*100]};s.rgb.hsv=function(r){var e,n,a,t,v,i=r[0]/255,u=r[1]/255,c=r[2]/255,h=Math.max(i,u,c),f=h-Math.min(i,u,c),l=function(x){return(h-x)/6/f+1/2};return f===0?t=v=0:(v=f/h,e=l(i),n=l(u),a=l(c),i===h?t=a-n:u===h?t=1/3+e-a:c===h&&(t=2/3+n-e),t<0?t+=1:t>1&&(t-=1)),[t*360,v*100,h*100]};s.rgb.hwb=function(r){var e=r[0],n=r[1],a=r[2],t=s.rgb.hsl(r)[0],v=1/255*Math.min(e,Math.min(n,a));return a=1-1/255*Math.max(e,Math.max(n,a)),[t,v*100,a*100]};s.rgb.cmyk=function(r){var e=r[0]/255,n=r[1]/255,a=r[2]/255,t,v,i,u;return u=Math.min(1-e,1-n,1-a),t=(1-e-u)/(1-u)||0,v=(1-n-u)/(1-u)||0,i=(1-a-u)/(1-u)||0,[t*100,v*100,i*100,u*100]};function O(r,e){return Math.pow(r[0]-e[0],2)+Math.pow(r[1]-e[1],2)+Math.pow(r[2]-e[2],2)}s.rgb.keyword=function(r){var e=m[r];if(e)return e;var n=1/0,a;for(var t in b)if(b.hasOwnProperty(t)){var v=b[t],i=O(r,v);i<n&&(n=i,a=t)}return a};s.keyword.rgb=function(r){return b[r]};s.rgb.xyz=function(r){var e=r[0]/255,n=r[1]/255,a=r[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var t=e*.4124+n*.3576+a*.1805,v=e*.2126+n*.7152+a*.0722,i=e*.0193+n*.1192+a*.9505;return[t*100,v*100,i*100]};s.rgb.lab=function(r){var e=s.rgb.xyz(r),n=e[0],a=e[1],t=e[2],v,i,u;return n/=95.047,a/=100,t/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,t=t>.008856?Math.pow(t,1/3):7.787*t+16/116,v=116*a-16,i=500*(n-a),u=200*(a-t),[v,i,u]};s.hsl.rgb=function(r){var e=r[0]/360,n=r[1]/100,a=r[2]/100,t,v,i,u,c;if(n===0)return c=a*255,[c,c,c];a<.5?v=a*(1+n):v=a+n-a*n,t=2*a-v,u=[0,0,0];for(var h=0;h<3;h++)i=e+1/3*-(h-1),i<0&&i++,i>1&&i--,6*i<1?c=t+(v-t)*6*i:2*i<1?c=v:3*i<2?c=t+(v-t)*(2/3-i)*6:c=t,u[h]=c*255;return u};s.hsl.hsv=function(r){var e=r[0],n=r[1]/100,a=r[2]/100,t=n,v=Math.max(a,.01),i,u;return a*=2,n*=a<=1?a:2-a,t*=v<=1?v:2-v,u=(a+n)/2,i=a===0?2*t/(v+t):2*n/(a+n),[e,i*100,u*100]};s.hsv.rgb=function(r){var e=r[0]/60,n=r[1]/100,a=r[2]/100,t=Math.floor(e)%6,v=e-Math.floor(e),i=255*a*(1-n),u=255*a*(1-n*v),c=255*a*(1-n*(1-v));switch(a*=255,t){case 0:return[a,c,i];case 1:return[u,a,i];case 2:return[i,a,c];case 3:return[i,u,a];case 4:return[c,i,a];case 5:return[a,i,u]}};s.hsv.hsl=function(r){var e=r[0],n=r[1]/100,a=r[2]/100,t=Math.max(a,.01),v,i,u;return u=(2-n)*a,v=(2-n)*t,i=n*t,i/=v<=1?v:2-v,i=i||0,u/=2,[e,i*100,u*100]};s.hwb.rgb=function(r){var e=r[0]/360,n=r[1]/100,a=r[2]/100,t=n+a,v,i,u,c;t>1&&(n/=t,a/=t),v=Math.floor(6*e),i=1-a,u=6*e-v,(v&1)!==0&&(u=1-u),c=n+u*(i-n);var h,f,l;switch(v){default:case 6:case 0:h=i,f=c,l=n;break;case 1:h=c,f=i,l=n;break;case 2:h=n,f=i,l=c;break;case 3:h=n,f=c,l=i;break;case 4:h=c,f=n,l=i;break;case 5:h=i,f=n,l=c