2D Drift: minor optimization
moving "t/20" out of the main loop gives some speedup.
This commit is contained in:
parent
e3ee48b52e
commit
1ecb4fedcc
@ -4759,11 +4759,12 @@ uint16_t mode_2DDrift() { // By: Stepko https://editor.soulmateli
|
|||||||
|
|
||||||
const uint16_t maxDim = MAX(cols, rows)/2;
|
const uint16_t maxDim = MAX(cols, rows)/2;
|
||||||
unsigned long t = millis() / (32 - (SEGMENT.speed>>3));
|
unsigned long t = millis() / (32 - (SEGMENT.speed>>3));
|
||||||
|
unsigned long t_20 = t/20; // softhack007: pre-calculating this gives about 10% speedup
|
||||||
for (float i = 1; i < maxDim; i += 0.25) {
|
for (float i = 1; i < maxDim; i += 0.25) {
|
||||||
float angle = radians(t * (maxDim - i));
|
float angle = radians(t * (maxDim - i));
|
||||||
uint16_t myX = (cols>>1) + (uint16_t)(sin_t(angle) * i) + (cols%2);
|
uint16_t myX = (cols>>1) + (uint16_t)(sin_t(angle) * i) + (cols%2);
|
||||||
uint16_t myY = (rows>>1) + (uint16_t)(cos_t(angle) * i) + (rows%2);
|
uint16_t myY = (rows>>1) + (uint16_t)(cos_t(angle) * i) + (rows%2);
|
||||||
SEGMENT.setPixelColorXY(myX, myY, ColorFromPalette(SEGPALETTE, (i * 20) + (t / 20), 255, LINEARBLEND));
|
SEGMENT.setPixelColorXY(myX, myY, ColorFromPalette(SEGPALETTE, (i * 20) + t_20, 255, LINEARBLEND));
|
||||||
}
|
}
|
||||||
SEGMENT.blur(SEGMENT.intensity>>3);
|
SEGMENT.blur(SEGMENT.intensity>>3);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user