Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

rgba.hxx

00001 
00002 // 
00003 // Copyright (C) 2006 James M. Lawrence.  All rights reserved.
00004 // 
00005 // software: esve-1.0.3
00006 // file: esve/base/dimn/rgba.hxx
00007 // 
00008 // Redistribution and use in source and binary forms, with or without
00009 // modification, are permitted provided that the following conditions
00010 // are met:
00011 // 
00012 // 1. Redistributions of source code must retain the above copyright
00013 //    notice, this list of conditions and the following disclaimer.
00014 // 
00015 // 2. The origin of this software must not be misrepresented; you must
00016 //    not claim that you wrote the original software.  If you use this
00017 //    software in a product, an acknowledgment in the product 
00018 //    documentation would be appreciated but is not required.
00019 // 
00020 // 3. Altered source versions must be plainly marked as such, and must
00021 //    not be misrepresented as being the original software.
00022 // 
00023 // 4. The name of the author may not be used to endorse or promote
00024 //    products derived from this software without specific prior written
00025 //    permission.
00026 // 
00027 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY,
00028 // AND WITH NO CLAIM AS TO ITS SUITABILITY FOR ANY PURPOSE.  IN NO EVENT
00029 // SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM WHATSOEVER MADE IN CONNECTION
00030 // TO THIS SOFTWARE.
00031 // 
00033 //
00034 // OpenGL-style RGBA color
00035 //
00036 
00037 #ifndef esve_base_dimn_rgba_hxx
00038 #define esve_base_dimn_rgba_hxx
00039 
00040 namespace esve { namespace base { namespace dimn {
00041 
00042 template< typename T_value_type >
00043 class rgba
00044 {
00045 private:
00046     typedef T_value_type m_value_type ;
00047 
00048     m_value_type mr ;
00049     m_value_type mg ;
00050     m_value_type mb ;
00051     m_value_type ma ;
00052 
00053 public:
00054     typedef m_value_type value_type ;
00055 
00056     struct from_hsva
00057     {
00058         value_type h ;
00059         value_type s ;
00060         value_type v ;
00061         value_type a ;
00062 
00063         from_hsva( value_type h_,
00064                    value_type s_,
00065                    value_type v_,
00066                    value_type a_ )
00067             : h(h_),
00068               s(s_),
00069               v(v_),
00070               a(a_) { }
00071     } ;
00072 
00073     rgba()
00074         : mr(0),
00075           mg(0),
00076           mb(0),
00077           ma(0) { }
00078 
00079     rgba( value_type r,
00080           value_type g,
00081           value_type b,
00082           value_type a )
00083         : mr(r),
00084           mg(g),
00085           mb(b),
00086           ma(a) { }
00087 
00088     rgba( const from_hsva & ) ;
00089 
00090     // compiler writes memberwise copy and assign
00091 
00092     value_type red() const
00093     {
00094         return mr ;
00095     }
00096 
00097     value_type green() const
00098     {
00099         return mg ;
00100     }
00101 
00102     value_type blue() const
00103     {
00104         return mb ;
00105     }
00106 
00107     value_type alpha() const
00108     {
00109         return ma ;
00110     }
00111 
00112     void red( value_type s )
00113     {
00114         mr = s ;
00115     }
00116 
00117     void green( value_type s )
00118     {
00119         mg = s ;
00120     }
00121 
00122     void blue( value_type s )
00123     {
00124         mb = s ;
00125     }
00126 
00127     void alpha( value_type s )
00128     {
00129         ma = s ;
00130     }
00131 
00132     const value_type* data() const
00133     {
00134         return &mr ;
00135     }
00136 } ;
00137 
00138 }}} // namespace esve::base::dimn
00139 
00140 #include <esve/base/dimn/rgba.template.cxx>
00141 
00142 #endif
00143 

Generated on Tue May 30 11:40:53 2006 for esve by doxygen 1.3.4