Skip to content

Instantly share code, notes, and snippets.

View literallylara's full-sized avatar
✌️

Lara Schütt literallylara

✌️
View GitHub Profile
// More info on the boilerplate at https://xem.github.io/articles/#webgl_quest
<canvas style=width:512px;height:512px id=a><svg onload='for(i in g=a.getContext`webgl`)g[i[0]+i[6]]=g[i];with(g)vA(P=cP(),2,5120,bD(B=ET-3,Int8Array.of(B,setInterval(x=>dr(6,vertexAttrib1f(1,NO+=.01),3),A=s=>sS(S=cS(FN++),s)|ce(S)|aS(P,S)),!A(`${V="precision lowp float;varying vec4 C,U;mat2 rot(float a){float c=cos(a),s=sin(a);return mat2(c,-s,s,c);}void main(){"}vec3 c=vec3(0),p,q;float t=0.,d,e,f,j,T=U.x;for(float i=0.;i<99.;i++){p=vec3(C.xy*3.,t-3.);q=p;q.yz*=rot(T-.8);q.xy*=rot(T-.6);e=max(length(q.xz)-.15,abs(q.y)-2.);q=p;q.xz*=rot(.8);q.yz*=rot(.6);f=length(vec2(length(q.xy)-2.,q.z))-.1;q=p;q.xz*=rot(-.8);q.yz*=rot(.6);f=min(f,length(vec2(length(q.xy)-2.,q.z))-.1);d=min(e,f);t+=d;if(d<.01){c=vec3(1.3-step(length(p),1.));j=i;break;}}gl_FragColor=vec4(c-t*j/50.,1);}`),B,!eV(bf(B,cB())),!A(`attribute vec4 A,B;${V}gl_Position=C=A;U=B;}`)),B+82),lo(P),ug(P))'>
/**
* RIFF WAVE PCM file generator
* Reference: www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
*
* @author Lara Sophie Schütt (@literallylara)
* @license CC0
*/
const DUR = 5 // duration in seconds
const NCH = 1 // number of channels