Skip to content

Instantly share code, notes, and snippets.

@literallylara
Last active January 23, 2017 14:23
Show Gist options
  • Save literallylara/43844c6621be811211bf5da8305c196c to your computer and use it in GitHub Desktop.
Save literallylara/43844c6621be811211bf5da8305c196c to your computer and use it in GitHub Desktop.
// 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))'>
@literallylara
Copy link
Author

795b

<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="varying lowp vec4 C,U;\n#define R(a)mat2(cos(a),-sin(a),sin(a),cos(a))\n#define D length(vec2(length(q.xy)-2.,q.z))-.1\nvoid main(){"}lowp float t=0.,d,e,f;for(int i=0;i<99;i++){lowp vec3 p=vec3(C.xy*3.,t-3.),q=p;q.yz*=R(U.x-.8);q.xy*=R(U.x-.6);e=max(length(q.xz)-.15,abs(q.y)-2.);q=p;q.xz*=R(.8);q.yz*=R(.6);f=D;q=p;q.xz*=R(-.8);q.yz*=R(.6);f=min(f,D);d=min(e,f);t+=d;if(d<.01){d=1.5-step(length(p),1.)-float(i)/5.;break;}}gl_FragColor=vec4(d,d,d,1);}`),B,!eV(bf(B,cB())),!A(`attribute vec4 A,B;${V}gl_Position=C=A;U=B;}`)),B+82),lo(P),ug(P))'>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment