-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from Makuna/MinorUpdates
Hue Blend Direction support
- Loading branch information
Showing
9 changed files
with
143 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name=NeoPixelBus by Makuna | ||
version=2.0.4 | ||
version=2.0.5 | ||
author=Michael C. Miller ([email protected]) | ||
maintainer=Michael C. Miller ([email protected]) | ||
sentence=A library that makes controlling NeoPixels (WS2811, WS2812 & SK6812) easy. | ||
paragraph=Supports most Arduino platforms, and especially Esp8266. Support for RGBW pixels. Includes seperate RgbColor, RgbwColor, HslColor, and HsbColor objects. Includes an animator class that helps create asyncronous animations. For Esp8266 it has three methods of sending data, DMA, UART, and Bit Bang. | ||
paragraph=Supports most Arduino platforms, and especially Esp8266. Support for RGBW pixels. Includes seperate RgbColor, RgbwColor, HslColor, and HsbColor objects. Includes an animator class that helps create asyncronous animations. Supports Matrix layout of pixels. Includes Gamma corretion object. For Esp8266 it has three methods of sending data, DMA, UART, and Bit Bang. | ||
category=Display | ||
url=https://github.com/Makuna/NeoPixelBus/wiki | ||
architectures=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/*------------------------------------------------------------------------- | ||
NeoHueBlend provides method objects that can be directly consumed by | ||
blend template functions in HslColor and HsbColor | ||
Written by Michael C. Miller. | ||
I invest time and resources providing this open source code, | ||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus) | ||
------------------------------------------------------------------------- | ||
This file is part of the Makuna/NeoPixelBus library. | ||
NeoPixelBus is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as | ||
published by the Free Software Foundation, either version 3 of | ||
the License, or (at your option) any later version. | ||
NeoPixelBus is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with NeoPixel. If not, see | ||
<http://www.gnu.org/licenses/>. | ||
-------------------------------------------------------------------------*/ | ||
#pragma once | ||
|
||
class NeoHueBlendBase | ||
{ | ||
protected: | ||
static float FixWrap(float value) | ||
{ | ||
if (value < 0.0f) | ||
{ | ||
value += 1.0f; | ||
} | ||
else if (value > 1.0f) | ||
{ | ||
value -= 1.0f; | ||
} | ||
return value; | ||
} | ||
}; | ||
|
||
class NeoHueBlendShortestDistance : NeoHueBlendBase | ||
{ | ||
public: | ||
static float HueBlend(float left, float right, float progress) | ||
{ | ||
float delta = right - left; | ||
float base = left; | ||
if (delta > 0.5f) | ||
{ | ||
base = right; | ||
delta = 1.0f - delta; | ||
progress = 1.0f - progress; | ||
} | ||
else if (delta < -0.5f) | ||
{ | ||
delta = 1.0f + delta; | ||
} | ||
return FixWrap(base + (delta) * progress); | ||
}; | ||
}; | ||
|
||
class NeoHueBlendLongestDistance : NeoHueBlendBase | ||
{ | ||
public: | ||
static float HueBlend(float left, float right, float progress) | ||
{ | ||
float delta = right - left; | ||
float base = left; | ||
if (delta < 0.5f && delta >= 0.0f) | ||
{ | ||
base = right; | ||
delta = 1.0f - delta; | ||
progress = 1.0f - progress; | ||
} | ||
else if (delta > -0.5f && delta < 0.0f) | ||
{ | ||
delta = 1.0f + delta; | ||
} | ||
return FixWrap(base + delta * progress); | ||
}; | ||
}; | ||
|
||
class NeoHueBlendClockwiseDirection : NeoHueBlendBase | ||
{ | ||
public: | ||
static float HueBlend(float left, float right, float progress) | ||
{ | ||
float delta = right - left; | ||
float base = left; | ||
if (delta < 0.0f) | ||
{ | ||
delta = 1.0f + delta; | ||
} | ||
|
||
return FixWrap(base + delta * progress); | ||
}; | ||
}; | ||
|
||
class NeoHueBlendCounterClockwiseDirection : NeoHueBlendBase | ||
{ | ||
public: | ||
static float HueBlend(float left, float right, float progress) | ||
{ | ||
float delta = right - left; | ||
float base = left; | ||
if (delta > 0.0f) | ||
{ | ||
delta = delta - 1.0f; | ||
} | ||
|
||
return FixWrap(base + delta * progress); | ||
}; | ||
}; |