Repository navigation
Expand file tree
/
Copy pathSvgShapes.hpp
More file actions
61 lines (53 loc) · 1.7 KB
/
Copy pathSvgShapes.hpp
File metadata and controls
61 lines (53 loc) · 1.7 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
// Created by Gábor Bácsi
// 4/7/2024
#pragma once
#include "type_defines.h"
#include <fstream>
#include <string>
#include <vector>
class SvgShape {
public:
virtual ~SvgShape() = default;
virtual void plot(std::ofstream& svgStream, VECTOR2D offset, float scale, float canvasHeight) = 0;
};
class SvgLine : public SvgShape {
public:
SvgLine(VECTOR2D a, VECTOR2D b, const std::string& color, float strokeWidth);
void plot(std::ofstream& svgStream, VECTOR2D offset, float scale, float canvasHeight) override;
private:
VECTOR2D _A, _B;
std::string _color;
float _strokeWidth;
};
class SvgCircle : public SvgShape {
public:
SvgCircle(VECTOR2D center, float r, const std::string& color);
void plot(std::ofstream& svgStream, VECTOR2D offset, float scale, float canvasHeight) override;
private:
VECTOR2D _center;
std::string _color;
float _radius;
};
class SvgPolygon : public SvgShape {
public:
SvgPolygon(std::vector<VECTOR2D> vertices, std::vector<int> indices, const std::string& name, const std::string& fillColor, const std::string& strokeColor, float strokeWidth, bool triangulatedIndices, bool animated);
void plot(std::ofstream& svgStream, VECTOR2D offset, float scale, float canvasHeight) override;
private:
std::string _name;
std::vector<VECTOR2D> _vertices;
std::vector<int> _indices;
float _strokeWidth;
std::string _fillColor, _strokeColor;
bool _animated;
bool _triangulated;
};
class SvgText : public SvgShape {
public:
SvgText(VECTOR2D position, const std::string& text, const std::string& color, int size);
void plot(std::ofstream& svgStream, VECTOR2D offset, float scale, float canvasHeight) override;
private:
VECTOR2D _position;
std::string _text;
int _size;
std::string _fillColor;
};