-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElement.cpp
More file actions
38 lines (33 loc) · 1.03 KB
/
Copy pathElement.cpp
File metadata and controls
38 lines (33 loc) · 1.03 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
#include "Element.hpp"
Element::Element(unsigned int _height,unsigned int index, unsigned int elementCount,unsigned int sWidth,unsigned int sHeight, SDL_Renderer* _renderer){
height = _height;
rect.x = index * sWidth / elementCount;
rect.y = sHeight - (height * (sHeight / elementCount));
rect.w = sWidth / elementCount;
rect.h = height * (sHeight / elementCount);
renderer = _renderer;
drawRectangle(renderer,rect,Color(255,255,255));
updateScreen(renderer);
}
bool Element::operator < (const Element& e){
return height < e.height;
}
bool Element::operator > (const Element& e){
return !(*this < e);
}
Element& Element::operator =(const Element& e){
if(renderer==nullptr){
height=e.height;
rect=e.rect;
renderer=e.renderer;
}
else{
drawRectangle(renderer, rect, Color(0,0,0));
height=e.height;
rect.y=e.rect.y;
rect.h=e.rect.h;
drawRectangle(renderer, rect, Color(255,255,255));
updateScreen(renderer);
}
return *this;
}