Skip to content

Commit

Permalink
Update folder tree
Browse files Browse the repository at this point in the history
  • Loading branch information
phthtgvi committed Nov 6, 2023
1 parent c9d0883 commit b162eea
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
*.bat
build
svg-reader
*.json
11 changes: 6 additions & 5 deletions src/Parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <SFML/Graphics.hpp>
#include <iostream>

#include "Circle.hpp"
#include "Ellipse.hpp"
#include "graphics/Circle.hpp"
#include "graphics/Ellipse.hpp"
#include "pugixml.hpp"

namespace parser {
Expand Down Expand Up @@ -72,9 +72,10 @@ namespace parser {
}
}

std::vector< sf::Shape* > parseSVG(std::string path) {
std::vector< Shape* > parseSVG(std::string path) {
pugi::xml_node svg = loadFile(path);
std::vector< sf::Shape* > shapes;
std::vector< Shape* > shapes;

for (pugi::xml_node tool = svg.first_child(); tool;
tool = tool.next_sibling()) {
sf::Color stroke_color = parseColor(tool, "stroke");
Expand Down Expand Up @@ -107,7 +108,7 @@ namespace parser {
return shapes;
}

void deleteShapes(std::vector< sf::Shape* >& shapes) {
void deleteShapes(std::vector< Shape* >& shapes) {
for (auto shape : shapes) {
delete shape;
}
Expand Down
File renamed without changes.
9 changes: 5 additions & 4 deletions src/Circle.hpp → src/graphics/Circle.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <SFML/Graphics.hpp>
#ifndef CIRCLE_H_
#define CIRCLE_H_
#ifndef CIRCLE_HPP_
#define CIRCLE_HPP_

#include "Shape.hpp"
#define SCALE 1000000

class Circle : public sf::Shape {
class Circle : public Shape {
private:
float radius;

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/Ellipse.hpp → src/graphics/Ellipse.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "Circle.hpp"
#ifndef ELLIPSE_H_
#define ELLIPSE_H_

#include "Circle.hpp"

class Ellipse : public Circle {
private:
sf::Vector2f radius;
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#include <SFML/Graphics.hpp>

#include "Circle.hpp"
#include "Ellipse.hpp"
#include "Parser.hpp"
#include "pugixml.hpp"

int main() {
constexpr int screen_width = 1600;
constexpr int screen_height = 900;

std::vector< sf::Shape* > shapes = parser::parseSVG("../sample/sample.svg");
std::vector< Shape* > shapes = parser::parseSVG("./sample/sample.svg");

sf::ContextSettings settings;
settings.antialiasingLevel = 16;
sf::RenderWindow window(sf::VideoMode(screen_width, screen_height),
Expand All @@ -24,12 +23,14 @@ int main() {
}

window.clear(sf::Color::White);

for (auto shape : shapes) {
window.draw(*shape);
}

window.display();
}

parser::deleteShapes(shapes);
// parser::deleteShapes(shapes);
return 0;
}

0 comments on commit b162eea

Please sign in to comment.