colour: add hsv field names

This commit is contained in:
Danny Robson 2015-04-09 21:50:22 +10:00
parent 7307d73bbc
commit e7fba43935
4 changed files with 10 additions and 7 deletions

View File

@ -29,9 +29,9 @@
namespace util { namespace util {
/// An RGBA colour POD type. /// An RGBA colour POD type.
template <size_t S, typename T> template <size_t S, typename T>
struct colour : public coord::base<S,T,colour,coord::rgba> { struct colour : public coord::base<S,T,colour,coord::rgba,coord::hsv> {
using coord::base<S,T,util::colour,coord::rgba>::base; using coord::base<S,T,util::colour,coord::rgba,coord::hsv>::base;
using base_t = coord::base<S,T,util::colour,coord::rgba>; using base_t = coord::base<S,T,util::colour,coord::rgba,coord::hsv>;
template <typename U> template <typename U>
colour<S,U> colour<S,U>

View File

@ -42,8 +42,8 @@ namespace util { namespace coord {
using init<S,T,tags...>::init; using init<S,T,tags...>::init;
base () = default; base () = default;
explicit base (T v) explicit base (T val)
{ std::fill (std::begin (this->data), std::end (this->data), v); } { std::fill (std::begin (this->data), std::end (this->data), val); }
base (const base<S,T,KLASS,tags...> &rhs) = default; base (const base<S,T,KLASS,tags...> &rhs) = default;
base& operator= (const base<S,T,KLASS,tags...> &rhs) = default; base& operator= (const base<S,T,KLASS,tags...> &rhs) = default;

View File

@ -24,6 +24,7 @@ namespace util { namespace coord {
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// tags for accessor names // tags for accessor names
struct rgba { }; struct rgba { };
struct hsv { };
struct xyzw { }; struct xyzw { };
struct stpq { }; struct stpq { };
struct whd { }; struct whd { };

View File

@ -48,18 +48,20 @@ namespace util { namespace coord {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
struct store<3,T,rgba> { struct store<3,T,rgba,hsv> {
union { union {
T data[3]; T data[3];
struct { T r,g,b; }; struct { T r,g,b; };
struct { T h,s,v; };
}; };
}; };
template <typename T> template <typename T>
struct store<4,T,rgba> { struct store<4,T,rgba,hsv> {
union { union {
T data[4]; T data[4];
struct { T r,g,b,a; }; struct { T r,g,b,a; };
struct { T h,s,v; };
}; };
}; };