← Back to context

Comment by H3X_K1TT3N

2 days ago

Welp, that took up a chunk of my day. This is as far as I got tricking it into doing webgl (it just renders a triangle):

if(!window.g){gc=document.createElement('canvas');g=gc.getContext('webgl');c.parentNode.replaceChild(gc,c);k=Object.keys(g.__proto__);d='void main(){gl_';str = `g395(g41,g318())g310(g41,new Float32Array([0,0.5,0,-0.5,-0.5,0,0.5,-0.5,0]),g46);a=g322(g139)g382(a,'attribute vec3 c;${d}Position=vec4(c,1);}')g313(a);b=g322(g138)g382(b,'${d}FragColor=vec4(1,0,1,0);}')g313(b);d=g320()g302(d,a)g302(d,b)g376(d)g393(d)g435(0,3,g128,0,0,0)g406(0)g404(g12,0,3)`.replace(/g(\d+)/g,"\ng.\${k[$1]}");eval("eval(`"+str+"`)")}

I assume there are far more advanced methods than what I managed to do, so it's probably possible to actually get that to 140 characters.

Every time I think I couldn't possibly make it smaller, I manage to shave off a few more bytes. Got it under 400 now:

x.arc&&c.parentNode.replaceChild(g=c.cloneNode(),c);x=g.getContext`webgl`;f=Float32Array;eval(`d=320()395(41,318())310(41,new f([0,n=0.5,-n,-n,n,-n]),46)${z='382(a=322(13'}9),'attribute vec2 c;${d='void main(){gl_'}Position=vec4(c${w=",0,1);}')313(a)302(d,a)"}${z}8),'${d}FragColor=vec4(0,1${w}376(d)393(d)435(0,2,128,0,0,0)406(0)404(12,0,3)`.replace(/\d{2,}/g,"\nx[Object.keys(x.__proto__)[$&]]"))

Most of the amazing stuff on dwitter.net is using plain old fillRect

Clever math does the heavy lifting on dwitter.net