最后活跃于 1731690498

snakey.js 原始文件
1Shader.AA_CIRCLE ??= Shader(`void main(){
2 float l = .5-length(uv-.5);
3 float op = clamp(l/fwidth(l)+.5, 0., 1.);
4 color = arg0()*op;
5}`, COLOR)
6const circles = new Float32Array(20).fill(NaN)
7render = () => {
8 ctx.reset(pixelRatio/ctx.width, 0, 0, pixelRatio/ctx.height, .5, .5)
9 let {x, y} = ctx.from(cursor)
10 ctx.shader = Shader.AA_CIRCLE
11 let r = 50
12 ctx.drawRect(x-r, y-r, r*2, r*2, vec4(.5))
13 for(let i = 0; i < circles.length; i += 2){
14 const r2 = r+(r*=.9)
15 let px = circles[i] - x, py = circles[i+1] - y
16 const d = r2/hypot(px, py)
17 if(!d) px = 0, py = r2 // catch NaN
18 else px *= d, py *= d
19 circles[i] = x += px
20 circles[i+1] = y += py
21 ctx.drawRect(x-r, y-r, r*2, r*2, vec4(r*.01))
22 }
23}