forked from mcneel/rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLBPColor.cpp
120 lines (95 loc) · 2.03 KB
/
LBPColor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "stdafx.h"
#include "LBPColor.h"
CLBPColor::CLBPColor()
{
m_Array[0] = 0.0;
m_Array[1] = 0.0;
m_Array[2] = 0.0;
m_Array[3] = 0.0;
}
CLBPColor::CLBPColor(float fRed, float fGreen, float fBlue, float fAlpha)
{
Set(fRed, fGreen, fBlue, fAlpha);
}
CLBPColor::CLBPColor(double dRed, double dGreen, double dBlue, double dAlpha)
{
Set(dRed, dGreen, dBlue, dAlpha);
}
CLBPColor::CLBPColor(int iRed, int iGreen, int iBlue, int iAlpha)
{
Set(iRed, iGreen, iBlue, iAlpha);
}
CLBPColor::CLBPColor(const CLBPColor& src)
{
*this=src;
}
CLBPColor& CLBPColor::operator=(const CLBPColor& src)
{
Set(src.DRed(), src.DGreen(), src.DBlue(), src.DAlpha());
return *this;
}
void CLBPColor::Set(float fRed, float fGreen, float fBlue, float fAlpha)
{
m_Array[0] = fRed;
m_Array[1] = fGreen;
m_Array[2] = fBlue;
m_Array[3] = fAlpha;
}
void CLBPColor::Set(double dRed, double dGreen, double dBlue, double dAlpha)
{
m_Array[0] = dRed;
m_Array[1] = dGreen;
m_Array[2] = dBlue;
m_Array[3] = dAlpha;
}
void CLBPColor::Set(int iRed, int iGreen, int iBlue, int iAlpha)
{
m_Array[0] = (double)iRed / 255.0;
m_Array[1] = (double)iGreen / 255.0;
m_Array[2] = (double)iBlue / 255.0;
m_Array[3] = (double)iAlpha / 255.0;
}
bool CLBPColor::operator== (const CLBPColor& c2) const
{
if(DRed()!=c2.DRed()) return false;
if(DGreen()!=c2.DGreen()) return false;
if(DBlue()!=c2.DBlue()) return false;
if(DAlpha()!=c2.DAlpha()) return false;
return TRUE;
}
bool CLBPColor::operator!= (const CLBPColor& c2) const
{
return !(*this==c2);
}
double CLBPColor::DRed() const
{
return m_Array[0];
}
double CLBPColor::DGreen() const
{
return m_Array[1];
}
double CLBPColor::DBlue() const
{
return m_Array[2];
}
double CLBPColor::DAlpha() const
{
return m_Array[3];
}
UINT CLBPColor::IRed() const
{
return (UINT)((DRed()*255.0)+0.01);
}
UINT CLBPColor::IGreen() const
{
return (UINT)((DGreen()*255.0)+0.01);
}
UINT CLBPColor::IBlue() const
{
return (UINT)((DBlue()*255.0)+0.01);
}
UINT CLBPColor::IAlpha() const
{
return (UINT)((DAlpha()*255.0+0.01));
}