16#ifndef MiL_SVG_COMPOSITE_AND_LAYER_BASICS_H
17#define MiL_SVG_COMPOSITE_AND_LAYER_BASICS_H 1
25 const string& outbase)
28 area<> a = { deltax, deltay };
48 const string& outbase)
51 area<> a = { 2 * deltax, deltay };
84 const double rlen = 24.0)
87 const std::locale loc(
"");
88 const bool alphap = std::isalpha(firstc, loc);
95 cidx = (
static_cast<uint>(firstc) % 65) - 32;
97 const double deltac = double(std::min(a._M_width, a._M_height)) / maxc;
98 double deltax(deltac * cidx);
99 double deltay(deltac * cidx);
105 point_to_rect(obj, { a._M_width - deltax - rlen - deltac, 0 },
106 estyl, deltac, rlen);
110 estyl, deltac, rlen);
114 { a._M_width - rlen, a._M_height - deltay - rlen - deltac },
115 estyl, rlen, deltac);
127 std::ifstream ifs(ifile);
133 getline(ifs, xmlheader);
134 if (xmlheader.find(
"xml version") == string::npos)
135 ifs.seekg(0, ifs.beg);
137 std::ostringstream oss;
143 string m(
"svg_file_to_svg_insert:: insert nested SVG failed ");
146 throw std::runtime_error(
m);
159 auto svgepos = isvgpre.find(
"<svg version");
160 if (svgepos != string::npos)
164 isvg = isvgpre.substr(svgepos);
168 string m(
"element_to_svg_insert:: insert nested SVG failed of size: ");
169 m += std::to_string(isvgpre.size());
174 throw std::runtime_error(
m);
195 const point_2t origin,
const double origsize,
const double isize,
196 const double angled = 0,
const style& styl = k::no_style)
199 auto [ objx, objy ] = origin;
200 const int x = objx - (isize / 2);
201 const int y = objy - (isize / 2);
206 if (isize != origsize)
208 const double scalex(isize / origsize);
220 string ts(xformrotate + k::space + xformtranslate + k::space + xformscale);
240 const auto [ width, height ] = a;
241 const auto [ xo, yo ] = p;
243 bool outofbounds(
false);
246 if (xo > (width / 2))
247 x = xo - (width / 2);
252 if (yo > (height / 2))
253 y = yo - (height / 2);
258 throw std::runtime_error(
"nest_inner_svg_element_centered::out of bounds");
277 const double bleedxoffset = 0)
279 const double bleedpx =
get_dpi() * bleedin;
280 const double bleedpxo =
get_dpi() * (bleedin + (bleedxoffset / 2));
287 const point_2t p = { bleedpx, bleedpxo };
void start_element()
SVG element beginning boilerplate for outermost (containing) svg_element. Variable: unit,...
void add_raw(const string &raw)
void add_element(const element_base &e)
svg_element insert_svg_at(svg_element &obj, const string isvg, const point_2t origin, const double origsize, const double isize, const double angled=0, const style &styl=k::no_style)
Embed svg in group element.
color
Color enumerated as types.
svg_element make_svg_1_channel(const space_type deltax, const space_type deltay, const string &outbase)
Take input size and make a one channel (single-image) SVG form.
void paint_edges_with_char_index(svg_element &obj, const area<> a, const char firstc, const svg::color klr=color::duboisgreen2, const double rlen=24.0)
Paint the edges of a physical page. Assumes page is square. /.
double space_type
Base floating point type.
void composite_bleed_areas(svg_element &obj, const svg::select slxt, const double bleedin, const double bleedxoffset=0)
Composite frame on bleed. For printed objects with a center gutter, some intra-page adjustments are n...
void point_to_rect(svg_element &obj, const point_2t origin, style s, double width=4, double height=4, const string filterstr="")
Rectangle at this point.
string file_to_svg_insert(const string ifile)
Import svg file, convert it to svg_element for insertion. ifile is a plain SVG file with a 1:1 aspect...
svg_element make_svg_2_channel(const space_type deltax, const space_type deltay, const string &outbase)
Take input size and make a two channel (single-image) SVG form.
svg_element nest_inner_svg_element_centered(const svg_element &obj, const point_2t &p)
Take.
void make_2_channel_insert(svg_element &obj, string insert1, string insert2)
double & get_dpi()
Resolution of output display device.
void make_1_channel_insert(svg_element &obj, string insert1)
string element_to_svg_insert(const string isvgpre)
Import svg file, convert it to svg_element for insertion.
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space.
Datum consolidating style preferences.
void set_colors(const svg::color &klr)
Convenience function to set all colors at once.