Skip to content

Commit c637769

Browse files
fix the 2d drift animation
1 parent a4384bd commit c637769

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

wled00/FX.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5011,14 +5011,17 @@ uint16_t mode_2DDrift() { // By: Stepko https://editor.soulmateli
50115011
const uint16_t cols = SEGMENT.virtualWidth();
50125012
const uint16_t rows = SEGMENT.virtualHeight();
50135013

5014+
const uint16_t colsCenter = (cols>>1) + cols%2;
5015+
const uint16_t rowsCenter = (rows>>1) + rows%2;
5016+
50145017
SEGMENT.fadeToBlackBy(128);
50155018
const uint16_t maxDim = MAX(cols, rows)/2;
50165019
unsigned long t = strip.now / (32 - (SEGMENT.speed>>3));
50175020
unsigned long t_20 = t/20; // softhack007: pre-calculating this gives about 10% speedup
50185021
for (float i = 1; i < maxDim; i += 0.25) {
50195022
float angle = radians(t * (maxDim - i));
5020-
uint16_t myX = (cols>>1) + (uint16_t)(sin_t(angle) * i) + (cols%2);
5021-
uint16_t myY = (rows>>1) + (uint16_t)(cos_t(angle) * i) + (rows%2);
5023+
uint16_t myX = colsCenter + (sin_t(angle) * i);
5024+
uint16_t myY = rowsCenter + (cos_t(angle) * i);
50225025
SEGMENT.setPixelColorXY(myX, myY, ColorFromPalette(SEGPALETTE, (i * 20) + t_20, 255, LINEARBLEND));
50235026
}
50245027
SEGMENT.blur(SEGMENT.intensity>>3);

0 commit comments

Comments
 (0)