How to 'paint' a circle on a LED matrix

Status
Not open for further replies.

harald25

Well-known member
Hey!
I've made myself a 5x5 LED matrix.
I'm trying to make an animation that starts in the middle and expands out in a circle.
Could anyone help me get started on the math behind painting a circle on a matrix?
 
I'd use a coordinate system with its center at the center of the 5x5 matrix. Each LED then has x and y coordinates from -2..2

For a radius r do the following:

- Loop over all pixels and calculate rp = x*x + y*y.
- if abs(rp - r*r) < delta switch the LED on.

Play with delta to get "nice" circles.
 
Thank you for your tips!
I ended up using your method luni, with some modifications. I'm pretty happy with the result :)

 
Status
Not open for further replies.
Back
Top