File tree Expand file tree Collapse file tree
libs/openFrameworks/types Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99#include < glm/ext/scalar_common.hpp>
1010#include < glm/vec3.hpp>
1111#include < iostream>
12+ #include < limits>
13+ #include < vector>
1214
1315// / \class ofColor_
1416// /
@@ -41,6 +43,20 @@ class ofColor_{
4143 // / \param alpha The alpha component.
4244 ofColor_ (float red, float green, float blue, float alpha = limit());
4345
46+ // / \brief Construct an ofColor_ by using values in a vector
47+ // /
48+ // / \param list 1 item = The gray value (full alpha)
49+ // / \param list 2 items = The gray value + alpha
50+ // / \param list 3 items = The RGB values (full alpha)
51+ // / \param list 4 items = The RGB values + alpha
52+ template <class InitType >
53+ ofColor_ (std::vector<InitType> list): ofColor_() {
54+ if (list.size () == 1 ) set (list[0 ]);
55+ if (list.size () == 2 ) set (list[0 ], list[1 ]);
56+ if (list.size () == 3 ) set (list[0 ], list[1 ], list[2 ]);
57+ if (list.size () == 4 ) set (list[0 ], list[1 ], list[2 ], list[3 ]);
58+ }
59+
4460 // / \brief Construct a grayscale ofColor_ by specifying a single number.
4561 // /
4662 // / \param gray A grayscale value.
You can’t perform that action at this time.
0 commit comments