Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 28 additions & 29 deletions wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,33 +383,33 @@ extern byte realtimeMode; // used in getMappedPixelIndex()
#define MODE_COUNT 219


#define BLEND_STYLE_FADE 0x00 // universal
#define BLEND_STYLE_FAIRY_DUST 0x01 // universal
#define BLEND_STYLE_SWIPE_RIGHT 0x02 // 1D or 2D
#define BLEND_STYLE_SWIPE_LEFT 0x03 // 1D or 2D
#define BLEND_STYLE_OUTSIDE_IN 0x04 // 1D or 2D
#define BLEND_STYLE_INSIDE_OUT 0x05 // 1D or 2D
#define BLEND_STYLE_SWIPE_UP 0x06 // 2D
#define BLEND_STYLE_SWIPE_DOWN 0x07 // 2D
#define BLEND_STYLE_OPEN_H 0x08 // 2D
#define BLEND_STYLE_OPEN_V 0x09 // 2D
#define BLEND_STYLE_SWIPE_TL 0x0A // 2D
#define BLEND_STYLE_SWIPE_TR 0x0B // 2D
#define BLEND_STYLE_SWIPE_BR 0x0C // 2D
#define BLEND_STYLE_SWIPE_BL 0x0D // 2D
#define BLEND_STYLE_CIRCULAR_OUT 0x0E // 2D
#define BLEND_STYLE_CIRCULAR_IN 0x0F // 2D
#define TRANSITION_FADE 0x00 // universal
#define TRANSITION_FAIRY_DUST 0x01 // universal
#define TRANSITION_SWIPE_RIGHT 0x02 // 1D or 2D
#define TRANSITION_SWIPE_LEFT 0x03 // 1D or 2D
#define TRANSITION_OUTSIDE_IN 0x04 // 1D or 2D
#define TRANSITION_INSIDE_OUT 0x05 // 1D or 2D
#define TRANSITION_SWIPE_UP 0x06 // 2D
#define TRANSITION_SWIPE_DOWN 0x07 // 2D
#define TRANSITION_OPEN_H 0x08 // 2D
#define TRANSITION_OPEN_V 0x09 // 2D
#define TRANSITION_SWIPE_TL 0x0A // 2D
#define TRANSITION_SWIPE_TR 0x0B // 2D
#define TRANSITION_SWIPE_BR 0x0C // 2D
#define TRANSITION_SWIPE_BL 0x0D // 2D
#define TRANSITION_CIRCULAR_OUT 0x0E // 2D
#define TRANSITION_CIRCULAR_IN 0x0F // 2D
// as there are many push variants to optimise if statements they are groupped together
#define BLEND_STYLE_PUSH_RIGHT 0x10 // 1D or 2D (& 0b00010000)
#define BLEND_STYLE_PUSH_LEFT 0x11 // 1D or 2D (& 0b00010000)
#define BLEND_STYLE_PUSH_UP 0x12 // 2D (& 0b00010000)
#define BLEND_STYLE_PUSH_DOWN 0x13 // 2D (& 0b00010000)
#define BLEND_STYLE_PUSH_TL 0x14 // 2D (& 0b00010000)
#define BLEND_STYLE_PUSH_TR 0x15 // 2D (& 0b00010000)
#define BLEND_STYLE_PUSH_BR 0x16 // 2D (& 0b00010000)
#define BLEND_STYLE_PUSH_BL 0x17 // 2D (& 0b00010000)
#define BLEND_STYLE_PUSH_MASK 0x10
#define BLEND_STYLE_COUNT 18
#define TRANSITION_PUSH_RIGHT 0x10 // 1D or 2D (& 0b00010000)
#define TRANSITION_PUSH_LEFT 0x11 // 1D or 2D (& 0b00010000)
#define TRANSITION_PUSH_UP 0x12 // 2D (& 0b00010000)
#define TRANSITION_PUSH_DOWN 0x13 // 2D (& 0b00010000)
#define TRANSITION_PUSH_TL 0x14 // 2D (& 0b00010000)
#define TRANSITION_PUSH_TR 0x15 // 2D (& 0b00010000)
#define TRANSITION_PUSH_BR 0x16 // 2D (& 0b00010000)
#define TRANSITION_PUSH_BL 0x17 // 2D (& 0b00010000)
#define TRANSITION_PUSH_MASK 0x10
#define TRANSITION_COUNT 18


