Minor tweaks and whitespace

This commit is contained in:
Blaž Kristan 2024-10-05 23:31:31 +02:00
parent ca062140f3
commit eb5ad232a0

View File

@ -195,6 +195,7 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col)
const int vW = vWidth(); // segment width in logical pixels (can be 0 if segment is inactive)
const int vH = vHeight(); // segment height in logical pixels (is always >= 1)
// negative values of x & y cast into unsigend will become very large values and will therefore be greater than vW/vH
if (unsigned(x) >= unsigned(vW) || unsigned(y) >= unsigned(vH)) return; // if pixel would fall out of virtual segment just exit
// if color is unscaled
@ -205,8 +206,7 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col)
if (transpose) { std::swap(x,y); } // swap X & Y if segment transposed
unsigned groupLen = groupLength();
if(groupLen > 1)
{
if (groupLen > 1) {
int W = width();
int H = height();
x *= groupLen; // expand to physical pixels
@ -222,8 +222,7 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col)
}
yY++;
}
}
else {
} else {
_setPixelColorXY_raw(x, y, col);
}
}
@ -427,18 +426,14 @@ void Segment::moveX(int delta, bool wrap) {
int start = 0;
if (wrap) newDelta = (delta + vW) % vW; // +cols in case delta < 0
else {
if(delta < 0) start = -delta;
if (delta < 0) start = absDelta;
stop = vW - absDelta;
newDelta = delta > 0 ? delta : 0;
}
for (int y = 0; y < vH; y++) {
for (int x = 0; x < stop; x++) {
int srcX;
if (wrap) {
srcX = (x + newDelta) % vW; // Wrap using modulo when `wrap` is true
} else {
srcX = x + newDelta;
}
int srcX = x + newDelta;
if (wrap) srcX %= vW; // Wrap using modulo when `wrap` is true
newPxCol[x] = getPixelColorXY(srcX, y);
}
for (int x = 0; x < stop; x++) setPixelColorXY(x + start, y, newPxCol[x]);
@ -457,18 +452,14 @@ void Segment::moveY(int delta, bool wrap) {
int start = 0;
if (wrap) newDelta = (delta + vH) % vH; // +rows in case delta < 0
else {
if(delta < 0) start = -delta;
if (delta < 0) start = absDelta;
stop = vH - absDelta;
newDelta = delta > 0 ? delta : 0;
}
for (int x = 0; x < vW; x++) {
for (int y = 0; y < stop; y++) {
int srcY;
if (wrap) {
srcY = (y + newDelta) % vH; // Wrap using modulo when `wrap` is true
} else {
srcY = y + newDelta;
}
int srcY = y + newDelta;
if (wrap) srcY %= vH; // Wrap using modulo when `wrap` is true
newPxCol[y] = getPixelColorXY(x, srcY);
}
for (int y = 0; y < stop; y++) setPixelColorXY(x, y + start, newPxCol[y]);