-
Notifications
You must be signed in to change notification settings - Fork 1
/
Pixel.cpp
65 lines (51 loc) · 1014 Bytes
/
Pixel.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
#include "Pixel.h"
#include <iostream>
Pixel::Pixel() {
}
Pixel::Pixel(int p, int q, Color col) {
x = p;
y = q;
c = col;
}
Pixel::~Pixel() {
}
Pixel::Pixel(const Pixel& other) {
x = other.x;
y = other.y;
c = other.c;
}
Color Pixel::get_color() const{
return c;
}
void Pixel::set_color(int x, int y, int z) {
c.set_red(x);
c.set_green(y);
c.set_blue(z);
}
void Pixel::set_color(Color c1) {
c = c1;
}
int Pixel::get_x() const{
return x;
}
int Pixel::get_y() const{
return y;
}
Pixel operator+(Pixel const &pixel1, Pixel const &pixel2) {
if(pixel1.get_x() == pixel2.get_x() && pixel1.get_y() == pixel2.get_y()) {
Color tmp_color = pixel1.get_color() + pixel2.get_color();
Pixel p(pixel1.get_x(), pixel1.get_y(), tmp_color);
return p;
}
return pixel1;
}
Pixel& Pixel::operator=(Pixel const &other) {
x = other.get_x();
y = other.get_y();
c = other.get_color();
return (*(this));
}
ostream& operator<<(ostream &os, Pixel &p) {
os<<p.c;
return os;
}