-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.cpp
More file actions
47 lines (41 loc) · 1.43 KB
/
Copy pathdisplay.cpp
File metadata and controls
47 lines (41 loc) · 1.43 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
#include "display.h"
using namespace std;
void drawGrid(int gridx, int gridy, int *graph, Wire *W)
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Grid");
vector<vector<sf::RectangleShape>> grid(gridx);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
sf::Vector2f cellSize((float)800.0 / gridx, (float)600.0 / gridy);
for (int i = 0; i < gridx; i++)
{
grid[i] = vector<sf::RectangleShape>(gridy);
for (int j = 0; j < gridy; j++)
{
grid[i][j].setSize(cellSize);
grid[i][j].setFillColor(sf::Color::White);
if (graph[gridy * i + j] == -1)
{
grid[i][j].setFillColor(sf::Color::Black);
}
else if (graph[gridy * i + j] != -2)
{
int ind = graph[gridy * i + j];
grid[i][j].setFillColor(sf::Color(W[ind].r, W[ind].g, W[ind].b));
}
grid[i][j].setOutlineColor(sf::Color::Black);
grid[i][j].setOutlineThickness(1.0f);
grid[i][j].setPosition(i * cellSize.x + 5.0f, j * cellSize.y + 5.0f);
window.draw(grid[i][j]);
}
}
window.display();
}
}