-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample.cpp
43 lines (32 loc) · 851 Bytes
/
example.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
#include "SFC/Svg.hpp"
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Window/Event.hpp>
int main() {
/* Create image */
sfc::SVGImage img;
/* Don't show debug lines */
img.setMode(sfc::DrawMode::NORMAL);
/* Load SVG image from file */
img.loadFromFile("media/car.svg");
/* Rasterize image */
img.rasterize().saveToFile("rasterized.png");
/* Move it by [10, 10] to make it more visible */
img.move({10, 10});
/* Create window */
sf::RenderWindow app(sf::VideoMode((img.getSize().x + 20) * 1, (img.getSize().y + 20) * 1), "sf-svg");
while(app.isOpen()) {
/* Handle events */
for(sf::Event ev; app.pollEvent(ev);) {
if(ev.type == sf::Event::Closed) {
app.close();
}
}
/* Clear window */
app.clear({20, 20, 20});
/* Draw SVG file */
app.draw(img);
/* Display */
app.display();
}
return 0;
}