nice and super simple for you fastled legends!
using an xy matrix (without other libraries) how do i draw a circle.
i can find a point, x,y and i know the radius.
but what do i do to get a circle shape.
and i know that some of the swirly patterns are created with sin / cos functions, but how would i go around making some of these patterns;
im not looking for direct solutions! just hints of how these are put together!
(although i’d never say no to an example
)
ps apologies for the music in the video… i’d recommend the mute :-0
I’d recommend Aaron Liddiment’s LEDMatrix library: https://github.com/AaronLiddiment/LEDMatrix
But if you really don’t want to use other libraries, here’s Bresenham’s circle algorithm: https://en.wikipedia.org/wiki/Midpoint_circle_algorithm#C_Example
Yeah, Aaron’s matrix code doesn’t seem compatible with my setup. I’ve tried for hours jostling the numbers around.
The other code has pushed me a new direction though… Not as pretty as I was hoping, but kinda manageable.
x & y are the origin x & y
r is the radius in leds
theta is counting variable, i could probably use millis()
posX = x+rcos(theta);
posY = y+rsin(theta);
theta++;
leds[matrix54[posY][posX]] = CRGB::Blue;
if (theta==255) {theta=0}; // to stop any overflow issues
it kinda mostly works, the initial “circle” is an offset square, but the idea is right!
plasma… plasma is the search term i more require for the swirly patterns!
This is my quite primitive code for a growing and shrinking circle in an XY matrix:
void pulsingMinimalist() {
int x0 = kMatrixWidth/2;
int y0 = kMatrixHeight/2;
int radius = beatsin8(bpm/2, 0, kMatrixHeight/2);
int x = radius;
int y = 0;
int decisionOver2 = 1 - x; // Decision criterion divided by 2 evaluated at x=r, y=0
int colorHue = beatsin8(bpm*2, 107, 167);
CRGB color1 = ColorFromPalette( currentPalette, colorHue, 255);
if (radius < 1) {
uint8_t blurAmount = beatsin8(bpm/4,13,50);
blur2d(leds, kMatrixWidth, kMatrixHeight, blurAmount);
}
while(x >= y)
{
uint8_t ms = millis();
leds[XY(x + x0, y + y0)] += color1;
leds[XY( y + x0, x + y0)] += color1;
leds[XY (-x + x0, y + y0)] += color1;
leds[XY(-y + x0, x + y0)] += color1;
leds[XY(-x + x0, -y + y0)] += color1;
leds[XY(-y + x0, -x + y0)] += color1;
leds[XY( x + x0, -y + y0)] += color1;
leds[XY( y + x0, -x + y0)] += color1;
y++;
if (decisionOver2<=0)
{
decisionOver2 += 2 * y + 1; // Change in decision criterion for y -> y+1
}
else
{
x–;
decisionOver2 += 2 * (y - x) + 1; // Change for y -> y+1, x -> x-1
}
}
FastLED.show();
for(int j = 0; j < NUM_LEDS; j++) {
leds[j].fadeToBlackBy(30);
}
}