opennurbs_color.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #if !defined(OPENNURBS_COLOR_INC_)
00018 #define OPENNURBS_COLOR_INC_
00019 
00021 //
00022 // Class ON_Color
00023 // 
00024 class ON_CLASS ON_Color
00025 {
00026 public:
00027         // Constructors & Conversions -     also default copy and assignment    
00028 
00029   static const ON_Color UnsetColor; // 0xFFFFFFFF
00030 
00031   // Default is R = 0, G = 0, B = 0, A = 0
00032         ON_Color();
00033 
00034   // Sets A = 0
00035         ON_Color(
00036     int red,   // ( 0 to 255 )
00037     int green, // ( 0 to 255 )
00038     int blue   // ( 0 to 255 )
00039     );
00040 
00041         ON_Color(
00042     int red,   // ( 0 to 255 )
00043     int green, // ( 0 to 255 )
00044     int blue,  // ( 0 to 255 )
00045     int alpha  // ( 0 to 255 )  (0 = opaque, 255 = transparent)
00046     );
00047 
00048   // Construct from Windows COLORREF
00049         ON_Color(unsigned int);
00050 
00051         // Conversion to Windows COLORREF
00052   operator unsigned int() const;        
00053 
00054   /*
00055   Description:
00056     Call this function when the color is needed in a 
00057     Windows COLORREF format with alpha = 0;
00058   Returns
00059     A Windows COLOREF with alpha = 0.
00060   */
00061   unsigned int WindowsRGB() const;
00062 
00063   // < 0 if this < arg, 0 ir this==arg, > 0 if this > arg
00064   int Compare( const ON_Color& ) const; 
00065 
00066         int Red()   const; // ( 0 to 255 )
00067         int Green() const; // ( 0 to 255 )
00068         int Blue()  const; // ( 0 to 255 )
00069   int Alpha() const; // ( 0 to 255 ) (0 = opaque, 255 = transparent)
00070 
00071         double FractionRed()   const; // ( 0.0 to 1.0 )
00072         double FractionGreen() const; // ( 0.0 to 1.0 )
00073         double FractionBlue()  const; // ( 0.0 to 1.0 )
00074         double FractionAlpha() const; // ( 0.0 to 1.0 ) (0.0 = opaque, 1.0 = transparent)
00075 
00076   void SetRGB(
00077     int red,   // red in range 0 to 255
00078     int green, // green in range 0 to 255
00079     int blue   // blue in range 0 to 255
00080     );
00081 
00082   void SetFractionalRGB(
00083     double red,   // red in range 0.0 to 1.0
00084     double green, // green in range 0.0 to 1.0
00085     double blue   // blue in range 0.0 to 1.0
00086     );
00087 
00088   void SetAlpha(
00089     int alpha // alpha in range 0 to 255 (0 = opaque, 255 = transparent)
00090     );
00091 
00092   void SetFractionalAlpha(
00093     double alpha // alpha in range 0.0 to 1.0 (0.0 = opaque, 1.0 = transparent)
00094     );
00095 
00096   void SetRGBA(
00097     int red,   // red in range 0 to 255
00098     int green, // green in range 0 to 255
00099     int blue,  // blue in range 0 to 255
00100     int alpha  // alpha in range 0 to 255 (0 = opaque, 255 = transparent)
00101     );
00102 
00103   // input args
00104   void SetFractionalRGBA(
00105     double red,   // red in range 0.0 to 1.0
00106     double green, // green in range 0.0 to 1.0
00107     double blue,  // blue in range 0.0 to 1.0
00108     double alpha  // alpha in range 0.0 to 1.0 (0.0 = opaque, 1.0 = transparent)
00109     );
00110 
00111   // Hue() returns an angle in the range 0 to 2*pi 
00112   //
00113   //           0 = red, pi/3 = yellow, 2*pi/3 = green, 
00114   //           pi = cyan, 4*pi/3 = blue,5*pi/3 = magenta,
00115   //           2*pi = red
00116   double Hue() const;
00117 
00118   // Returns 0.0 (gray) to 1.0 (saturated)
00119   double Saturation() const;
00120 
00121   // Returns 0.0 (black) to 1.0 (white)
00122   double Value() const;
00123 
00124   void SetHSV( 
00125          double h, // hue in radians 0 to 2*pi
00126          double s, // satuation 0.0 = gray, 1.0 = saturated
00127          double v // value     
00128          );
00129 
00130 private:
00131   // m_color is in Windows COLORREF format.
00132   //
00133   //  0xaabbggrr,  rr= red component 0-255, etc. (little endian order)
00134   //               aa=0 means opaque, aa=255 means transparent.
00135         unsigned int m_color;
00136 };
00137 
00138 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:00