From af62ef0ed591545c2af5df7e3d0816f13930f81b Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Tue, 3 Oct 2023 20:00:50 -0400 Subject: [PATCH 1/5] ofColor: constructor based on vector --- libs/openFrameworks/types/ofColor.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/openFrameworks/types/ofColor.h b/libs/openFrameworks/types/ofColor.h index bd8d789f186..3e508f28fe5 100644 --- a/libs/openFrameworks/types/ofColor.h +++ b/libs/openFrameworks/types/ofColor.h @@ -37,6 +37,20 @@ class ofColor_{ /// \param alpha The alpha component. ofColor_(float red, float green, float blue, float alpha = limit()); + /// \brief Construct an ofColor_ by using channel 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 item = The RGB values + alpha + template + ofColor_(std::vector list): ofColor_() { + if (list.size() == 1) set(ofColor_(list[0])); + else if (list.size() == 2) set(ofColor_(list[0], list[1])); + else if (list.size() == 3) set(ofColor_(list[0], list[1], list[2])); + else if (list.size() == 4) set(ofColor_(list[0], list[1], list[2], list[3])); + } + /// \brief Construct a grayscale ofColor_ by specifying a single number. /// /// \param gray A grayscale value. From 5c3848ec206a20e4859f8c306e54841878340758 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Tue, 3 Oct 2023 20:23:55 -0400 Subject: [PATCH 2/5] skip a constructor --- libs/openFrameworks/types/ofColor.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/openFrameworks/types/ofColor.h b/libs/openFrameworks/types/ofColor.h index 3e508f28fe5..7c468b79eeb 100644 --- a/libs/openFrameworks/types/ofColor.h +++ b/libs/openFrameworks/types/ofColor.h @@ -37,7 +37,7 @@ class ofColor_{ /// \param alpha The alpha component. ofColor_(float red, float green, float blue, float alpha = limit()); - /// \brief Construct an ofColor_ by using channel values in a vector + /// \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 @@ -45,10 +45,10 @@ class ofColor_{ /// \param list 4 item = The RGB values + alpha template ofColor_(std::vector list): ofColor_() { - if (list.size() == 1) set(ofColor_(list[0])); - else if (list.size() == 2) set(ofColor_(list[0], list[1])); - else if (list.size() == 3) set(ofColor_(list[0], list[1], list[2])); - else if (list.size() == 4) set(ofColor_(list[0], list[1], list[2], list[3])); + 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. From 7ed269be7f40bc421b68dacbe74ba1f6902ce3a1 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Tue, 3 Oct 2023 20:25:04 -0400 Subject: [PATCH 3/5] typo --- libs/openFrameworks/types/ofColor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/types/ofColor.h b/libs/openFrameworks/types/ofColor.h index 7c468b79eeb..6eaf567247a 100644 --- a/libs/openFrameworks/types/ofColor.h +++ b/libs/openFrameworks/types/ofColor.h @@ -42,7 +42,7 @@ class ofColor_{ /// \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 item = The RGB values + alpha + /// \param list 4 items = The RGB values + alpha template ofColor_(std::vector list): ofColor_() { if (list.size() == 1) set(list[0]); From f40187d9113c5afd268a67b6b1de27220d8b2f84 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Tue, 3 Oct 2023 23:14:33 -0400 Subject: [PATCH 4/5] missing vector? --- libs/openFrameworks/types/ofColor.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/openFrameworks/types/ofColor.h b/libs/openFrameworks/types/ofColor.h index 6eaf567247a..b11d818bf08 100644 --- a/libs/openFrameworks/types/ofColor.h +++ b/libs/openFrameworks/types/ofColor.h @@ -5,6 +5,8 @@ #include #include #include +#include + /// \class ofColor_ /// From eb8b9ce88681e8a5f49fb6d76f1f52148c06a096 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Tue, 3 Oct 2023 23:20:05 -0400 Subject: [PATCH 5/5] use class --- libs/openFrameworks/types/ofColor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/types/ofColor.h b/libs/openFrameworks/types/ofColor.h index b11d818bf08..0c416bb947f 100644 --- a/libs/openFrameworks/types/ofColor.h +++ b/libs/openFrameworks/types/ofColor.h @@ -45,7 +45,7 @@ class ofColor_{ /// \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 + template ofColor_(std::vector list): ofColor_() { if (list.size() == 1) set(list[0]); if (list.size() == 2) set(list[0], list[1]);