16#ifndef MiL_SVG_BASE_TYPES_H
17#define MiL_SVG_BASE_TYPES_H 1
43 using enum_map_type = std::map<unit, std::string>;
45 static enum_map_type enum_map;
80template<
typename T1 = svg::space_type>
93 inline constexpr double
97 return leastside / rdenom;
109 atype lg = 0, sm = 0;
122 return area(twidth, theight);
129 atype lg = 0, sm = 0;
142 return area(twidth, theight);
192 const string space(
"; ");
193 std::ostringstream stream;
195 stream <<
"style=" << k::quote;
210 matrix(
double a,
double b,
double c,
double d,
double e,
double f)
212 std::ostringstream stream;
213 stream <<
"matrix(" << a << k::comma << b << k::comma << c << k::comma
214 << d << k::comma << e << k::comma << f << k::comma <<
")";
221 std::ostringstream stream;
222 stream <<
"rotate(" << deg <<
")";
229 std::ostringstream stream;
230 stream <<
"rotate(" << deg << k::comma << x << k::comma << y <<
")";
237 std::ostringstream stream;
238 stream <<
"scale(" << factor <<
")";
243 scale(
double factor1,
double factor2)
245 std::ostringstream stream;
246 stream <<
"scale(" << factor1 << k::comma << factor2 <<
")";
253 std::ostringstream stream;
254 stream <<
"skewX(" << factor <<
")";
261 std::ostringstream stream;
262 stream <<
"skewY(" << factor <<
")";
269 std::ostringstream stream;
270 stream <<
"translate(" << x << k::comma << y <<
")";
372 using enum_map_type = std::map<align, std::string>;
374 static enum_map_type enum_map;
375 if (enum_map.empty())
395 using enum_map_type = std::map<anchor, std::string>;
397 static enum_map_type enum_map;
398 if (enum_map.empty())
411 using enum_map_type = std::map<weight, std::string>;
413 static enum_map_type enum_map;
414 if (enum_map.empty())
429 using enum_map_type = std::map<baseline, std::string>;
431 static enum_map_type enum_map;
432 if (enum_map.empty())
452 using enum_map_type = std::map<property, std::string>;
454 static enum_map_type enum_map;
455 if (enum_map.empty())
466 const string name(
"__name");
467 const string size(
"__size");
468 const string anchor(
"__anchor");
469 const string align(
"__align");
470 const string len(
"__lentype");
472 std::string strip1 = \
473 R
"(font-family="__name" font-size="__size__lentype" text-anchor="__anchor" text-align="__align" )";
481 const std::string
weight(
"__weight");
482 const std::string
property(
"__prop");
484 std::string strip2 = \
485 R
"(font-weight="__weight" font-style="__prop")";
494 stripb +=
"dominant-baseline=";
500 return strip1 + stripb + strip2;
color
Color enumerated as types.
unit
Measurement abstraction for absolute (not relative) measurements.
@ px
Pixel where 1 pixel x 96 PPI = .26 mm.
@ pt
Point where 1 pixel x 1/72 dpi 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)
double space_type
Base floating point type.
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space.
constexpr point_2t center_point() const
Convenience function for finding center.
area to_portrait() const
Portrait, aka largest side is vertical.
area to_landscape() const
Landscape, aka largest side is horizontal.
constexpr double max_segment_size_n(const uint rdenom=2) const
Given.
Color quantified as integral RGB components in the range [0,255]. aka like Scalar in OpenCV.
static string to_string(color_qi s)
Additional path/line/polyline stroke styles.
Datum consolidating style preferences.
void set_colors(const svg::color &klr)
Convenience function to set all colors at once.
const std::string to_string(const baseline b) const
baseline
How to align text to the dominant-baseline. https://developer.mozilla.org/docs/Web/SVG/Attribute/domi...
@ none
Ignore this attribute.
@ central
For rotated text.
const std::string to_string(const align a) const
const std::string to_string(const anchor a) const
const std::string to_string(const property p) const
@ right
Right part of text block.
@ left
Left-most part of text block.
@ center
Center part of text block.
const std::string to_string(const weight w) const
anchor
How to align text to a given point.
@ middle
Center the middle of the text block at point.
@ inherit
Enclosing object or group.
@ end
End the text block at point.
@ start
Start the text block at point.
property
Face style variant. https://developer.mozilla.org/docs/Web/CSS/font-style.
weight
Weight as per CSS property.
typography use_style(const style s) const
const std::string add_attribute(const svg::unit utype=svg::unit::pixel) const