-
Notifications
You must be signed in to change notification settings - Fork 0
/
Svg.cpp
57 lines (48 loc) · 1.25 KB
/
Svg.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "Svg.h"
#include "Vector2.h"
CSvg::CSvg(
const std::string& rFileName,
const CVector2& rMinCoord,
const CVector2& rMaxCoord,
b8 bShouldCondense /* = false */,
CColor fillColor /* = CColor::sm_kBlack */,
CColor strokeColor /* = CColor::sm_kRed */,
f32 fStrokeWidth /* = 0.25f */) :
m_file (rFileName.c_str(), std::ios_base::trunc),
m_bShouldCondense (bShouldCondense),
m_FillColor (fillColor),
m_StrokeColor (strokeColor),
m_fStrokeWidth (fStrokeWidth)
{
if (IsOpen()) {
m_file << "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"" <<
rMinCoord.x << ' ' << rMinCoord.y << ' ' <<
rMaxCoord.x - rMinCoord.x << ' ' << rMaxCoord.y - rMinCoord.y << "\">" <<
GetOptionalNewLine();
}
}
CSvg::~CSvg() {
if (IsOpen()) {
m_file << "</svg>" << GetOptionalNewLine();
}
}
/*
inline const char* CSvg::GetOptionalSpace() const {
return m_bShouldCondense ? "" : " ";
}
inline const char* CSvg::GetOptionalNewLine() const {
return m_bShouldCondense ? "" : "\n";
}
inline bool CSvg::IsOpen() const {
return m_file.is_open();
}
inline bool CSvg::ShouldCondense() const {
return m_bShouldCondense;
}
//*/
CSvg& CSvg::operator<<(const std::string& rString) {
if (IsOpen()) {
m_file << rString;
}
return *this;
}