summaryrefslogtreecommitdiff
path: root/lib/colors.h
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-22 01:20:29 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-22 01:20:29 -0400
commitdd2c47db3512658858685c83dd772603203aaab1 (patch)
treee029032fb62317237482844af9f1bbd3b5545c45 /lib/colors.h
parente74305e932e45c0d2e69fd1c0a7313662fc47375 (diff)
downloadc++-dd2c47db3512658858685c83dd772603203aaab1.tar.gz
c++-dd2c47db3512658858685c83dd772603203aaab1.tar.bz2
c++-dd2c47db3512658858685c83dd772603203aaab1.zip
potts now fully functional
Diffstat (limited to 'lib/colors.h')
-rw-r--r--lib/colors.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/colors.h b/lib/colors.h
new file mode 100644
index 0000000..04d39a8
--- /dev/null
+++ b/lib/colors.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "types.h"
+
+double hue_to_R(double theta) {
+ if (((M_PI / 3 <= theta) && (theta < 2 * M_PI / 3)) || ((4 * M_PI / 3 <= theta) && (theta < 5 * M_PI / 3))) {
+ return 1.0 - fabs(fmod(theta / (2 * M_PI / 6), 2) - 1.0);
+ } else if (((0 <= theta) && (theta < M_PI / 3)) || ((5 * M_PI / 3 <= theta) && (theta <= 2 * M_PI))) {
+ return 1.0;
+ } else {
+ return 0.0;
+ }
+}
+
+double hue_to_G(double theta) {
+ if (((0 <= theta) && (theta < M_PI / 3)) || ((M_PI <= theta) && (theta < 4 * M_PI / 3))) {
+ return 1.0 - fabs(fmod(theta / (2 * M_PI / 6), 2) - 1.0);
+ } else if (((M_PI / 3 <= theta) && (theta < 2 * M_PI / 3)) || ((2 * M_PI / 3 <= theta) && (theta < M_PI))) {
+ return 1.0;
+ } else {
+ return 0.0;
+ }
+}
+
+double hue_to_B(double theta) {
+ if (((2 * M_PI / 3 <= theta) && (theta < M_PI)) || ((5 * M_PI / 3 <= theta) && (theta <= 2 * M_PI))) {
+ return 1.0 - fabs(fmod(theta / (2 * M_PI / 6), 2) - 1.0);
+ } else if (((M_PI <= theta) && (theta < 4 * M_PI / 3)) || ((4 * M_PI / 3 <= theta) && (theta < 5 * M_PI / 3))) {
+ return 1.0;
+ } else {
+ return 0.0;
+ }
+}
+