Finding all the pixels is quite tricky even for a circle. A circle can be represented by
x^2 + y^2 = r^2 or with
sin but if you look at pixels, they are quantized and quite arbitrary…
If you don’t care about the framerate, you can first draw on the screen or p5.Graphics/PGraphics and then search for every pixel using
get function. Let’s say, you first clear the canvas with white, and set
stroke(0), all the border pixels are supposed to be black color.
However, there is smoothing (antialiasing) that result in a color between black and white. You need to threshold the color in that case (for example, if it’s bigger than or smaller than 128), but the choice of the threshold will affect the “thickness” of the collection of points.