effect bugfixes for width>255

* band-aid for ripple, matrix, crazy bee
* arc mapping fix for diameter > 255
* small speedup for "block" mapping
This commit is contained in:
Frank
2024-11-13 23:57:53 +01:00
parent 202255849f
commit c73ed486e9
2 changed files with 18 additions and 15 deletions

View File

@@ -2589,7 +2589,7 @@ uint16_t ripple_base()
} else {//randomly create new wave
if (random16(IBN + 10000) <= (SEGMENT.intensity >> (SEGMENT.is2D()*3))) {
ripples[i].state = 1;
ripples[i].pos = SEGMENT.is2D() ? ((random8(SEGENV.virtualWidth())<<8) | (random8(SEGENV.virtualHeight()))) : random16(SEGLEN);
ripples[i].pos = SEGMENT.is2D() ? ((random16(SEGENV.virtualWidth())<<8) | (random16(SEGENV.virtualHeight()))) : random16(SEGLEN);
ripples[i].color = random8(); //color
}
}
@@ -5803,7 +5803,7 @@ uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams.
// spawn new falling code
if (random8() <= SEGMENT.intensity || emptyScreen) {
uint8_t spawnX = random8(cols);
uint16_t spawnX = random16(cols);
SEGMENT.setPixelColorXY(spawnX, 0, spawnColor);
// update hint for next run
SEGENV.aux0 = spawnX;
@@ -6276,8 +6276,8 @@ uint16_t mode_2Dcrazybees(void) {
void aimed(uint_fast16_t w, uint_fast16_t h) {
if (!true) //WLEDMM SuperSync
random16_set_seed(strip.now);
aimX = random8(0, w);
aimY = random8(0, h);
aimX = random8(0, min(UINT8_MAX, int(w)));
aimY = random8(0, min(UINT8_MAX, int(h)));
hue = random8();
deltaX = abs(aimX - posX);
deltaY = abs(aimY - posY);
@@ -6296,8 +6296,8 @@ uint16_t mode_2Dcrazybees(void) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
for (size_t i = 0; i < n; i++) {
bee[i].posX = random8(0, cols);
bee[i].posY = random8(0, rows);
bee[i].posX = random8(0, min(UINT8_MAX, int(cols)));
bee[i].posY = random8(0, min(UINT8_MAX, int(rows)));
bee[i].aimed(cols, rows);
}
}

View File

@@ -873,8 +873,11 @@ uint16_t Segment::calc_virtualLength() const {
vLen = max(vW,vH); // get the longest dimension
break;
case M12_pArc:
vLen = sqrt16(vW * vW + vH * vH);
if (vW != vH) vLen++; // round up
{ unsigned vLen2 = vW * vW + vH * vH; // length ^2
if (vLen2 < UINT16_MAX) vLen = sqrt16(vLen2); // use faster function for 16bit values
else vLen = sqrtf(vLen2); // fall-back to float if bigger
if (vW != vH) vLen++; // round up
}
break;
case M12_jMap: //WLEDMM jMap
if (jMap)
@@ -888,7 +891,7 @@ uint16_t Segment::calc_virtualLength() const {
if (nrOfVStrips()>1)
vLen = max(vW,vH) * 4;//0.5; // get the longest dimension
else
vLen = max(vW,vH) * 0.5; // get the longest dimension
vLen = max(vW,vH) * 0.5f; // get the longest dimension
break;
case M12_sPinwheel:
vLen = getPinwheelLength(vW, vH);
@@ -906,23 +909,23 @@ uint16_t Segment::calc_virtualLength() const {
//WLEDMM used for M12_sBlock
static void xyFromBlock(uint16_t &x,uint16_t &y, uint16_t i, uint16_t vW, uint16_t vH, uint16_t vStrip) {
float i2;
if (i<=SEGLEN*0.25) { //top, left to right
i2 = i/(SEGLEN*0.25);
if (i<=SEGLEN*0.25f) { //top, left to right
i2 = i/(SEGLEN*0.25f);
x = vW / 2 - vStrip - 1 + i2 * vStrip * 2;
y = vH / 2 - vStrip - 1;
}
else if (i <= SEGLEN * 0.5) { //right, top to bottom
i2 = (i-SEGLEN*0.25)/(SEGLEN*0.25);
else if (i <= SEGLEN * 0.5f) { //right, top to bottom
i2 = (i-SEGLEN*0.25f)/(SEGLEN*0.25f);
x = vW / 2 + vStrip;
y = vH / 2 - vStrip - 1 + i2 * vStrip * 2;
}
else if (i <= SEGLEN * 0.75) { //bottom, right to left
i2 = (i-SEGLEN*0.5)/(SEGLEN*0.25);
i2 = (i-SEGLEN*0.5f)/(SEGLEN*0.25f);
x = vW / 2 + vStrip - i2 * vStrip * 2;
y = vH / 2 + vStrip;
}
else if (i <= SEGLEN) { //left, bottom to top
i2 = (i-SEGLEN*0.75)/(SEGLEN*0.25);
i2 = (i-SEGLEN*0.75f)/(SEGLEN*0.25f);
x = vW / 2 - vStrip - 1;
y = vH / 2 + vStrip - i2 * vStrip * 2;
}