CHSV& nblend( CHSV& existing, const CHSV& overlay, fract8 amountOfOverlay, TGradientDirectionCode directionCode) { if( amountOfOverlay == 0) { return existing; } if( amountOfOverlay == 255) { existing = overlay; return existing; } fract8 amountOfKeep = 256 - amountOfOverlay; uint8_t huedelta8 = overlay.hue - existing.hue; if( directionCode == SHORTEST_HUES ) { directionCode = FORWARD_HUES; if( huedelta8 > 127) { directionCode = BACKWARD_HUES; } } if( directionCode == LONGEST_HUES ) { directionCode = FORWARD_HUES; if( huedelta8 < 128) { directionCode = BACKWARD_HUES; } } if( directionCode == FORWARD_HUES) { existing.hue = existing.hue + scale8( huedelta8, amountOfOverlay); } else /* directionCode == BACKWARD_HUES */ { huedelta8 = -huedelta8; existing.hue = existing.hue - scale8( huedelta8, amountOfOverlay); } existing.sat = scale8_LEAVING_R1_DIRTY( existing.sat, amountOfKeep) + scale8_LEAVING_R1_DIRTY( overlay.sat, amountOfOverlay); existing.val = scale8_LEAVING_R1_DIRTY( existing.val, amountOfKeep) + scale8_LEAVING_R1_DIRTY( overlay.val, amountOfOverlay); cleanup_R1(); return existing; }
CRGB& nblend( CRGB& existing, const CRGB& overlay, fract8 amountOfOverlay ) { if( amountOfOverlay == 0) { return existing; } if( amountOfOverlay == 255) { existing = overlay; return existing; } fract8 amountOfKeep = 256 - amountOfOverlay; existing.red = scale8_LEAVING_R1_DIRTY( existing.red, amountOfKeep) + scale8_LEAVING_R1_DIRTY( overlay.red, amountOfOverlay); existing.green = scale8_LEAVING_R1_DIRTY( existing.green, amountOfKeep) + scale8_LEAVING_R1_DIRTY( overlay.green, amountOfOverlay); existing.blue = scale8_LEAVING_R1_DIRTY( existing.blue, amountOfKeep) + scale8_LEAVING_R1_DIRTY( overlay.blue, amountOfOverlay); cleanup_R1(); return existing; }