mirror of
https://github.com/wled/WLED.git
synced 2025-07-22 18:26:32 +00:00
Minor tweaks and whitespace
This commit is contained in:
parent
ca062140f3
commit
eb5ad232a0
@ -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 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)
|
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 (unsigned(x) >= unsigned(vW) || unsigned(y) >= unsigned(vH)) return; // if pixel would fall out of virtual segment just exit
|
||||||
|
|
||||||
// if color is unscaled
|
// 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
|
if (transpose) { std::swap(x,y); } // swap X & Y if segment transposed
|
||||||
unsigned groupLen = groupLength();
|
unsigned groupLen = groupLength();
|
||||||
|
|
||||||
if(groupLen > 1)
|
if (groupLen > 1) {
|
||||||
{
|
|
||||||
int W = width();
|
int W = width();
|
||||||
int H = height();
|
int H = height();
|
||||||
x *= groupLen; // expand to physical pixels
|
x *= groupLen; // expand to physical pixels
|
||||||
@ -222,8 +222,7 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col)
|
|||||||
}
|
}
|
||||||
yY++;
|
yY++;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_setPixelColorXY_raw(x, y, col);
|
_setPixelColorXY_raw(x, y, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,7 +292,7 @@ void Segment::blur2D(uint8_t blur_x, uint8_t blur_y, bool smear) {
|
|||||||
const unsigned rows = vHeight();
|
const unsigned rows = vHeight();
|
||||||
uint32_t lastnew;
|
uint32_t lastnew;
|
||||||
uint32_t last;
|
uint32_t last;
|
||||||
if(blur_x) {
|
if (blur_x) {
|
||||||
const uint8_t keepx = smear ? 255 : 255 - blur_x;
|
const uint8_t keepx = smear ? 255 : 255 - blur_x;
|
||||||
const uint8_t seepx = blur_x >> (1 + smear);
|
const uint8_t seepx = blur_x >> (1 + smear);
|
||||||
for (unsigned row = 0; row < rows; row++) { // blur rows (x direction)
|
for (unsigned row = 0; row < rows; row++) { // blur rows (x direction)
|
||||||
@ -316,7 +315,7 @@ void Segment::blur2D(uint8_t blur_x, uint8_t blur_y, bool smear) {
|
|||||||
setPixelColorXY(cols-1, row, curnew); // set last pixel
|
setPixelColorXY(cols-1, row, curnew); // set last pixel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(blur_y) {
|
if (blur_y) {
|
||||||
const uint8_t keepy = smear ? 255 : 255 - blur_y;
|
const uint8_t keepy = smear ? 255 : 255 - blur_y;
|
||||||
const uint8_t seepy = blur_y >> (1 + smear);
|
const uint8_t seepy = blur_y >> (1 + smear);
|
||||||
for (unsigned col = 0; col < cols; col++) {
|
for (unsigned col = 0; col < cols; col++) {
|
||||||
@ -425,20 +424,16 @@ void Segment::moveX(int delta, bool wrap) {
|
|||||||
int newDelta;
|
int newDelta;
|
||||||
int stop = vW;
|
int stop = vW;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
if(wrap) newDelta = (delta + vW) % vW; // +cols in case delta < 0
|
if (wrap) newDelta = (delta + vW) % vW; // +cols in case delta < 0
|
||||||
else {
|
else {
|
||||||
if(delta < 0) start = -delta;
|
if (delta < 0) start = absDelta;
|
||||||
stop = vW - absDelta;
|
stop = vW - absDelta;
|
||||||
newDelta = delta > 0 ? delta : 0;
|
newDelta = delta > 0 ? delta : 0;
|
||||||
}
|
}
|
||||||
for (int y = 0; y < vH; y++) {
|
for (int y = 0; y < vH; y++) {
|
||||||
for (int x = 0; x < stop; x++) {
|
for (int x = 0; x < stop; x++) {
|
||||||
int srcX;
|
int srcX = x + newDelta;
|
||||||
if (wrap) {
|
if (wrap) srcX %= vW; // Wrap using modulo when `wrap` is true
|
||||||
srcX = (x + newDelta) % vW; // Wrap using modulo when `wrap` is true
|
|
||||||
} else {
|
|
||||||
srcX = x + newDelta;
|
|
||||||
}
|
|
||||||
newPxCol[x] = getPixelColorXY(srcX, y);
|
newPxCol[x] = getPixelColorXY(srcX, y);
|
||||||
}
|
}
|
||||||
for (int x = 0; x < stop; x++) setPixelColorXY(x + start, y, newPxCol[x]);
|
for (int x = 0; x < stop; x++) setPixelColorXY(x + start, y, newPxCol[x]);
|
||||||
@ -455,20 +450,16 @@ void Segment::moveY(int delta, bool wrap) {
|
|||||||
int newDelta;
|
int newDelta;
|
||||||
int stop = vH;
|
int stop = vH;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
if(wrap) newDelta = (delta + vH) % vH; // +rows in case delta < 0
|
if (wrap) newDelta = (delta + vH) % vH; // +rows in case delta < 0
|
||||||
else {
|
else {
|
||||||
if(delta < 0) start = -delta;
|
if (delta < 0) start = absDelta;
|
||||||
stop = vH - absDelta;
|
stop = vH - absDelta;
|
||||||
newDelta = delta > 0 ? delta : 0;
|
newDelta = delta > 0 ? delta : 0;
|
||||||
}
|
}
|
||||||
for (int x = 0; x < vW; x++) {
|
for (int x = 0; x < vW; x++) {
|
||||||
for (int y = 0; y < stop; y++) {
|
for (int y = 0; y < stop; y++) {
|
||||||
int srcY;
|
int srcY = y + newDelta;
|
||||||
if (wrap) {
|
if (wrap) srcY %= vH; // Wrap using modulo when `wrap` is true
|
||||||
srcY = (y + newDelta) % vH; // Wrap using modulo when `wrap` is true
|
|
||||||
} else {
|
|
||||||
srcY = y + newDelta;
|
|
||||||
}
|
|
||||||
newPxCol[y] = getPixelColorXY(x, srcY);
|
newPxCol[y] = getPixelColorXY(x, srcY);
|
||||||
}
|
}
|
||||||
for (int y = 0; y < stop; y++) setPixelColorXY(x, y + start, newPxCol[y]);
|
for (int y = 0; y < stop; y++) setPixelColorXY(x, y + start, newPxCol[y]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user