Close SVG file when the object gets deallocated.

This commit is contained in:
bubnikv 2016-04-15 17:57:38 +02:00
parent 3a0172888a
commit 83166a7ff3
2 changed files with 3 additions and 0 deletions

View file

@ -204,6 +204,7 @@ SVG::Close()
{
fprintf(this->f, "</svg>\n");
fclose(this->f);
this->f = NULL;
printf("SVG written to %s\n", this->filename.c_str());
}

View file

@ -17,6 +17,8 @@ class SVG
SVG(const char* filename);
SVG(const char* filename, const BoundingBox &bbox);
~SVG() { if (f != NULL) Close(); }
void draw(const Line &line, std::string stroke = "black", coord_t stroke_width = 0);
void draw(const ThickLine &line, const std::string &fill, const std::string &stroke, coord_t stroke_width = 0);
void draw(const Lines &lines, std::string stroke = "black");