-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphDisplay2.cpp
More file actions
112 lines (102 loc) · 3.04 KB
/
graphDisplay2.cpp
File metadata and controls
112 lines (102 loc) · 3.04 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
//
// graphDisplay2.cpp for in /home/antoine/rendu/Piscine_cpp/cpp_gkrellm
//
// Made by antoine
// Login <antoine.roche@epitech.eu>
//
// Started on Sun Jan 22 09:29:26 2017 antoine
// Last update Sun Jan 22 09:34:29 2017 antoine
//
#include <iostream>
#include <string>
#include <sstream>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "Infos.hpp"
#include "Core.hpp"
#include "User.hpp"
#include "graphDisplay.hpp"
void print_shape(sf::RenderWindow *window, int _x, int _size)
{
sf::RectangleShape rectangle;
rectangle.setSize(sf::Vector2f(280, _size));
rectangle.setOutlineColor(sf::Color::Black);
rectangle.setOutlineThickness(3);
rectangle.setPosition(10, _x);
window->draw(rectangle);
}
void print_title(sf::RenderWindow *window, std::string _text, int _x)
{
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Text text;
text.setFont(font);
text.setString(_text);
text.setCharacterSize(14);
text.setColor(sf::Color::Red);
sf::FloatRect textRect = text.getLocalBounds();
text.setOrigin(textRect.left + textRect.width/2.0f,
textRect.top + textRect.height/2.0f);
text.setPosition(sf::Vector2f(300/2.0f, _x));
window->draw(text);
}
void print_text(sf::RenderWindow *window, std::string _text, int _x)
{
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Text text;
text.setFont(font);
text.setString(_text);
text.setCharacterSize(12);
text.setColor(sf::Color::Black);
sf::FloatRect textRect = text.getLocalBounds();
text.setOrigin(textRect.left + textRect.width/2.0f,
textRect.top + textRect.height/2.0f);
text.setPosition(sf::Vector2f(300/2.0f, _x));
window->draw(text);
}
void print_shape2(sf::RenderWindow *window, int _x, int _y, int _sizex, int _sizey, int value)
{
sf::RectangleShape rectangle;
rectangle.setSize(sf::Vector2f(_sizey, _sizex));
rectangle.setOutlineColor(sf::Color::Black);
if (value == 0)
rectangle.setFillColor(sf::Color::White);
else if (value <= 10 && value != 0)
rectangle.setFillColor(sf::Color::Blue);
else if (value <= 25 && value > 10)
rectangle.setFillColor(sf::Color::Green);
else if (value < 50 && value > 25)
rectangle.setFillColor(sf::Color::Yellow);
else
rectangle.setFillColor(sf::Color::Red);
rectangle.setOutlineThickness(3);
rectangle.setPosition(_y, _x);
window->draw(rectangle);
}
void print_title2(sf::RenderWindow *window, std::string _text, int _x, int _y)
{
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Text text;
text.setFont(font);
text.setString(_text);
text.setCharacterSize(25);
text.setColor(sf::Color::Black);
text.setStyle(sf::Text::Bold | sf::Text::Underlined);
text.setPosition(_y, _x);
window->draw(text);
}
void print_text2(sf::RenderWindow *window, std::string _text, int _x, int _y)
{
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Text text;
text.setFont(font);
text.setString(_text);
text.setCharacterSize(65);
text.setColor(sf::Color::Red);
text.setStyle(sf::Text::Bold | sf::Text::Underlined);
text.setPosition(_y, _x);
window->draw(text);
}