# Find/calculate all points that lay on a border of shape?

Hello

is there a way to find all the points (x,y) that lay on the border of the shape that i’ve drawn?

say i have drawn a simple ellipse: ellipse(x,y,width,height)…given that i know the centre point and the dimensions i must be able to find all border points…but how would that be possible?

thanks!

It’s probably hard to get this for ALL shapes

But for a circle check here: Trigonometry Primer \ Processing.org

I was wondering, since you mention the constraint of using trigonometry for solving for a regular shape, for IRREGULAR shapes would it be possible to solve with edge detection? Provided the contrast along the shape’s edge is strong enough?

1 Like

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 cos/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 loadPixels or get function. Let’s say, you first clear the canvas with white, and set noFill and 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.

1 Like