CustomEffects as usermod: step 4: modify wledv123.json, add drawLine/Arc

General (for CE, but also used by M12_pArc)
- add drawArc

Custom Effects
- add WLEDSR Custom Effects comment to places in WLED where it is hooked in
- move from wled.json to wledv123.json
- rename matrixWidth/Heigth to width/height and use virtualWidth/Height
- remove setPixels
- add drawLine / drawArc
This commit is contained in:
Ewowi
2022-08-31 13:14:51 +02:00
parent 717d755969
commit 06c0c0edfb
13 changed files with 97 additions and 70 deletions

View File

@@ -459,6 +459,29 @@ void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint3
}
}
void Segment::drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color, uint32_t fillColor) {
// float step = degrees / (2.85f*MAX(radius,1));
// for (float rad = 0.0f; rad <= degrees+step/2; rad += step) {
// // may want to try float version as well (with or without antialiasing)
// int x = roundf(sin_t(rad) * radius);
// int y = roundf(cos_t(rad) * radius);
// setPixelColorXY(x+x0, y+y0, c);
// }
float minradius = radius - .5;
float maxradius = radius + .5;
for (int x=0; x<virtualWidth(); x++) for (int y=0; y<virtualHeight(); y++) {
int newX = x - x0;
int newY = y - y0;
if (newX*newX + newY*newY >= minradius * minradius && newX*newX + newY*newY <= maxradius * maxradius)
setPixelColorXY(x, y, color);
if (fillColor != 0)
if (newX*newX + newY*newY < minradius * minradius)
setPixelColorXY(x, y, fillColor);
}
}
#include "console_font_5x8.h"
#include "console_font_5x12.h"
#include "console_font_6x8.h"