expand1D: add Circles and Block and show virtualStrip effects with ⋮⋮

index.js: add Circles and Block, add 1.5d
FX.h: add Circles and Block
FX.cpp: add 1.5d to virtualStrip effects
FX_fcn.cpp: add Circles and Block
This commit is contained in:
Ewowi
2022-10-21 12:05:57 +02:00
parent 8e70176de6
commit f5718b67d4
6 changed files with 954 additions and 854 deletions

View File

@@ -219,6 +219,7 @@ struct Voxel {
uint32_t col;
};
//https://xem.github.io/articles/projection.html
class Frame3D {
private:
std::vector<Voxel> points;

View File

@@ -2016,7 +2016,7 @@ uint16_t mode_fire_2012()
return FRAMETIME;
}
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate;1,2,3;!;sx=120,ix=64,mp12=1,1d"; //bars
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate;1,2,3;!;sx=120,ix=64,mp12=1,1.5d"; //bars
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
@@ -2857,7 +2857,7 @@ uint16_t mode_bouncing_balls(void) {
return FRAMETIME;
}
static const char _data_FX_MODE_BOUNCINGBALLS[] PROGMEM = "Bouncing Balls@Gravity,# of balls;!,!,!;!;mp12=1,1d"; //bar
static const char _data_FX_MODE_BOUNCINGBALLS[] PROGMEM = "Bouncing Balls@Gravity,# of balls;!,!,!;!;mp12=1,1.5d"; //bar
/*
@@ -3000,7 +3000,7 @@ uint16_t mode_popcorn(void) {
return FRAMETIME;
}
static const char _data_FX_MODE_POPCORN[] PROGMEM = "Popcorn@!,!;!,!,!;!;mp12=1,1d"; //bar
static const char _data_FX_MODE_POPCORN[] PROGMEM = "Popcorn@!,!;!,!,!;!;mp12=1,1.5d"; //bar
//values close to 100 produce 5Hz flicker, which looks very candle-y
@@ -3451,7 +3451,7 @@ uint16_t mode_drip(void)
return FRAMETIME;
}
static const char _data_FX_MODE_DRIP[] PROGMEM = "Drip@Gravity,# of drips,Fall ratio;!,!;!;mp12=1,1d"; //bar
static const char _data_FX_MODE_DRIP[] PROGMEM = "Drip@Gravity,# of drips,Fall ratio;!,!;!;mp12=1,1.5d"; //bar
/*
@@ -3540,7 +3540,7 @@ uint16_t mode_tetrix(void) {
return FRAMETIME;
}
static const char _data_FX_MODE_TETRIX[] PROGMEM = "Tetrix@!,Width;!,!,;!;sx=0,ix=0,pal=11,mp12=1,1d";
static const char _data_FX_MODE_TETRIX[] PROGMEM = "Tetrix@!,Width;!,!,;!;sx=0,ix=0,pal=11,mp12=1,1.5d";
/*

View File

@@ -326,7 +326,9 @@ typedef enum mapping1D2D {
M12_pBar = 1,
M12_pArc = 2,
M12_pCorner = 3,
M12_jMap = 4 //WLEDSR jMap
M12_jMap = 4, //WLEDSR jMap
M12_sCircle = 5, //WLEDSR jMap
M12_sBlock = 6 //WLEDSR jMap
} mapping1D2D_t;
// segment, 72 bytes

View File

@@ -465,6 +465,12 @@ uint16_t Segment::nrOfVStrips() const {
case M12_pBar:
vLen = virtualWidth();
break;
case M12_sCircle: //WLEDSR
vLen = (virtualWidth() + virtualHeight()) / 6; // take third of the average width
break;
case M12_sBlock: //WLEDSR
vLen = (virtualWidth() + virtualHeight()) / 8; // take half of the average width
break;
}
}
#endif
@@ -639,6 +645,16 @@ uint16_t Segment::virtualLength() const {
if (jMap)
vLen = ((JMapC *)jMap)->length();
break;
case M12_sCircle: //WLEDSR
vLen = max(vW,vH); // get the longest dimension
// vLen = (virtualWidth() + virtualHeight()) * 3;
break;
case M12_sBlock: //WLEDSR
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
break;
}
return vLen;
}
@@ -649,6 +665,32 @@ uint16_t Segment::virtualLength() const {
return vLength;
}
//WLEDSR used for M12_sBlock
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);
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);
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);
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);
x = vW / 2 - vStrip - 1;
y = vH / 2 + vStrip - i2 * vStrip * 2;
}
}
void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
{
int vStrip = i>>16; // hack to allow running on virtual strips (2D segment columns/rows)
@@ -685,6 +727,35 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
if (jMap)
((JMapC *)jMap)->setPixelColor(i, col);
break;
case M12_sCircle: //WLEDSR
if (vStrip > 0)
{
int x = roundf(sin_t(360*i/SEGLEN*DEG_TO_RAD) * vW * (vStrip+1)/nrOfVStrips());
int y = roundf(cos_t(360*i/SEGLEN*DEG_TO_RAD) * vW * (vStrip+1)/nrOfVStrips());
setPixelColorXY(x + vW/2, y + vH/2, col);
}
else // pArc -> circle
drawArc(vW/2, vH/2, i/2, col);
break;
case M12_sBlock: //WLEDSR
if (vStrip > 0)
{
//vStrip+1 is distance from centre, i is how much of the square is filled
uint16_t x=0,y=0;
xyFromBlock(x,y, i, vW, vH, (vStrip+1)*2);
setPixelColorXY(x, y, col);
}
else { // pCorner -> block
for (int x = vW / 2 - i - 1; x <= vW / 2 + i; x++) { // top and bottom horizontal lines
setPixelColorXY(x, vH / 2 - i - 1, col);
setPixelColorXY(x, vH / 2 + i , col);
}
for (int y = vH / 2 - i - 1 + 1; y <= vH / 2 + i - 1; y++) { //left and right vertical lines
setPixelColorXY(vW / 2 - i - 1, y, col);
setPixelColorXY(vW / 2 + i , y, col);
}
}
break;
}
return;
} else if (strip.isMatrix && (width()==1 || height()==1)) { // TODO remove this hack
@@ -795,6 +866,26 @@ uint32_t Segment::getPixelColor(int i)
if (jMap)
return ((JMapC *)jMap)->getPixelColor(i);
break;
case M12_sCircle: //WLEDSR
if (vStrip > 0)
{
int x = roundf(sin_t(360*i/SEGLEN*DEG_TO_RAD) * vW * (vStrip+1)/nrOfVStrips());
int y = roundf(cos_t(360*i/SEGLEN*DEG_TO_RAD) * vW * (vStrip+1)/nrOfVStrips());
return getPixelColorXY(x + vW/2, y + vH/2);
}
else
return vW>vH ? getPixelColorXY(i, 0) : getPixelColorXY(0, i);
break;
case M12_sBlock: //WLEDSR
if (vStrip > 0)
{
uint16_t x=0,y=0;
xyFromBlock(x,y, i, vW, vH, (vStrip+1)*2);
return getPixelColorXY(x, y);
}
else
return getPixelColorXY(vW / 2, vH / 2 - i - 1);
break;
}
return 0;
}

View File

@@ -739,6 +739,8 @@ function populateSegments(s)
<option value="2" ${inst.mp12==2?' selected':''}>Arc</option>
<option value="3" ${inst.mp12==3?' selected':''}>Corner</option>
<option value="4" ${inst.mp12==4?' selected':''}>jMap</option>
<option value="5" ${inst.mp12==5?' selected':''}>Circles</option>
<option value="6" ${inst.mp12==6?' selected':''}>Block</option>
</select></div>
</div>`;
let sndSim = `<div data-snd="ssim" class="lbl-s hide">Sound sim<br>
@@ -865,6 +867,7 @@ function populateEffects()
let m = (eP.length<4 || eP[3]==='')?[]:eP[3].split(","); // metadata
if (m.length>0) for (let r of m) {
if (r.substring(0,2)=="1d") nm += "&#8942;"; // 1D effects
if (r.substring(0,4)=="1.5d") nm += "&#8942;&#8942;"; // 1D effects + vStrips
if (r.substring(0,2)=="2d") nm += "&#9638;"; // 2D effects
if (r.substring(0,2)=="vo") nm += "&#9834;"; // volume effects
if (r.substring(0,2)=="fr") nm += "&#9835;"; // frequency effects

File diff suppressed because it is too large Load Diff