#pragma once //************************************************************************* // RGBA Color osztály // // Szirmay-Kalos László (szirmay@iit.bme.hu) // BME, Iranyitástechnika és Informatika Tanszék // 2003. Május //************************************************************************* #ifndef COLOR_H #define COLOR_H //=============================================================== struct Color { //=============================================================== float R, G, B, A; Color( ) { } Color( float R0, float G0, float B0, float A0 = 1.0 ) { R = R0; G = G0; B = B0; A = A0; } Color operator*( const Color& c ) { float r = R * c.R, g = G * c.G, b = B * c.B, a = A * c.A; return Color(r, g, b, a); } Color operator+( const Color& c ) { // színek összeadása float r = R + c.R, g = G + c.G, b = B + c.B, a = A + c.A; return Color(r, g, b, a); } Color operator*( float f ) { // színek szorzása return Color( R * f, G * f, B * f, A * f ); } void operator+=( const Color& c ) { R += c.R; G += c.G; B += c.B; A += c.A; } void operator*=( float f ) { R *= f; G *= f; B *= f; A *= f; } Color operator-( const Color& c ) { float r = R - c.R, g = G - c.G, b = B - c.B, a = A - c.A; return Color(r, g, b, a); } Color operator/( float f ) { return Color( R/f, G/f, B/f, A/f ); } float Lum( ) { return (R + G + B)/3; } float * GetArray() { return &R; } float Red() { return R; } float Green() { return G; } float Blue() { return B; } }; #endif