diff --git a/libs/openFrameworks/types/ofColor.h b/libs/openFrameworks/types/ofColor.h index f7b89136a68..5d1ef3e3e32 100644 --- a/libs/openFrameworks/types/ofColor.h +++ b/libs/openFrameworks/types/ofColor.h @@ -5,6 +5,8 @@ #include #include #include +#include + /// \class ofColor_ /// @@ -37,6 +39,20 @@ class ofColor_{ /// \param alpha The alpha component. ofColor_(float red, float green, float blue, float alpha = limit()); + /// \brief Construct an ofColor_ by using values in a vector + /// + /// \param list 1 item = The gray value (full alpha) + /// \param list 2 items = The gray value + alpha + /// \param list 3 items = The RGB values (full alpha) + /// \param list 4 items = The RGB values + alpha + template + ofColor_(std::vector list): ofColor_() { + if (list.size() == 1) set(list[0]); + if (list.size() == 2) set(list[0], list[1]); + if (list.size() == 3) set(list[0], list[1], list[2]); + if (list.size() == 4) set(list[0], list[1], list[2], list[3]); + } + /// \brief Construct a grayscale ofColor_ by specifying a single number. /// /// \param gray A grayscale value.