2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
|
function s(r,t){F(r)&&(r="100%");var e=I(r);return r=t===360?r:Math.min(t,Math.max(0,parseFloat(r))),e&&(r=parseInt(String(r*t),10)/100),Math.abs(r-t)<1e-6?1:(t===360?r=(r<0?r%t+t:r%t)/parseFloat(String(t)):r=r%t/parseFloat(String(t)),r)}function v(r){return Math.min(1,Math.max(0,r))}function F(r){return typeof r=="string"&&r.indexOf(".")!==-1&&parseFloat(r)===1}function I(r){return typeof r=="string"&&r.indexOf("%")!==-1}function A(r){return r=parseFloat(r),(isNaN(r)||r<0||r>1)&&(r=1),r}function p(r){return r<=1?"".concat(Number(r)*100,"%"):r}function b(r){return r.length===1?"0"+r:String(r)}function E(r,t,e){return{r:s(r,255)*255,g:s(t,255)*255,b:s(e,255)*255}}function M(r,t,e){r=s(r,255),t=s(t,255),e=s(e,255);var a=Math.max(r,t,e),n=Math.min(r,t,e),i=0,f=0,h=(a+n)/2;if(a===n)f=0,i=0;else{var u=a-n;switch(f=h>.5?u/(2-a-n):u/(a+n),a){case r:i=(t-e)/u+(t<e?6:0);break;case t:i=(e-r)/u+2;break;case e:i=(r-t)/u+4;break}i/=6}return{h:i,s:f,l:h}}function l(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*(6*e):e<1/2?t:e<2/3?r+(t-r)*(2/3-e)*6:r}function B(r,t,e){var a,n,i;if(r=s(r,360),t=s(t,100),e=s(e,100),t===0)n=e,i=e,a=e;else{var f=e<.5?e*(1+t):e+t-e*t,h=2*e-f;a=l(h,f,r+1/3),n=l(h,f,r),i=l(h,f,r-1/3)}return{r:a*255,g:n*255,b:i*255}}function S(r,t,e){r=s(r,255),t=s(t,255),e=s(e,255);var a=Math.max(r,t,e),n=Math.min(r,t,e),i=0,f=a,h=a-n,u=a===0?0:h/a;if(a===n)i=0;else{switch(a){case r:i=(t-e)/h+(t<e?6:0);break;case t:i=(e-r)/h+2;break;case e:i=(r-t)/h+4;break}i/=6}return{h:i,s:u,v:f}}function N(r,t,e){r=s(r,360)*6,t=s(t,100),e=s(e,100);var a=Math.floor(r),n=r-a,i=e*(1-t),f=e*(1-n*t),h=e*(1-(1-n)*t),u=a%6,H=[e,f,i,i,h,e][u],R=[h,e,e,f,i,i][u],T=[i,i,h,e,e,f][u];return{r:H*255,g:R*255,b:T*255}}function w(r,t,e,a){var n=[b(Math.round(r).toString(16)),b(Math.round(t).toString(16)),b(Math.round(e).toString(16))];return a&&n[0].startsWith(n[0].charAt(1))&&n[1].startsWith(n[1].charAt(1))&&n[2].startsWith(n[2].charAt(1))?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function P(r,t,e,a,n){var i=[b(Math.round(r).toString(16)),b(Math.round(t).toString(16)),b(Math.round(e).toString(16)),b(j(a))];return n&&i[0].startsWith(i[0].charAt(1))&&i[1].startsWith(i[1].charAt(1))&&i[2].startsWith(i[2].charAt(1))&&i[3].startsWith(i[3].charAt(1))?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0)+i[3].charAt(0):i.join("")}function j(r){return Math.round(parseFloat(r)*255).toString(16)}function k(r){return o(r)/255}function o(r){return parseInt(r,16)}function O(r){return{r:r>>16,g:(r&65280)>>8,b:r&255}}var x={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",goldenrod:"#daa520",gold:"#ffd700",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavenderblush:"#fff0f5",lavender:"#e6e6fa",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",li
|