diff --git a/wled00/FX.h b/wled00/FX.h
index 486c9af45..2bb88a2bb 100644
--- a/wled00/FX.h
+++ b/wled00/FX.h
@@ -501,7 +501,7 @@ typedef struct Segment {
inline bool getOption(uint8_t n) const { return ((options >> n) & 0x01); }
inline bool isSelected(void) const { return selected; }
inline bool isActive(void) const { return stop > start; }
- inline bool is2D(void) const { return !(startY == 0 && stopY == 1); }
+ inline bool is2D(void) const { return (width()>1 && height()>1); }
inline uint16_t width(void) const { return stop - start; } // segment width in physical pixels (length if 1D)
inline uint16_t height(void) const { return stopY - startY; } // segment height (if 2D) in physical pixels
inline uint16_t length(void) const { return width() * height(); } // segment length (count) in physical pixels
diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp
index bbbae7598..e567e49fd 100644
--- a/wled00/FX_2Dfcn.cpp
+++ b/wled00/FX_2Dfcn.cpp
@@ -150,6 +150,7 @@ uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y) {
void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
{
if (!strip.isMatrix) return; // not a matrix set-up
+ if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit
if (leds) leds[XY(x,y)] = col;
diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp
index dedff0eff..4edf05c13 100644
--- a/wled00/FX_fcn.cpp
+++ b/wled00/FX_fcn.cpp
@@ -442,11 +442,16 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
break;
case M12_Circle:
// expand in circular fashion from center
- for (float degrees = 0.0f; degrees <= 90.0f; degrees += 89.99f / (sqrtf((float)max(vH,vW))*i+1)) { // this may prove too many iterations on larger matrices
- // may want to try float version as well (with or without antialiasing)
- int x = roundf(sin_t(degrees*DEG_TO_RAD) * i);
- int y = roundf(cos_t(degrees*DEG_TO_RAD) * i);
- setPixelColorXY(x, y, col);
+ if (i==0)
+ setPixelColorXY(0, 0, col);
+ else {
+ float step = HALF_PI / (2*i);
+ for (float rad = 0.0f; rad <= HALF_PI+step/2; rad += step) {
+ // may want to try float version as well (with or without antialiasing)
+ int x = roundf(sin_t(rad) * i);
+ int y = roundf(cos_t(rad) * i);
+ setPixelColorXY(x, y, col);
+ }
}
break;
case M12_Block:
@@ -455,9 +460,16 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
break;
}
return;
+ } else if (width()==1 && height()>1) {
+ // we have a vertical 1D segment
+ setPixelColorXY(0, i, col); // transpose
+ } else if (width()>1 && height()==1) {
+ // we have a horizontal 1D segment
+ setPixelColorXY(i, 0, col);
}
#endif
+ if (i >= virtualLength() || i<0) return; // if pixel would fall out of segment just exit
if (leds) leds[i] = col;
uint16_t len = length();
diff --git a/wled00/data/index.js b/wled00/data/index.js
index f9f74111f..5985a6d97 100644
--- a/wled00/data/index.js
+++ b/wled00/data/index.js
@@ -701,6 +701,10 @@ function populateSegments(s)
`;
+ let staX = inst.start;
+ let stoX = inst.stop;
+ let staY = inst.startY;
+ let stoY = inst.stopY;
let rvXck = ``;
let miXck = ``;
let rvYck = "", miYck ="";
@@ -745,14 +749,14 @@ function populateSegments(s)
${isM?'':'Offset'} |
- |
- |
+ |
+ |
${isM?miXck+' '+rvXck:''} |
${isM ? 'Start Y | '+(cfg.comp.seglen?'Height':'Stop Y')+' | |
'+
''+
- ' | '+
- ' | '+
+ ' | '+
+ ' | '+
''+miYck+' '+rvYck+' | '+
'
':''}
@@ -768,7 +772,7 @@ function populateSegments(s)
${!isM?rvXck:''}
- ${isM?map2D:''}
+ ${isM&&stoY-staY>1&&stoX-staX>1?map2D:''}
${s.AudioReactive && s.AudioReactive.on ? "" : sndSim}