source: trunk/packages/vizservers/nanovis/Color.h @ 3464

Last change on this file since 3464 was 3177, checked in by mmc, 7 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 * Color.h: RGBA color class
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16#ifndef COLOR_H
17#define COLOR_H
18
19class Color 
20{
21public:
22    Color();
23
24    Color(double r, double g, double b);
25
26    ~Color();
27
28    Color(const Color& c);
29
30    Color& operator=(const Color& c);
31
32    void getRGB(unsigned char *result);
33
34    void getRGB(float *result);
35
36    double r() const
37    {
38        return _r;
39    }
40
41    double g() const
42    {
43        return _g;
44    }
45
46    double b() const
47    {
48        return _b;
49    }
50
51    /// Limits the color to be in range of [0,1]
52    void clamp();
53
54    Color operator*(const Color& other) const;
55
56    Color operator*(double k) const;
57
58    Color operator+(const Color& other) const;
59
60    friend Color operator*(double k, const Color& other);
61
62private:
63    double _r;  ///< Red component
64    double _g;  ///< Green component
65    double _b;  ///< Blue component
66};
67
68// This is NOT member operator. It's used so we can write (k*V),
69// not only (V*k) (V-vector k-scalar)
70inline Color operator*(double k, const Color& c)
71{
72    return Color(c._r * k, c._g * k, c._b * k);
73}
74
75#endif
Note: See TracBrowser for help on using the repository browser.