-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathautumn.min.js
More file actions
1 lines (1 loc) · 1.99 KB
/
Copy pathautumn.min.js
File metadata and controls
1 lines (1 loc) · 1.99 KB
1
(function(e){var t=false;if(e.hasOwnProperty("husl")){t=true}var n={hsldefault:["hsl",65,95,45,75],superwide:["hsl",30,100,20,90],saturated:["hsl",100,100,40,70],greyscale:["hsl",0,0,15,85]};var r={"default":["husl",90,100,50,85],dark:["husl",80,100,30,60],light:["husl",70,100,60,90],pastel:["huslp",60,100,60,90],wide:["husl",50,100,30,85]};e.extend(n,r);var i={colorProfile:"default",hueCenter:0,hueScale:1,generator:"halton",primeWalkHueDistance:223};if(!t){i.colorProfile="hsldefault"}var s={};s=e.extend(s,i);e.fn.autumn=function(t,n){if(t===undefined){t="backgroundColor"}var r,i;return this.each(function(s,o){i={};if(n===undefined){r=s}else{r=e(this).attr(n)}i[t]=e.fn.autumn.getColor(r);e(this).css(i)})};e.fn.autumn.init=function(t){if(typeof t.colorProfile==="object"){n["user"]=t.colorProfile;t.colorProfile="user"}s=e.extend({},i,t)};e.fn.autumn.getColor=function(e){var t=a(e);return u(t.h,t.s,t.l)};e.fn.autumn.getGradientColors=function(e,t){if(t===undefined){t=30}var n=a(e);return[u(n.h,n.s,Math.min(100,n.l+t/2)),u(n.h,n.s,Math.max(0,n.l-t/2))]};e.fn.autumn.getColorProfiles=function(){return n};var o=function(e){var t=0,n,r;for(r=0;r<e.length;r++){n=e.charCodeAt(r);t=(t<<5)-t+n;t=t&t}return t};var u=function(r,i,o){var u=n[s.colorProfile];if(u[0]==="hsl"||!t){return"hsl("+r+","+i+"%,"+o+"%)"}else if(u[0]==="husl"){return e.husl.toHex(r,i,o)}else if(u[0]==="huslp"){return e.husl.p.toHex(r,i,o)}};var a=function(e){var t,r,i;if(typeof e==="string"){if(!isNaN(e)){e=Number(e)}else{e=o(e)}}if(s.generator==="halton"){if(e<0){e=e>>>0}var u,a,f;var l=[3,5,7];var c=[];for(var h=0;h<l.length;h++){u=0;a=1/l[h];f=e;while(f>0){u=u+a*(f%l[h]);f=Math.floor(f/l[h]);a=a/l[h]}c.push(u)}t=c[0]*360;r=c[1]*100;i=c[2]*100}else{t=e*s.primeWalkHueDistance%359*(360/359);r=e*13%101*(100/101);i=e*19%103*(100/103)}if(t>=180)t-=360;var p=n[s.colorProfile];var d=(t%360*s.hueScale+s.hueCenter)%360;var v=r%100/100*(p[2]-p[1])+p[1];var m=i%100/100*(p[4]-p[3])+p[3];if(d<0)d+=360;if(v<0)v+=100;if(m<0)m+=100;return{h:d,s:v,l:m}}})(jQuery)