top | item 39686944

(no title)

sflanker | 1 year ago

Here's a p5js sketch using WEBGL to do something similar. Not as flexible as the shadertoy, but arguably simpler to interact with: https://openprocessing.org/sketch/2203876

discuss

order

sflanker|1 year ago

If somebody can explain why bitwise ands generate serpinski triangles I would sure like to know.

(y * 4 & x *4) % (frameCount / 10 % 300)

sflanker|1 year ago

Oh duh, this is inherent in binary counting. When y is equal to one any even x will be a zero. The when y is equal to 2 you get groups of zeros two at a time 0, 1; 4, 5; 8, 9; etc. The pattern repeats in lengthening, self similar way as the values of y increase leaving ever lager gaps and sequences of zeros (with the top edges of the triangles corresponding to powers of two, which give long sequences of zeros or non zeros respectively.

I always think of this pattern geometrically so it’s weird to see it pop out in simple math.