PageSourceSearch

https://portfolio.gateaux-09suntan.workers.dev/shader-base.js?v=1

js portfolio.gateaux-09suntan.workers.dev collected 2026-10-03 08:09:26 UTC 5,206 bytes, 1 lines download raw bytes

1import{ShaderMount as W,simplexNoiseFragmentShader as X}from"./vendor/paper-shaders-0.0.76.min.js";export{W as ShaderMount};export function oklch(e,o,t,n=1){const a=t*Math.PI/180,r=o*Math.cos(a),d=o*Math.sin(a),f=e+.3963377774*r+.2158037573*d,h=e-.1055613458*r-.0638541728*d,p=e-.0894841775*r-1.291485548*d,s=f*f*f,c=h*h*h,m=p*p*p;let g=4.0767416621*s-3.3077115913*c+.2309699292*m,S=-1.2684380046*s+2.6097574011*c-.3413193965*m,M=-.0041960863*s-.7034186147*c+1.707614701*m;const E=w=>(w=Math.max(0,Math.min(1,w)),w<=.0031308?w*12.92:1.055*Math.pow(w,1/2.4)-.055);return[E(g),E(S),E(M),n]}const $=typeof window<"u"&&window.devicePixelRatio||1;export const SHADER_MAX_PIXELS=Math.round(Math.min(1e6*$*$,1e6));const Y=1.5,j={mobile:1.5,tablet:2,desktop:3},z={mobile:2,tablet:3,desktop:4},H=typeof window<"u"?matchMedia("(max-width: 809px)"):null,q=typeof window<"u"?matchMedia("(min-width: 810px) and (max-width: 1199px)"):null;function P(){return H?.matches?"mobile":q?.matches?"tablet":"desktop"}export function getCardScale(){return j[P()]}export function getHeroScale(){return z[P()]}export function getHeroSpeed(){return Y*(getCardScale()/getHeroScale())}function N(){typeof globalThis<"u"&&(globalThis.SHADER_ANIM_SPEED=getHeroSpeed())}N();const B=new Set;let O=P();function V(){const e=P();e!==O&&(O=e,N(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("shader-speed-change")),B.forEach(o=>{try{o()}catch{}}))}H?.addEventListener("change",V),q?.addEventListener("change",V);export function onBreakpointChange(e){return B.add(e),()=>B.delete(e)}export const siteFragmentShader=X;const G={"gradient-wren":0};export function shaderFrameOffset(e){if(e in G)return G[e];let o=2166136261;for(let t=0;t<e.length;t++)o^=e.charCodeAt(t),o=Math.imul(o,16777619);return(o>>>0)%1e6}export function createShaderUniforms(){return{u_scale:getCardScale(),u_stepsPerColor:1,u_softness:1}}const U=()=>{if(typeof location<"u"){const e=new URLSearchParams(location.search);if(e.has("dark"))return!0;if(e.has("light"))return!1}if(typeof document<"u"){const e=document.documentElement.getAttribute("data-theme");if(e==="dark")return!0;if(e==="light")return!1}return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches};export function cardBg(){return U()?oklch(.1,0,0):oklch(1,0,0)}export function brandColor(e,o,t,n=1){return U()?e>.95?oklch(.12,0,0,n):oklch(.3,Math.min(o*1.4,.1),t,n):oklch(e,o,t,n)}export function buildShaderColors({brand:e,transition:o=[],bg:t}){if(e.length===1){const a=o.length+1;return[...Array(a).fill(e[0]),...o,t]}const n=e.length;return[...e,...e,...o,...Array(n).fill(t)]}
1export function averageColor(e){let o=0,t=0,n=0;for(const r of e)o+=r[0],t+=r[1],n+=r[2];const a=e.length||1;return`rgb(${Math.round(o/a*255)} ${Math.round(t/a*255)} ${Math.round(n/a*255)})`}export function createShaderVisibilityGate(e,o,t){let n=!0,a=!1;const r=()=>o.setSpeed(n&&!a?t():0);return new IntersectionObserver(([d])=>{n=d.isIntersecting,r()},{rootMargin:"100% 0px"}).observe(e),window.addEventListener("site:pause-shaders",()=>{a=!0,r()}),window.addEventListener("site:resume-shaders",()=>{a=!1,r()}),{get visible(){return n},apply:r}}export function createFadeColorSampler(e,o,t={}){const n=t.sampleBaseMs??1500,a=t.tweenBaseMs??1500,r=t.refSpeed??1.125,d=t.getSpeed??(()=>r),f=()=>Math.min(3,r/(d()||r)),h=()=>Math.max(500,n*f()),p=()=>Math.max(500,a*f());let s=null,c=null,m="",g=0,S=0,M=0;const E=u=>{const i=`${Math.round(u[0])} ${Math.round(u[1])} ${Math.round(u[2])}`;m!==i&&(m=i,o.style.setProperty("--card-fade-color",`rgb(${i})`),o.style.setProperty("--card-fade-color-0",`rgb(${i} / 0)`))},w=()=>{const u=o.style.getPropertyValue("--card-fade-color"),i=u&&u.match(/[\d.]+/g);return i&&i.length>=3?[+i[0],+i[1],+i[2]]:null},C=u=>{const i=S?u-S:16;S=u;const b=1-Math.exp(-i/p());s||(s=c.slice());let _=!1,A=!1;for(let l=0;l<3;l++){const y=c[l]-s[l];if(Math.abs(y)<.3){s[l]=c[l];continue}s[l]+=y*b,_=!0,A=!0}(_||!m)&&E(s),g=A?requestAnimationFrame(C):(S=0,0)},R=u=>{const i=e&&e.gl;if(!i)return;const b=i.drawingBufferWidth,_=i.drawingBufferHeight;if(!b||!_||!e.program)return;e.render(performance.now());const A=Math.max(1,Math.round(_*.06)),l=new Uint8Array(b*A*4);if(i.isContextLost())return;i.readPixels(0,0,b,A,i.RGBA,i.UNSIGNED_BYTE,l);let y=0,I=0,T=0,v=0;for(let x=0;x<l.length;x+=4){const L=l[x+3];if(L<8)continue;const k=255/L;y+=l[x]*k,I+=l[x+1]*k,T+=l[x+2]*k,v++}if(v){if(c=[y/v,I/v,T/v],u){s=c.slice(),m="",E(c);return}s||(s=w()||c.slice()),g||(S=0,g=requestAnimationFrame(C))}},F=()=>!document.hidden&&(!t.isVisible||t.isVisible()),D=()=>{F()&&R(!1),M=setTimeout(D,h())};return{start(){M||(F()&&R(!1),M=setTimeout(D,h()))},snap(){R(!0)},stop(){clearTimeout(M),M=0,g&&cancelAnimationFrame(g),g=0}}}const J=1200;export function createSpeedRamp(e,o=0){let t=o,n=0;const a=r=>r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2;return{get current(){return t},snap(r){n&&cancelAnimationFrame(n),n=0,t=r,e.setSpeed(r)},ramp(r,d=J){if(n&&cancelAnimationFrame(n),t===r){n=0;return}const f=t,h=performance.now(),p=s=>{const c=Math.min(1,(s-h)/d);t=f+(r-f)*a(c),e.setSpeed(t),c<1?n=requestAnimationFrame(p):n=0};n=requestAnimationFrame(p)},cancel(){n&&cancelAnimationFrame(n),n=0}}}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.