forked from kovacsv/VisualScriptEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNUIE_Drawing.cpp
More file actions
173 lines (137 loc) · 2.73 KB
/
Copy pathNUIE_Drawing.cpp
File metadata and controls
173 lines (137 loc) · 2.73 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include "NUIE_Drawing.hpp"
namespace NUIE
{
Color::Color () :
Color (0, 0, 0)
{
}
Color::Color (unsigned char r, unsigned char g, unsigned char b) :
r (r),
g (g),
b (b)
{
}
void Color::Set (unsigned char newR, unsigned char newG, unsigned char newB)
{
r = newR;
g = newG;
b = newB;
}
unsigned char Color::GetR () const
{
return r;
}
unsigned char Color::GetG () const
{
return g;
}
unsigned char Color::GetB () const
{
return b;
}
bool Color::operator== (const Color& rhs) const
{
return r == rhs.r && g == rhs.g && b == rhs.b;
}
bool Color::operator!= (const Color& rhs) const
{
return !operator== (rhs);
}
BlendColor::BlendColor (const Color& color, double ratio) :
color (color),
ratio (ratio)
{
}
const Color& BlendColor::GetColor () const
{
return color;
}
double BlendColor::GetRatio () const
{
return ratio;
}
bool BlendColor::operator== (const BlendColor& rhs) const
{
return color == rhs.color && ratio == rhs.ratio;
}
bool BlendColor::operator!= (const BlendColor& rhs) const
{
return !operator== (rhs);
}
Pen::Pen (const Color & color, double thickness) :
color (color),
thickness (thickness)
{
}
const Color& Pen::GetColor () const
{
return color;
}
double Pen::GetThickness () const
{
return thickness;
}
bool Pen::operator== (const Pen& rhs) const
{
return color == rhs.color && thickness == rhs.thickness;
}
bool Pen::operator!= (const Pen& rhs) const
{
return !operator== (rhs);
}
Font::Font (const std::wstring& family, double size) :
family (family),
size (size)
{
}
const std::wstring& Font::GetFamily () const
{
return family;
}
double Font::GetSize () const
{
return size;
}
bool Font::operator== (const Font& rhs) const
{
return family == rhs.family && size == rhs.size;
}
bool Font::operator!= (const Font& rhs) const
{
return !operator== (rhs);
}
void AddColorToChecksum (NE::Checksum& checksum, const Color& color)
{
checksum.Add (color.GetR ());
checksum.Add (color.GetG ());
checksum.Add (color.GetB ());
}
void AddPenToChecksum (NE::Checksum& checksum, const Pen& pen)
{
AddColorToChecksum (checksum, pen.GetColor ());
checksum.Add (pen.GetThickness ());
}
void AddFontToChecksum (NE::Checksum& checksum, const Font& font)
{
checksum.Add (font.GetFamily ());
checksum.Add (font.GetSize ());
}
NE::Stream::Status ReadColor (NE::InputStream& inputStream, Color& color)
{
unsigned char r = 0;
unsigned char g = 0;
unsigned char b = 0;
inputStream.Read (r);
inputStream.Read (g);
inputStream.Read (b);
color.Set (r, g, b);
return inputStream.GetStatus ();
}
NE::Stream::Status WriteColor (NE::OutputStream& outputStream, const Color& color)
{
outputStream.Write (color.GetR ());
outputStream.Write (color.GetG ());
outputStream.Write (color.GetB ());
return outputStream.GetStatus ();
}
}