Sha256: d21e6908c7e9112d160b7480084f225aa3d93a64aa31dce137f104264972a388

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

#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<Color*>(this)->array();
	}

	Color::operator bool () const
	{
		return red >= 0 && green >= 0 && blue >= 0 && alpha >= 0;
	}

	bool
	Color::operator ! () const
	{
		return !operator bool();
	}


}// Rays

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rays-0.1.6 src/color.cpp
rays-0.1.5 src/color.cpp
rays-0.1.4 src/color.cpp