source: GTP/trunk/App/Demos/Illum/StochasticIteration/color.h @ 1808

Revision 1808, 1.5 KB checked in by szirmay, 18 years ago (diff)
Line 
1#pragma once
2
3//*************************************************************************
4// RGBA Color osztály
5//
6// Szirmay-Kalos László (szirmay@iit.bme.hu)
7// BME, Iranyitástechnika és Informatika Tanszék
8// 2003. Május
9//*************************************************************************
10#ifndef COLOR_H
11#define COLOR_H
12
13//===============================================================
14struct Color {
15//===============================================================
16        float R, G, B, A;
17 
18        Color( ) { }
19        Color( float R0, float G0, float B0, float A0 = 1.0 ) { R = R0; G = G0; B = B0; A = A0; }
20       
21        Color operator*( const Color& c ) {
22                float r = R * c.R, g = G * c.G, b = B * c.B, a = A * c.A;
23                return Color(r, g, b, a);
24        }
25
26        Color operator+( const Color& c ) { // színek összeadása
27                float r = R + c.R, g = G + c.G, b = B + c.B, a = A + c.A;
28                return Color(r, g, b, a);
29        }
30
31        Color operator*( float f ) {        // színek szorzása
32                return Color( R * f, G * f, B * f, A * f );
33        }
34
35        void operator+=( const Color& c ) {
36                R += c.R; G += c.G; B += c.B; A += c.A;
37        }
38
39        void operator*=( float f ) { R *= f; G *= f; B *= f; A *= f; }
40
41        Color operator-( const Color& c ) {
42                float r = R - c.R, g = G - c.G, b = B - c.B, a = A - c.A;
43                return Color(r, g, b, a);
44        }
45
46        Color operator/( float f ) {
47                return Color( R/f, G/f, B/f, A/f );
48        }
49
50        float Lum( ) { return (R + G + B)/3; }
51
52        float * GetArray() { return &R; }
53        float Red() { return R; }
54        float Green() { return G; }
55        float Blue() { return B; }
56};
57
58#endif
Note: See TracBrowser for help on using the repository browser.