StackBlur/dist/stackblur.min.js
Brett Zamir af06af0c13 - Breaking change: Remove now deprecated Bower
- Fix: Duck type with image or canvas in place of `instanceof` check (and a broken one)
- Enhancement: Add JSDoc comments
- Linting (ESLint): Add ESLint with "standard" base
- Linting (Markdown): Add `.remarkrc`
- Linting (package.json): Add recommended properties
- Linting (HTML): Add empty favicon to suppress console
- License: Change MIT license file name to reflect license type (MIT)
- Docs: Move changelog to own file: `CHANGES.md`
- Demo: Move demo to own directory (with static server to avoid Chrome security problems reaching out of folder)
- Demo: Move JS and CSS to separate files for easier linting/examination
- Build: Move from Grunt to Rollup, supporting ES6 Modules distribution as well as UMD
- Build: Add npm-recommended `package-lock.json`
- npm: Add start, eslint, rollup, open-docs, docs scripts
- npm: Add `module` for ES6 module discovery and switch `main` to point to `dist`
- npm: Bump to 2.0.0
2018-11-05 22:33:38 +08:00

3 lines
5.9 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.StackBlur={})}(this,function(t){"use strict";const e=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],n=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function r(t,e,n,r,o){if("string"==typeof t&&(t=document.getElementById(t)),!(t&&"getContext"in t))return;const a=t.getContext("2d");try{return a.getImageData(e,n,r,o)}catch(t){throw new Error("unable to access image data: "+t)}}function o(t,e,n,o,i,g){if(isNaN(g)||g<1)return;g|=0;let f=r(t,e,n,o,i);f=a(f,e,n,o,i,g),t.getContext("2d").putImageData(f,e,n)}function a(t,r,o,a,i,g){const u=t.data;let c,s,l,x,d,b,h,m,p,y,w,B,I,C,N,D,R,E,G,v,j,k,A,S;const W=g+g+1,_=a-1,H=i-1,M=g+1,O=M*(M+1)/2,P=new f;let q,z=P;for(l=1;l<W;l++)z=z.next=new f,l===M&&(q=z);z.next=P;let F=null,J=null;h=b=0;const K=e[g],L=n[g];for(s=0;s<i;s++){for(D=R=E=G=m=p=y=w=0,B=M*(v=u[b]),I=M*(j=u[b+1]),C=M*(k=u[b+2]),N=M*(A=u[b+3]),m+=O*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,x=c+((x=s+M)<H?x:H)*a<<2,m+=D+=F.r=u[x],p+=R+=F.g=u[x+1],y+=E+=F.b=u[x+2],w+=G+=F.a=u[x+3],F=F.next,B+=v=J.r,I+=j=J.g,C+=k=J.b,N+=A=J.a,D-=v,R-=j,E-=k,G-=A,J=J.next,b+=a}return t}function i(t,e,n,o,a,i){if(isNaN(i)||i<1)return;i|=0;let f=r(t,e,n,o,a);f=g(f,e,n,o,a,i),t.getContext("2d").putImageData(f,e,n)}function g(t,r,o,a,i,g){const u=t.data;let c,s,l,x,d,b,h,m,p,y,w,B,I,C,N,D,R,E,G,v;const j=g+g+1,k=a-1,A=i-1,S=g+1,W=S*(S+1)/2,_=new f;let H,M=_;for(l=1;l<j;l++)M=M.next=new f,l===S&&(H=M);M.next=_;let O=null,P=null;h=b=0;const q=e[g],z=n[g];for(s=0;s<i;s++){for(C=N=D=m=p=y=0,w=S*(R=u[b]),B=S*(E=u[b+1]),I=S*(G=u[b+2]),m+=W*R,p+=W*E,y+=W*G,M=_,l=0;l<S;l++)M.r=R,M.g=E,M.b=G,M=M.next;for(l=1;l<S;l++)x=b+((k<l?k:l)<<2),m+=(M.r=R=u[x])*(v=S-l),p+=(M.g=E=u[x+1])*v,y+=(M.b=G=u[x+2])*v,C+=R,N+=E,D+=G,M=M.next;for(O=_,P=H,c=0;c<a;c++)u[b]=m*q>>z,u[b+1]=p*q>>z,u[b+2]=y*q>>z,m-=w,p-=B,y-=I,w-=O.r,B-=O.g,I-=O.b,x=h+((x=c+g+1)<k?x:k)<<2,m+=C+=O.r=u[x],p+=N+=O.g=u[x+1],y+=D+=O.b=u[x+2],O=O.next,w+=R=P.r,B+=E=P.g,I+=G=P.b,C-=R,N-=E,D-=G,P=P.next,b+=4;h+=a}for(c=0;c<a;c++){for(N=D=C=p=y=m=0,w=S*(R=u[b=c<<2]),B=S*(E=u[b+1]),I=S*(G=u[b+2]),m+=W*R,p+=W*E,y+=W*G,M=_,l=0;l<S;l++)M.r=R,M.g=E,M.b=G,M=M.next;for(d=a,l=1;l<=g;l++)b=d+c<<2,m+=(M.r=R=u[b])*(v=S-l),p+=(M.g=E=u[b+1])*v,y+=(M.b=G=u[b+2])*v,C+=R,N+=E,D+=G,M=M.next,l<A&&(d+=a);for(b=c,O=_,P=H,s=0;s<i;s++)u[x=b<<2]=m*q>>z,u[x+1]=p*q>>z,u[x+2]=y*q>>z,m-=w,p-=B,y-=I,w-=O.r,B-=O.g,I-=O.b,x=c+((x=s+S)<A?x:A)*a<<2,m+=C+=O.r=u[x],p+=N+=O.g=u[x+1],y+=D+=O.b=u[x+2],O=O.next,w+=R=P.r,B+=E=P.g,I+=G=P.b,C-=R,N-=E,D-=G,P=P.next,b+=a}return t}class f{constructor(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}}t.BlurStack=f,t.image=function(t,e,n,r){if("string"==typeof t&&(t=document.getElementById(t)),!(t&&"naturalWidth"in t))return;const a=t.naturalWidth,g=t.naturalHeight;if("string"==typeof e&&(e=document.getElementById(e)),!(e&&"getContext"in e))return;e.style.width=a+"px",e.style.height=g+"px",e.width=a,e.height=g;const f=e.getContext("2d");f.clearRect(0,0,a,g),f.drawImage(t,0,0),isNaN(n)||n<1||(r?o(e,0,0,a,g,n):i(e,0,0,a,g,n))},t.canvasRGBA=o,t.canvasRGB=i,t.imageDataRGBA=a,t.imageDataRGB=g,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=stackblur.min.js.map