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 {
/// An RGBA colour POD type.
template <size_t S, typename T>
struct colour : public coord::base<S,T,colour,coord::rgba> {
using coord::base<S,T,util::colour,coord::rgba>::base;
using base_t = coord::base<S,T,util::colour,coord::rgba>;
struct colour : public coord::base<S,T,colour,coord::rgba,coord::hsv> {
using coord::base<S,T,util::colour,coord::rgba,coord::hsv>::base;
using base_t = coord::base<S,T,util::colour,coord::rgba,coord::hsv>;
template <typename U>
colour<S,U>

View File

@ -42,8 +42,8 @@ namespace util { namespace coord {
using init<S,T,tags...>::init;
base () = default;
explicit base (T v)
{ std::fill (std::begin (this->data), std::end (this->data), v); }
explicit base (T val)
{ std::fill (std::begin (this->data), std::end (this->data), val); }
base (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
struct rgba { };
struct hsv { };
struct xyzw { };
struct stpq { };
struct whd { };

View File

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