-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPixelBox.hpp
More file actions
171 lines (147 loc) · 4.22 KB
/
PixelBox.hpp
File metadata and controls
171 lines (147 loc) · 4.22 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
/*
** EPITECH PROJECT, 2018
** arcade
** File description:
** arcade
*/
/*!
* @file PixelBox.hpp
* @brief PixelBox class, similar to a rectangle of pixels
* @authors https://github.com/EPITECH-Strasbourg-2021/CPP-Arcade-Spec
*
* Class used by games and graphic libraries, similar to a rectangle of pixels.
* All functions must be implemented correctly for libraries to function properly.
*
*/
#pragma once
#include <string>
#include <vector>
#include "Color.hpp"
#include "Vect.hpp"
/*!
* @namespace Arcade
* @brief Arcade project namespace
*/
namespace Arcade {
/*!
* @class PixelBox
* @brief PixelBox class
*
* Class used to represent a rectangle of pixels
*
*/
class PixelBox {
public:
/*!
* @brief PixelBox class's constructor
* @param size : Vect<size_t> containing the width (x) and the height (y) of the pixelBox
* @param pos : Vect<size_t> containing both x and y offsets. Used to place the pixelBox on the rendering support
* @param col : the color with which the array of pixels inside the pixelBox will be created
*
* Creates a new pixelBox class instance.
* The first Vect<size_t> size argument defines the dimensions of the pixelBox.
* The second Vect<size_t> pos argument defines the coordinates
* of the pixelBox's position on the rendering support.
* It will be the offset applied when rendering it.
* The third argument defines the color in which the pixels will be created.
*
*/
explicit PixelBox(Vect<size_t> size = Vect<size_t>(),
Vect<size_t> pos = Vect<size_t>(),
Color col = Color(255, 255, 255, 255));
/*!
* @brief PixelBox class's destructor
*/
~PixelBox() = default;
/*!
* @brief PixelBox height's getter
* @return the pixelBox's height
*/
size_t getHeight() const;
/*!
* @brief PixelBox Y offset's getter
* @return the pixelBox Y's offset
*/
size_t getY() const;
/*!
* @brief PixelBox height setter
*/
void setHeight(size_t height);
/*!
* @brief PixelBox Y offset's getter
*/
void setY(size_t y);
/*!
* @brief PixelBox width's getter
* @return the pixelBox's height
*/
size_t getWidth() const;
/*!
* @brief PixelBox X offset's getter
* @return the pixelBox X's offset
*/
size_t getX() const;
/*!
* @brief PixelBox height's setter
*/
void setWidth(size_t width);
/*!
* @brief PixelBox X offset's setter
*/
void setX(size_t x);
/*!
* @brief PixelBox dimensions's getter
* @return a Vect<size_t> containing the width (x) and the height (y) of the pixelBox.
*/
Vect<size_t> getSize() const;
/*!
* @brief PixelBox dimensions's getter
* @param size : new dimensions of the pixelBox pixels's array
*
* Takes both new dimensions as parameter, within a Vect<size_t>
*
*/
void setSize(Vect<size_t> size);
/*!
* @brief PixelBox positions's getter
* @return a Vect<size_t> containing the offsetX (x) and the offsetY (y) of the pixelBox.
*/
Vect<size_t> getPos() const;
/*!
* @brief PixelBox positions's setter
* @param pos : new positions of the pixelBox pixels's array
*
* Takes both new positions as parameter, within a Vect<size_t>
*
*/
void setPos(Vect<size_t> pos);
/*!
* @brief Sets the color of the pixel at the given position
* @param pos : The position of the pixel to be modified
* @param col : The new color of the pixel to be modified
*/
void putPixel(Vect<size_t> pos, Color col);
/*!
* @brief Getter from pixel color to given position
* @param pos : The position of the pixel from which the color is requested
* @return the color of the requested pixel
*/
Color getPixel(Vect<size_t> pos) const;
/*!
* @brief Sets the color of many pixels within the pixelBox pixels's array
* @param pos : The position from which the new color has to be applied
* @param size : The dimensions of the chunk of pixels to be modified
* @param col : The new color to apply
*/
void putRect(Vect<size_t> pos, Vect<size_t> size, Color col);
/*!
* @brief Getter of the pixels array
* @return a vector of all the pixels of the pixelBox.
*/
std::vector<Color> const &getPixelArray() const;
private:
std::vector<Color> _colorFrame;
Vect<size_t> _size;
Vect<size_t> _pos;
};
};