2011-09-13 15:14:12 +10:00
|
|
|
/*
|
|
|
|
* This file is part of libgim.
|
|
|
|
*
|
|
|
|
* libgim is free software: you can redistribute it and/or modify it under the
|
|
|
|
* terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* libgim is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2015-01-13 10:50:12 +11:00
|
|
|
* Copyright 2010-2015 Danny Robson <danny@nerdcruft.net>
|
2011-09-13 15:14:12 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UTIL_COLOUR_HPP
|
|
|
|
#define __UTIL_COLOUR_HPP
|
|
|
|
|
2015-03-06 01:15:52 +11:00
|
|
|
#include "coord.hpp"
|
2015-01-13 18:33:02 +11:00
|
|
|
|
2015-02-03 00:07:09 +11:00
|
|
|
#include "json/tree.hpp"
|
2011-09-13 15:14:12 +10:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace util {
|
2013-08-05 16:37:11 +10:00
|
|
|
/// An RGBA colour POD type.
|
2015-04-09 18:00:40 +10:00
|
|
|
template <size_t S, typename T>
|
2015-04-09 20:44:54 +10:00
|
|
|
struct colour : public coord::base<S,T,colour,coord::rgba> {
|
2015-04-09 18:00:40 +10:00
|
|
|
using coord::base<S,T,util::colour,coord::rgba>::base;
|
2015-04-09 20:45:55 +10:00
|
|
|
using base_t = coord::base<S,T,util::colour,coord::rgba>;
|
|
|
|
|
|
|
|
template <typename U>
|
|
|
|
colour<S,U>
|
|
|
|
cast (void) const;
|
2015-01-13 18:33:02 +11:00
|
|
|
|
2012-06-13 14:41:19 +10:00
|
|
|
static const colour WHITE;
|
|
|
|
static const colour BLACK;
|
2013-07-30 23:50:37 +10:00
|
|
|
static const colour RED;
|
|
|
|
static const colour BLUE;
|
|
|
|
static const colour GREEN;
|
2011-09-13 15:14:12 +10:00
|
|
|
};
|
|
|
|
|
2015-04-09 18:00:40 +10:00
|
|
|
// Convenience types
|
|
|
|
typedef colour<4,float> colour4f;
|
2015-01-13 18:33:02 +11:00
|
|
|
|
2015-04-09 18:00:40 +10:00
|
|
|
// Serialisation
|
2015-02-02 21:22:38 +11:00
|
|
|
const json::tree::node& operator>> (const json::tree::node&, util::colour4f&);
|
2015-04-09 20:44:54 +10:00
|
|
|
|
|
|
|
template <size_t S, typename T>
|
|
|
|
std::ostream& operator<< (std::ostream&, util::colour<S,T>);
|
2011-09-13 15:14:12 +10:00
|
|
|
}
|
|
|
|
|
2015-04-09 20:45:55 +10:00
|
|
|
#include "colour.ipp"
|
|
|
|
|
2011-09-13 15:14:12 +10:00
|
|
|
#endif
|