typedef enum mapping1D2D {
Expand Down Expand Up @@ -461,9 +461,8 @@ class Segment {
bool check1 : 1; // checkmark 1
bool check2 : 1; // checkmark 2
bool check3 : 1; // checkmark 3
//uint8_t blendMode : 4; // segment blending modes: top, bottom, add, subtract, difference, multiply, divide, lighten, darken, screen, overlay, hardlight, softlight, dodge, burn
};
uint8_t blendMode; // segment blending modes: top, bottom, add, subtract, difference, multiply, divide, lighten, darken, screen, overlay, hardlight, softlight, dodge, burn
uint8_t blendMode; // segment blending modes: top, bottom, add, subtract, difference, average, multiply, divide, lighten, darken, screen, overlay, hardlight, softlight, dodge, burn, stencil
char *name; // segment name

// runtime data
Expand Down Expand Up @@ -562,7 +561,7 @@ class Segment {

inline static void modeBlend(bool blend) { Segment::_modeBlend = blend; }
inline static void setClippingRect(int startX, int stopX, int startY = 0, int stopY = 1) { _clipStart = startX; _clipStop = stopX; _clipStartY = startY; _clipStopY = stopY; };
inline static bool isPreviousMode() { return Segment::_modeBlend; } // needed for determining CCT/opacity during non-BLEND_STYLE_FADE transition
inline static bool isPreviousMode() { return Segment::_modeBlend; } // needed for determining CCT/opacity during non-TRANSITION_FADE transition

static void handleRandomPalette();

Expand Down
10 changes: 5 additions & 5 deletions wled00/FX_2Dfcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,25 @@ void WS2812FX::setUpMatrix() {
// pixel is clipped if it falls outside clipping range
// if clipping start > stop the clipping range is inverted
bool Segment::isPixelXYClipped(int x, int y) const {
if (blendingStyle != BLEND_STYLE_FADE && isInTransition() && _clipStart != _clipStop) {
if (blendingStyle != TRANSITION_FADE && isInTransition() && _clipStart != _clipStop) {
const bool invertX = _clipStart > _clipStop;
const bool invertY = _clipStartY > _clipStopY;
const int cStartX = invertX ? _clipStop : _clipStart;
const int cStopX = invertX ? _clipStart : _clipStop;
const int cStartY = invertY ? _clipStopY : _clipStartY;
const int cStopY = invertY ? _clipStartY : _clipStopY;
if (blendingStyle == BLEND_STYLE_FAIRY_DUST) {
if (blendingStyle == TRANSITION_FAIRY_DUST) {
const unsigned width = cStopX - cStartX; // assumes full segment width (faster than virtualWidth())
const unsigned len = width * (cStopY - cStartY); // assumes full segment height (faster than virtualHeight())
if (len < 2) return false;
const unsigned shuffled = hashInt(x + y * width) % len;
const unsigned pos = (shuffled * 0xFFFFU) / len;
return progress() <= pos;
}
if (blendingStyle == BLEND_STYLE_CIRCULAR_IN || blendingStyle == BLEND_STYLE_CIRCULAR_OUT) {
if (blendingStyle == TRANSITION_CIRCULAR_IN || blendingStyle == TRANSITION_CIRCULAR_OUT) {
const int cx = (cStopX-cStartX+1) / 2;
const int cy = (cStopY-cStartY+1) / 2;
const bool out = (blendingStyle == BLEND_STYLE_CIRCULAR_OUT);
const bool out = (blendingStyle == TRANSITION_CIRCULAR_OUT);
const unsigned prog = out ? progress() : 0xFFFFU - progress();
int radius2 = max(cx, cy) * prog / 0xFFFF;
radius2 = 2 * radius2 * radius2;
Expand All @@ -179,7 +179,7 @@ bool Segment::isPixelXYClipped(int x, int y) const {
}
bool xInside = (x >= cStartX && x < cStopX); if (invertX) xInside = !xInside;
bool yInside = (y >= cStartY && y < cStopY); if (invertY) yInside = !yInside;
const bool clip = blendingStyle == BLEND_STYLE_OUTSIDE_IN ? xInside || yInside : xInside && yInside;
const bool clip = blendingStyle == TRANSITION_OUTSIDE_IN ? xInside || yInside : xInside && yInside;
return !clip;
}
return false;
Expand Down
Loading
Loading