colour: rename variables to r,g,b,a

for consistency with coord types
This commit is contained in:
Danny Robson 2015-01-13 10:50:12 +11:00
parent 04b22cb64d
commit 25f21a66e4
2 changed files with 16 additions and 16 deletions

View File

@ -28,12 +28,12 @@ using namespace util;
//-----------------------------------------------------------------------------
const util::colour util::colour::WHITE ({ 1, 1, 1, 1 });
const util::colour util::colour::BLACK ({ 0, 0, 0, 1 });
const util::colour util::colour::WHITE ({ 1.f, 1.f, 1.f, 1.f });
const util::colour util::colour::BLACK ({ 0.f, 0.f, 0.f, 1.f });
const util::colour util::colour::RED ({ 1, 0, 0, 1 });
const util::colour util::colour::GREEN ({ 0, 1, 0, 1 });
const util::colour util::colour::BLUE ({ 0, 0, 1, 1 });
const util::colour util::colour::RED ({ 1.f, 0.f, 0.f, 1.f });
const util::colour util::colour::GREEN ({ 0.f, 1.f, 0.f, 1.f });
const util::colour util::colour::BLUE ({ 0.f, 0.f, 1.f, 1.f });
//-----------------------------------------------------------------------------
@ -43,14 +43,14 @@ const util::colour util::colour::BLUE ({ 0, 0, 1, 1 });
//! json::type_error.
const json::node&
operator>> (const json::node &node, colour &c) {
c.red = static_cast<float> (node[0].as_number ());
c.green = static_cast<float> (node[1].as_number ());
c.blue = static_cast<float> (node[2].as_number ());
c.r = static_cast<float> (node[0].as_number ());
c.g = static_cast<float> (node[1].as_number ());
c.b = static_cast<float> (node[2].as_number ());
try {
c.alpha = static_cast<float> (node[3].as_number ());
c.a = static_cast<float> (node[3].as_number ());
} catch (...) {
c.alpha = 1;
c.a = 1;
}
return node;
@ -78,6 +78,6 @@ namespace util {
//-----------------------------------------------------------------------------
std::ostream&
util::operator<< (std::ostream &os, const util::colour &c) {
os << "colour(" << c.red << ", " << c.green << ", " << c.blue << ", " << c.alpha << ")";
os << "colour(" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ")";
return os;
}

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2010-2013 Danny Robson <danny@nerdcruft.net>
* Copyright 2010-2015 Danny Robson <danny@nerdcruft.net>
*/
#ifndef __UTIL_COLOUR_HPP
@ -27,10 +27,10 @@
namespace util {
/// An RGBA colour POD type.
struct colour {
float red;
float green;
float blue;
float alpha;
float r;
float g;
float b;
float a;
static const colour WHITE;
static const colour BLACK;