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

View File

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