-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnaevner-min.js
2 lines (2 loc) · 2.97 KB
/
naevner-min.js
1
2
/*! naevner v1.0.0 | MIT */
const naevner=(e,l="ish")=>{let r,n,a,t,o,g,u,b,c,y,i,w=l;const s=(e,l)=>{var r=l.indexOf("-"),n=parseInt(l.substr(0,r)),a=parseInt(l.substr(r+1));return e>=n&&e<=a};i=/^#.*/g.test(e)?e:"#"+e,r=function(e){let l=0,r=0,n=0;return 4==e.length?(l="0x"+e[1]+e[1],r="0x"+e[2]+e[2],n="0x"+e[3]+e[3]):7==e.length&&(l="0x"+e[1]+e[2],r="0x"+e[3]+e[4],n="0x"+e[5]+e[6]),{r:l,g:r,b:n}}(i),n=function(e,l,r){e/=255,l/=255,r/=255;let n=Math.min(e,l,r),a=Math.max(e,l,r),t=a-n,o=0,g=0,u=0;return o=0==t?0:a==e?(l-r)/t%6:a==l?(r-e)/t+2:(e-l)/t+4,o=Math.round(60*o),o<0&&(o+=360),u=(a+n)/2,g=0==t?0:t/(1-Math.abs(2*u-1)),g=+(100*g).toFixed(1),u=+(100*u).toFixed(1),{h:o,s:g,l:u}}(r.r,r.g,r.b);let d=parseInt(n.h),h=parseInt(n.s),k=parseInt(n.l);return a=null,t=null,o=null,g=null,u=null,b=null,c=null,s(h,"0-0")?b="monochrome":s(h,"1-6")?b="grey":s(h,"7-10")?b=`grey${w}`:s(h,"11-35")?b="faded":s(h,"36-65")?b="calm":s(h,"66-90")?b="clear":s(h,"91-100")&&(b="vibrant"),s(k,"0-5")?a="black":s(k,"6-10")?a="very dark":s(k,"11-35")?a="dark":s(k,"36-65")?a=null:s(k,"66-85")?a="light":s(k,"86-98")?a="very light":s(k,"98-100")&&(a="white"),s(d,"0-3")||s(d,"346-360")?"grey"!==b&&"black"!==a&&(k<20||h<40)?(o="brown",u="red"):k<30||h<50?(o="red",u="brown"):(o="red",u=null):s(d,"4-6")?"grey"!==b&&"black"!==a&&(k<35||h<50)?(o="brown",u="orange"):(o="red",u="orange"):s(d,"7-12")?"grey"!==b&&"black"!==a&&(k<35||h<50)?(o="brown",u="orange"):k<40&&h<90||k<45&&h<70?(o="orange",u="brown"):(o="orange",u="red"):s(d,"13-35")?"grey"!==b&&"black"!==a&&(k<35||h<50)?(o="brown",u="orange"):k<40&&h<90||k<45&&h<70?(o="orange",u="brown"):(o="orange",u=null):s(d,"36-42")?"grey"!==b&&"black"!==a&&k<50||h<70?(o="brown",u="olive"):(o="orange",u="yellow"):s(d,"43-46")?"grey"!==b&&"black"!==a&&(k<50||h<70)?(o="olive",u="brown"):(o="yellow",u="orange"):s(d,"47-61")?"grey"!==b&&"black"!==a&&(k<50||h<70)?(o="olive",u=null):(o="yellow",u=null):s(d,"62-67")?"grey"!==b&&"black"!==a&&(k<50||h<70)?(o="olive",u="green"):(o="yellow",u="green"):s(d,"68-74")?"grey"!==b&&"black"!==a&&(k<50||h<70)?(o="green",u="olive"):(o="green",u="yellow"):s(d,"75-147")?(o="green",u=null):s(d,"148-157")?(o="green",u="turquoise"):s(d,"158-172")?(o="turquoise",u=null):s(d,"173-193")?(o="cyan",u=null):s(d,"194-201")?(o="cyan",u="blue"):s(d,"202-211")?(o="blue",u="cyan"):s(d,"212-255")?(o="blue",u=null):s(d,"256-258")?(o="blue",u="purple"):s(d,"259-265")?(o="purple",u="blue"):s(d,"266-280")?(o="purple",u=null):s(d,"281-287")?(o="purple",u="magenta"):s(d,"288-298")?(o="magenta",u="purple"):s(d,"299-316")?(o="magenta",u=null):s(d,"317-337")?"grey"!==b&&"black"!==a&&(k<30||h<40)?(o="magenta",u="brown"):(o="magenta",u="red"):s(d,"338-345")&&("grey"!==b&&"black"!==a&&(k<35||h<50)?(o="brown",u="magenta"):(o="red",u="magenta")),t=a?a+", ":"",c=u?b+", ":b+" ",g=u?u+w+" "+o:o,"monochrome"==b?"black"==a||"white"==a?y=`${a}`:(a||(a=""),y=`${a} grey`):y="black"==a?`${o}-tinted black`:"white"==a?`${o}-tinted off-white`:"grey"==b?`${t}${o}${w} ${b}`:`${t}${c}${g}`,y};