Arc - gPC fix by @Brandon502

with fix for missing pixel on 8x32 and similar ratios.
This commit is contained in:
Frank
2024-10-19 22:26:11 +02:00
parent 2ac354aa0c
commit 670c621ffe
2 changed files with 29 additions and 17 deletions

View File

@@ -957,6 +957,7 @@ void IRAM_ATTR_YN __attribute__((hot)) Segment::setPixelColor(int i, uint32_t co
if (i==0)
setPixelColorXY(0, 0, col);
else {
if (i == virtualLength() - 1) setPixelColorXY(vW-1, vH-1, col); // Last i always fill corner
if (!_isSuperSimpleSegment) {
// WLEDMM: drawArc() is faster if it's NOT "super simple" as the regular M12_pArc
// can do "useSymmetry" to speed things along, but a more complicated segment likey
@@ -1227,10 +1228,20 @@ uint32_t __attribute__((hot)) Segment::getPixelColor(int i) const
return vW>vH ? getPixelColorXY(i, 0) : getPixelColorXY(0, i); // Corner and Arc
break;
}
int length = virtualLength();
int x = i * vW / length;
int y = i * vH / length;
return getPixelColorXY(x, y); // Not 100% accurate
float minradius = float(i) - .5f;
const int minradius2 = roundf(minradius * minradius);
int startX, startY;
if (vW >= vH) {startX = vW - 1; startY = 1;} // Last Column
else {startX = 1; startY = vH - 1;} // Last Row
// Loop through only last row/column depending on orientation
for (int x = startX; x < vW; x++) {
int newX2 = x * x;
for (int y = startY; y < vH; y++) {
int newY2 = y * y;
if (newX2 + newY2 >= minradius2) return getPixelColorXY(x, y);
}
}
return getPixelColorXY(vW-1, vH-1); // Last pixel
break;
}
case M12_jMap: //WLEDMM jMap