diff --git a/keywords.txt b/keywords.txt
index 54a04df7..bddec9b1 100644
--- a/keywords.txt
+++ b/keywords.txt
@@ -11,6 +11,7 @@ RgbwColor KEYWORD1
RgbColor KEYWORD1
HslColor KEYWORD1
HsbColor KEYWORD1
+HtmlColor KEYWORD1
NeoGrbFeature KEYWORD1
NeoRgbwFeature KEYWORD1
NeoRgbFeature KEYWORD1
diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h
index 95e9b6f0..158dcdc6 100644
--- a/src/NeoPixelBus.h
+++ b/src/NeoPixelBus.h
@@ -30,6 +30,7 @@ License along with NeoPixel. If not, see
#include "internal/RgbColor.h"
#include "internal/HslColor.h"
#include "internal/HsbColor.h"
+#include "internal/HtmlColor.h"
#include "internal/RgbwColor.h"
#include "internal/NeoColorFeatures.h"
diff --git a/src/internal/HsbColor.cpp b/src/internal/HsbColor.cpp
index cc0b3b26..1ca06cc4 100644
--- a/src/internal/HsbColor.cpp
+++ b/src/internal/HsbColor.cpp
@@ -28,7 +28,7 @@ License along with NeoPixel. If not, see
#include "HsbColor.h"
-HsbColor::HsbColor(RgbColor color)
+HsbColor::HsbColor(const RgbColor& color)
{
// convert colors to float between (0.0 - 1.0)
float r = color.R / 255.0f;
diff --git a/src/internal/HsbColor.h b/src/internal/HsbColor.h
index bf20a4ea..bcc929ed 100644
--- a/src/internal/HsbColor.h
+++ b/src/internal/HsbColor.h
@@ -45,7 +45,7 @@ struct HsbColor
// ------------------------------------------------------------------------
// Construct a HsbColor using RgbColor
// ------------------------------------------------------------------------
- HsbColor(RgbColor color);
+ HsbColor(const RgbColor& color);
// ------------------------------------------------------------------------
// Construct a HsbColor that will have its values set in latter operations
diff --git a/src/internal/HslColor.cpp b/src/internal/HslColor.cpp
index 3842ab49..9e0f39a0 100644
--- a/src/internal/HslColor.cpp
+++ b/src/internal/HslColor.cpp
@@ -28,7 +28,7 @@ License along with NeoPixel. If not, see
#include "HslColor.h"
-HslColor::HslColor(RgbColor color)
+HslColor::HslColor(const RgbColor& color)
{
// convert colors to float between (0.0 - 1.0)
float r = color.R / 255.0f;
diff --git a/src/internal/HslColor.h b/src/internal/HslColor.h
index 54c620b5..5e7cd87c 100644
--- a/src/internal/HslColor.h
+++ b/src/internal/HslColor.h
@@ -47,7 +47,7 @@ struct HslColor
// ------------------------------------------------------------------------
// Construct a HslColor using RgbColor
// ------------------------------------------------------------------------
- HslColor(RgbColor color);
+ HslColor(const RgbColor& color);
// ------------------------------------------------------------------------
// Construct a HslColor that will have its values set in latter operations
diff --git a/src/internal/HtmlColor.h b/src/internal/HtmlColor.h
new file mode 100644
index 00000000..286ed7c1
--- /dev/null
+++ b/src/internal/HtmlColor.h
@@ -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
+.
+-------------------------------------------------------------------------*/
+#pragma once
+
+#include
+#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;
+};
+
diff --git a/src/internal/RgbColor.cpp b/src/internal/RgbColor.cpp
index 6bed4f04..c8e1c758 100644
--- a/src/internal/RgbColor.cpp
+++ b/src/internal/RgbColor.cpp
@@ -27,6 +27,7 @@ License along with NeoPixel. If not, see
#include "RgbColor.h"
#include "HslColor.h"
#include "HsbColor.h"
+#include "HtmlColor.h"
static float _CalcColor(float p, float q, float t)
{
@@ -47,7 +48,12 @@ static float _CalcColor(float p, float q, float t)
return p;
}
-RgbColor::RgbColor(HslColor color)
+RgbColor::RgbColor(const HtmlColor& color) :
+ R((color.Color >> 16) & 0xff), G((color.Color >> 8) & 0xff), B(color.Color & 0xff)
+{
+}
+
+RgbColor::RgbColor(const HslColor& color)
{
float r;
float g;
@@ -76,7 +82,7 @@ RgbColor::RgbColor(HslColor color)
B = (uint8_t)(b * 255.0f);
}
-RgbColor::RgbColor(HsbColor color)
+RgbColor::RgbColor(const HsbColor& color)
{
float r;
float g;
diff --git a/src/internal/RgbColor.h b/src/internal/RgbColor.h
index 1852c108..5a7c8300 100644
--- a/src/internal/RgbColor.h
+++ b/src/internal/RgbColor.h
@@ -29,6 +29,7 @@ License along with NeoPixel. If not, see
struct HslColor;
struct HsbColor;
+struct HtmlColor;
// ------------------------------------------------------------------------
// RgbColor represents a color object that is represented by Red, Green, Blue
@@ -55,15 +56,20 @@ struct RgbColor
{
};
+ // ------------------------------------------------------------------------
+ // Construct a RgbColor using HtmlColor
+ // ------------------------------------------------------------------------
+ RgbColor(const HtmlColor& color);
+
// ------------------------------------------------------------------------
// Construct a RgbColor using HslColor
// ------------------------------------------------------------------------
- RgbColor(HslColor color);
+ RgbColor(const HslColor& color);
// ------------------------------------------------------------------------
// Construct a RgbColor using HsbColor
// ------------------------------------------------------------------------
- RgbColor(HsbColor color);
+ RgbColor(const HsbColor& color);
// ------------------------------------------------------------------------
// Construct a RgbColor that will have its values set in latter operations