forked from Makuna/NeoPixelBus
HtmlColor
This commit is contained in:
1 parent
6eba5a9615
commit
c7b07b43cd
9 files changed
+96
-8
No files matched your search
@@ -0,0 +1,74 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
HtmlColor provides a color object that can be directly consumed by NeoPixelBus
|
||||
|
||||
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
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "RgbColor.h"
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// HtmlColor represents a color object that is represented by a single uint32
|
||||
// value. It contains minimal routines and used primarily as a helper to
|
||||
// initialize other color objects
|
||||
// ------------------------------------------------------------------------
|
||||
struct HtmlColor
|
||||
{
|
||||
// ------------------------------------------------------------------------
|
||||
// Construct a HtmlColor using a single value (0-0xffffff)
|
||||
// This works well for hexidecimal color definitions
|
||||
// 0xff0000 = red, 0x00ff00 = green, and 0x0000ff = blue
|
||||
// ------------------------------------------------------------------------
|
||||
HtmlColor(uint32_t color) :
|
||||
Color(color)
|
||||
{
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Construct a HtmlColor using RgbColor
|
||||
// ------------------------------------------------------------------------
|
||||
HtmlColor(const RgbColor& color)
|
||||
{
|
||||
Color = color.R << 16 | color.G << 8 | color.B;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Construct a HtmlColor that will have its values set in latter operations
|
||||
// CAUTION: The Color member is not initialized and may not be consistent
|
||||
// ------------------------------------------------------------------------
|
||||
HtmlColor()
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Color member (0-0xffffff) where
|
||||
// 0xff0000 is red
|
||||
// 0x00ff00 is green
|
||||
// 0x0000ff is blue
|
||||
// ------------------------------------------------------------------------
|
||||
uint32_t Color;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user