#include "rays/color.h" namespace Rays { Color::Color (float value, float alpha) { set(value, alpha); } Color::Color (float red, float green, float blue, float alpha) { set(red, green, blue, alpha); } Color Color::dup () const { return *this; } Color& Color::set (float value, float alpha) { return set(value, value, value, alpha); } Color& Color::set (float red, float green, float blue, float alpha) { this->red = red; this->green = green; this->blue = blue; this->alpha = alpha; return *this; } bool Color::get (float* red, float* green, float* blue, float* alpha) const { if (!red && !green && !blue && !alpha) return false; if (red) *red = this->red; if (green) *green = this->green; if (blue) *blue = this->blue; if (alpha) *alpha = this->alpha; return true; } float* Color::array () { return (float*) this; } const float* Color::array () const { return const_cast(this)->array(); } Color::operator bool () const { return red >= 0 && green >= 0 && blue >= 0 && alpha >= 0; } bool Color::operator ! () const { return !operator bool(); } }// Rays