Line | |
---|
1 | //////////////////////////////////////////////////////////////////////////////////////////
|
---|
2 | // COLOR.cpp
|
---|
3 | // function definitions for an RGBA color class
|
---|
4 | // You may use this code however you wish, but if you do, please credit me and
|
---|
5 | // provide a link to my website in a readme file or similar
|
---|
6 | // Downloaded from: www.paulsprojects.net
|
---|
7 | // Created: 20th July 2002
|
---|
8 | // Modified: 7th November 2002 - Some speed improvements
|
---|
9 | // - Removed clamping after adds etc. Do it yourself!
|
---|
10 | // To enable use with floating point color buffers
|
---|
11 | // - Corrected lerp (reversed f and 1-f)
|
---|
12 | //////////////////////////////////////////////////////////////////////////////////////////
|
---|
13 |
|
---|
14 | #include "Maths.h"
|
---|
15 |
|
---|
16 | void COLOR::ClampTo01()
|
---|
17 | {
|
---|
18 | if(r>1.0f)
|
---|
19 | r=1.0f;
|
---|
20 | if(r<0.0f)
|
---|
21 | r=0.0f;
|
---|
22 |
|
---|
23 | if(g>1.0f)
|
---|
24 | g=1.0f;
|
---|
25 | if(g<0.0f)
|
---|
26 | g=0.0f;
|
---|
27 |
|
---|
28 | if(b>1.0f)
|
---|
29 | b=1.0f;
|
---|
30 | if(b<0.0f)
|
---|
31 | b=0.0f;
|
---|
32 |
|
---|
33 | if(a>1.0f)
|
---|
34 | a=1.0f;
|
---|
35 | if(a<0.0f)
|
---|
36 | a=0.0f;
|
---|
37 | }
|
---|
38 |
|
---|
39 | COLOR operator*(float scaleFactor, const COLOR & rhs)
|
---|
40 | {
|
---|
41 | return rhs*scaleFactor;
|
---|
42 | }
|
---|
43 |
|
---|
44 | bool COLOR::operator ==(const COLOR & rhs) const
|
---|
45 | {
|
---|
46 | if(r != rhs.r)
|
---|
47 | return false;
|
---|
48 | if(g != rhs.g)
|
---|
49 | return false;
|
---|
50 | if(b != rhs.b)
|
---|
51 | return false;
|
---|
52 | if(a != rhs.a)
|
---|
53 | return false;
|
---|
54 |
|
---|
55 | return true;
|
---|
56 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.