02 Drawing shapes with math
length: distance makes a circle
Closer to the centre than the radius means inside the circle.
01
01
0.030.45
ExerciseTune values
Put a small circle at the top left
Runs once per pixelDrag numbers, or edit the code
JS side
gl.uniform2f(uResolution, …, …)length(p − center) is the distance to the centre; if it is less than the radius, you are inside.
Try it
- Move the circle to the top left
- Open the pixel debugger: is d exactly the radius on the edge?