PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 All 36 releases
desktop-mode / assets / js / animated-logo-wallpaper.min.js

animated-logo-wallpaper.min.js in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.12, at assets/js/animated-logo-wallpaper.min.js

2 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(){"use strict";const g={sampleStride:7,alphaThreshold:128,targetLogoWidth:1e3,logoShellFraction:.72,spriteReferenceWidth:700,springK:.015,damping:.86,restVelocityEpsilon:.02,dragRadius:150,dragStrength:.22,dragBoost:.3,dragBoostRefSpeed:40,maxMouseDelta:80,brushSize:128,spriteScaleMin:.1,spriteScaleMax:.26,spriteAlphaMin:.55,spriteAlphaMax:.92},X=[16726843,16726843,16747562,16747562,16767293,16767293,5036388,5036388,4104447,4104447,11037695,11037695,16757703,8380415,16777215,13140042],K="radial-gradient(circle at 50% 50%, #1e40af 0%, #152a6b 45%, #0a1024 100%)";async function $({container:s,logoUrl:r,prefersReducedMotion:l}){const t=window.PIXI;if(!t)throw new Error("[animated-logo-wallpaper] window.PIXI is undefined; declare `needs: ['pixijs']` on the wallpaper def so the shell loads it before mount.");const e=await _(r),c=s.style.background;s.style.background=K;const o=new t.Application;await o.init({resizeTo:s,backgroundAlpha:0,antialias:!0,autoDensity:!0,resolution:Math.min(window.devicePixelRatio||1,2)}),s.appendChild(o.canvas),G(o.canvas);const f=Y(t),v=new t.Container;o.stage.addChild(v);const a=e.length,h=new Float32Array(a),M=new Float32Array(a),w=new Float32Array(a),m=new Float32Array(a),b=new Float32Array(a),C=new Float32Array(a),y=new Array(a),P=new Float32Array(a);for(let i=0;i<a;i++){const p=new t.Sprite(f);p.anchor.set(.5),p.blendMode="add",p.tint=X[Math.floor(Math.random()*X.length)];const u=g.spriteScaleMin+Math.random()*(g.spriteScaleMax-g.spriteScaleMin);P[i]=u,p.scale.set(u),p.alpha=g.spriteAlphaMin+Math.random()*(g.spriteAlphaMax-g.spriteAlphaMin),v.addChild(p),y[i]=p}let I=1,B=0,O=0;const q=()=>{const i=o.canvas.clientWidth,p=o.canvas.clientHeight,u=Math.min(g.targetLogoWidth,Math.min(i,p)*g.logoShellFraction);I=u,B=(i-u)/2,O=(p-u)/2;const S=Math.min(1,u/g.spriteReferenceWidth);for(let d=0;d<a;d++)y[d].scale.set(P[d]*S),h[d]=B+e[d][0]*I,M[d]=O+e[d][1]*I,w[d]===0&&m[d]===0&&(w[d]=h[d],m[d]=M[d])};q();const V=new ResizeObserver(()=>q());V.observe(s);let A=-1e6,L=-1e6,x=!1,F=0,n=0;const k=i=>{const p=o.canvas.getBoundingClientRect(),u=i.clientX-p.left,S=i.clientY-p.top;if(x){const d=u-A,H=S-L,R=g.maxMouseDelta;F+=Math.max(-R,Math.min(R,d)),n+=Math.max(-R,Math.min(R,H))}A=u,L=S,x=!0},W=()=>{A=-1e6,L=-1e6,x=!1,F=0,n=0};window.addEventListener("pointermove",k,{passive:!0}),window.addEventListener("pointerleave",W);let E=!l;const T=()=>{for(let i=0;i<a;i++)y[i].x=w[i],y[i].y=m[i]},z=()=>{E&&U(a,h,M,w,m,b,C,A,L,x?F:0,x?n:0),F=0,n=0,T()};return o.ticker.add(z),T(),E||(o.renderer.render(o.stage),o.ticker.stop()),{destroy(){V.disconnect(),window.removeEventListener("pointermove",k),window.removeEventListener("pointerleave",W),o.destroy({removeView:!0},{children:!0,texture:!0,textureSource:!0,context:!0});try{f.destroy(!0)}catch{}s.style.background=c},setAnimating(i){E=i&&!l,E?o.ticker.start():o.ticker.stop()}}}function U(s,r,l,t,e,c,o,f,v,a,h){const{springK:M,damping:w,dragRadius:m,dragStrength:b,dragBoost:C,dragBoostRefSpeed:y,restVelocityEpsilon:P}=g,I=m*m,B=P*P,O=.25,q=O*O,A=1+Math.sqrt(a*a+h*h)/y*C,L=a*b*A,x=h*b*A,F=a!==0||h!==0;for(let n=0;n<s;n++){const k=r[n]-t[n],W=l[n]-e[n];let E=k*M,T=W*M;const z=t[n]-f,i=e[n]-v,p=z*z+i*i;let u=!1;if(F&&p<I){const H=1-Math.sqrt(p)/m,R=H*H;E+=L*R,T+=x*R,u=!0}const S=(c[n]+E)*w,d=(o[n]+T)*w;if(!u&&S*S+d*d<B&&k*k+W*W<q){t[n]=r[n],e[n]=l[n],c[n]=0,o[n]=0;continue}c[n]=S,o[n]=d,t[n]+=S,e[n]+=d}}function Y(s){const r=g.brushSize,l=document.createElement("canvas");l.width=r,l.height=r;const t=l.getContext("2d");if(!t)throw new Error("[animated-logo-wallpaper] 2D canvas context unavailable.");const e=r/2,c=t.createRadialGradient(e,e,0,e,e,e);return c.addColorStop(0,"rgba(255, 255, 255, 1)"),c.addColorStop(.18,"rgba(255, 255, 255, 0.85)"),c.addColorStop(.42,"rgba(255, 255, 255, 0.28)"),c.addColorStop(.75,"rgba(255, 255, 255, 0.06)"),c.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=c,t.fillRect(0,0,r,r),s.Texture.from(l)}async function _(s){const r=await j(s),l=400,t=r.naturalWidth/r.naturalHeight,e=t>=1?l:Math.round(l*t),c=t>=1?Math.round(l/t):l,o=document.createElement("canvas");o.width=e,o.height=c;const f=o.getContext("2d",{willReadFrequently:!0});if(!f)return[];f.drawImage(r,0,0,e,c);const v=f.getImageData(0,0,e,c).data,a=[],h=g.sampleStride,M=g.alphaThreshold;for(let w=0;w<c;w+=h){const m=w/h%2===0?0:h/2;for(let b=0;b<e;b+=h){const C=Math.min(e-1,Math.round(b+m)),y=w;v[(y*e+C)*4+3]>M&&a.push([C/e,y/c])}}return a}function j(s){return new Promise((r,l)=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>r(t),t.onerror=()=>l(new Error(`Failed to load logo: ${s}`)),t.src=s})}function G(s){s.style.display="block",s.style.width="100%",s.style.height="100%"}const D="wp-animated-logo",N={id:D,label:"Animated WordPress Logo",type:"canvas",preview:"radial-gradient(circle at 50% 50%, #1e3a8a 0%, #0b0f25 100%)",renderPreview:async(s,r)=>{const l=await $({container:s,logoUrl:`${r.pluginUrl}/assets/images/wp-logo.png`,prefersReducedMotion:r.prefersReducedMotion});return()=>l.destroy()},needs:["pixijs"],mount:async(s,r)=>{const l=`${r.pluginUrl}/assets/images/wp-logo.png`,t=await $({container:s,logoUrl:l,prefersReducedMotion:r.prefersReducedMotion}),e="desktop-mode/animated-logo",c="os.wallpaper.visibility",o=window.wp?.os,f=(...v)=>{const a=v[0];!a||a.id!==D||t.setAnimating(a.state==="visible")};return o?.hooks?.addAction(c,`${e}/visibility`,f),()=>{o?.hooks?.removeAction(c,`${e}/visibility`),t.destroy()}}};window.openStationWallpapers=window.openStationWallpapers||{},window.openStationWallpapers[D]=N})();
2