16#ifndef MiL_SVG_ELEMENTS_COMPONENTS_H
17#define MiL_SVG_ELEMENTS_COMPONENTS_H 1
36 string filename(
_M_name +
".svg");
37 std::ofstream f(filename);
38 if (!f.is_open() || !f.good())
39 throw std::runtime_error(
"svg_element::write fail");
42 catch(std::exception& e)
54 const string start = R
"_delimiter_(<?xml version="1.0" encoding="utf-8"?>
55<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
58 xmlns="http://www.w3.org/2000/svg"
59 xmlns:xlink="http://www.w3.org/1999/xlink"
60 xmlns:html="http://www.w3.org/1999/xhtml"
63 const string id(
"__id");
64 const string unit(
"__unit");
65 const string width(
"__width");
66 const string height(
"__height");
68 string strip = R
"_delimiter_(id="__id" x="0__unit" y="0__unit"
69width="__width__unit" height="__height__unit"
70viewBox="0 0 __width __height" enable-background="new 0 0 __width __height" role="img">
77 const string wunit = width +
unit;
78 const string hunit = height +
unit;
105 const string id(
"__id");
106 string start = R
"_delimiter_(<svg id="__id" )_delimiter_";
109 const string unit(
"__unit");
110 const string width(
"__width");
111 const string height(
"__height");
112 const string dwidth(
"__dwidth");
113 const string dheight(
"__dheight");
114 const string px(
"__x");
115 const string py(
"__y");
116 string strip = R
"_delimiter_(viewBox="0 0 __width __height" x="__x__unit" y="__y__unit" width="__dwidth__unit" height="__dheight__unit" )_delimiter_";
122 const auto [ dw, dh ] = destarea;
123 const auto [
x, y ] = p;
132 string m(
"svg_element::start_element error buffer is not empty: " );
136 throw std::runtime_error(
m);
145 const bool colornonep = nostr == fillstr;
158 const string f = R
"_delimiter_(<defs>
159 <filter id="gblur10" x="0" y="0">
160 <feGaussianBlur in="SourceGraphic" stdDeviation="10" />
161 <feOffset dx="0" dy="0" />
163 <filter id="gblur20" x="0" y="0">
164 <feGaussianBlur in="SourceGraphic" stdDeviation="20" />
165 <feOffset dx="0" dy="0" />
167 <filter id="gblur10y" x="0" y="0">
168 <feGaussianBlur in="SourceGraphic" stdDeviation="0, 10" />
169 <feOffset dx="0" dy="0" />
171 <filter id="gblur20y" x="0" y="0">
172 <feGaussianBlur in="SourceGraphic" stdDeviation="0, 20" />
173 <feOffset dx="0" dy="0" />
stream_type _M_sstream
Virtual, only one buffer.
void add_style(const style &sty)
void finish_element()
SVG element end boilerplate.
void start(const string &desc="", const bool autoszp=false)
void start_element(void)
Default.
void add_title(const string &t)
bool empty()
Empty when the output buffer is.
void add_element(const element_base &e)
unit
Measurement abstraction for absolute (not relative) measurements.
@ px
Pixel where 1 pixel x 96 PPI = .26 mm.
const string to_string(const unit e)
void string_replace(std::string &target, const std::string &match, const std::string &replace)
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space, space_type defaults to double.
Datum consolidating style preferences.