summaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/src/color.h
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2021-09-20 18:15:14 -0500
committerMatt Strapp <matt@mattstrapp.net>2021-09-20 18:15:14 -0500
commit342403a02f8063903d0f38327430721d4d0ae331 (patch)
tree29d020a27bc16939c568dd4b29166566d1c0e658 /dev/MinGfx/src/color.h
parentFix parenthesis (diff)
downloadcsci4611-342403a02f8063903d0f38327430721d4d0ae331.tar
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.gz
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.bz2
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.lz
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.xz
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.zst
csci4611-342403a02f8063903d0f38327430721d4d0ae331.zip
Diffstat (limited to 'dev/MinGfx/src/color.h')
-rw-r--r--dev/MinGfx/src/color.h206
1 files changed, 103 insertions, 103 deletions
diff --git a/dev/MinGfx/src/color.h b/dev/MinGfx/src/color.h
index 553dc84..8444949 100644
--- a/dev/MinGfx/src/color.h
+++ b/dev/MinGfx/src/color.h
@@ -1,103 +1,103 @@
-/*
- This file is part of the MinGfx Project.
-
- Copyright (c) 2017,2018 Regents of the University of Minnesota.
- All Rights Reserved.
-
- Original Author(s) of this File:
- Dan Keefe, 2018, University of Minnesota
-
- Author(s) of Significant Updates/Modifications to the File:
- ...
- */
-
-#ifndef SRC_COLOR_H_
-#define SRC_COLOR_H_
-
-#include <iostream>
-#include <vector>
-
-namespace mingfx {
-
-
-/** Represents a 4-component (R,G,B,A) color, stored internally in a float array
- to be compatable with OpenGL. Example usage:
- ~~~
- Color black(0, 0, 0);
- Color white(1, 1, 1);
- Color gray(0.5, 0.5, 0.5);
- Color tranparent_red(1.0, 0.0, 0.0, 0.5);
- Color orange(1.0, 0.65, 0.0);
-
- float red_component_of_orange = orange[0];
- float green_component_of_orange = orange[1];
- float blue_component_of_orange = orange[2];
- float alpha_component_of_orange = orange[3];
-
- // Use value_ptr() to send the array of floats directly to OpenGL commands
- glColor4fv(orange.value_ptr());
- ~~~
- */
-class Color {
-public:
- /// Defaults to black
- Color();
-
- /// Constructs a color. Alpha defaults to 1.0 (completely opaque)
- Color(float red, float green, float blue, float alpha=1.0);
-
- /// Constructs a point given a pointer to float array
- Color(float *p);
-
- /// Constructs a point given a 3 or 4-element vector of floats
- Color(const std::vector<float> &vals);
-
- /// Copy constructor
- Color(const Color& p);
-
- /// Color destructor
- virtual ~Color();
-
- /// Check for equality
- bool operator==(const Color& p) const;
-
- /// Check for inequality
- bool operator!=(const Color& p) const;
-
- /// Assignment operator
- Color& operator=(const Color& p);
-
- /// Accesses the ith component of the color, stored in RGBA order.
- float operator[](const int i) const;
-
- /// Accesses the ith coordinate of the color, stored in RGBA order.
- float& operator[](const int i);
-
- /// Returns a const pointer to the raw data array
- const float * value_ptr() const;
-
- std::vector<float> ToVector() const;
-
- /// Linear interpolation between this color and another. Alpha=0.0 returns
- /// this color, and alpha=1.0 returns the other color, other values blend
- /// between the two via a linear interpolation on each color channel.
- Color Lerp(const Color &b, float alpha) const;
-
- /// Linear interpolation between two colors. Alpha=0.0 returns 'a' and
- /// alpha=1.0 returns 'b', other values blend between the two via a linear
- /// interpolation on each color channel.
- static Color Lerp(const Color &a, const Color &b, float alpha);
-
-
-private:
- float c[4];
-};
-
-
-std::ostream & operator<< ( std::ostream &os, const Color &c);
-std::istream & operator>> ( std::istream &is, Color &c);
-
-
-} // namespace
-
-#endif
+/*
+ This file is part of the MinGfx Project.
+
+ Copyright (c) 2017,2018 Regents of the University of Minnesota.
+ All Rights Reserved.
+
+ Original Author(s) of this File:
+ Dan Keefe, 2018, University of Minnesota
+
+ Author(s) of Significant Updates/Modifications to the File:
+ ...
+ */
+
+#ifndef SRC_COLOR_H_
+#define SRC_COLOR_H_
+
+#include <iostream>
+#include <vector>
+
+namespace mingfx {
+
+
+/** Represents a 4-component (R,G,B,A) color, stored internally in a float array
+ to be compatable with OpenGL. Example usage:
+ ~~~
+ Color black(0, 0, 0);
+ Color white(1, 1, 1);
+ Color gray(0.5, 0.5, 0.5);
+ Color tranparent_red(1.0, 0.0, 0.0, 0.5);
+ Color orange(1.0, 0.65, 0.0);
+
+ float red_component_of_orange = orange[0];
+ float green_component_of_orange = orange[1];
+ float blue_component_of_orange = orange[2];
+ float alpha_component_of_orange = orange[3];
+
+ // Use value_ptr() to send the array of floats directly to OpenGL commands
+ glColor4fv(orange.value_ptr());
+ ~~~
+ */
+class Color {
+public:
+ /// Defaults to black
+ Color();
+
+ /// Constructs a color. Alpha defaults to 1.0 (completely opaque)
+ Color(float red, float green, float blue, float alpha=1.0);
+
+ /// Constructs a point given a pointer to float array
+ Color(float *p);
+
+ /// Constructs a point given a 3 or 4-element vector of floats
+ Color(const std::vector<float> &vals);
+
+ /// Copy constructor
+ Color(const Color& p);
+
+ /// Color destructor
+ virtual ~Color();
+
+ /// Check for equality
+ bool operator==(const Color& p) const;
+
+ /// Check for inequality
+ bool operator!=(const Color& p) const;
+
+ /// Assignment operator
+ Color& operator=(const Color& p);
+
+ /// Accesses the ith component of the color, stored in RGBA order.
+ float operator[](const int i) const;
+
+ /// Accesses the ith coordinate of the color, stored in RGBA order.
+ float& operator[](const int i);
+
+ /// Returns a const pointer to the raw data array
+ const float * value_ptr() const;
+
+ std::vector<float> ToVector() const;
+
+ /// Linear interpolation between this color and another. Alpha=0.0 returns
+ /// this color, and alpha=1.0 returns the other color, other values blend
+ /// between the two via a linear interpolation on each color channel.
+ Color Lerp(const Color &b, float alpha) const;
+
+ /// Linear interpolation between two colors. Alpha=0.0 returns 'a' and
+ /// alpha=1.0 returns 'b', other values blend between the two via a linear
+ /// interpolation on each color channel.
+ static Color Lerp(const Color &a, const Color &b, float alpha);
+
+
+private:
+ float c[4];
+};
+
+
+std::ostream & operator<< ( std::ostream &os, const Color &c);
+std::istream & operator>> ( std::istream &is, Color &c);
+
+
+} // namespace
+
+#endif