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);
189 using enum_map_type = std::map<marker_shape, std::string>;
191 static enum_map_type enum_map;
192 if (enum_map.empty())
255 using std::to_string;
259 const uint da_sz = lsize + 1;
270 const string space(
"; ");
271 std::ostringstream stream;
273 stream <<
"style=" << k::quote;
288 matrix(
double a,
double b,
double c,
double d,
double e,
double f)
290 std::ostringstream stream;
291 stream <<
"matrix(" << a << k::comma << b << k::comma << c << k::comma
292 << d << k::comma << e << k::comma << f << k::comma <<
")";
299 std::ostringstream stream;
300 stream <<
"rotate(" << deg <<
")";
307 std::ostringstream stream;
308 stream <<
"rotate(" << deg << k::comma <<
x << k::comma << y <<
")";
315 std::ostringstream stream;
316 stream <<
"scale(" << factor <<
")";
321 scale(
double factor1,
double factor2)
323 std::ostringstream stream;
324 stream <<
"scale(" << factor1 << k::comma << factor2 <<
")";
331 std::ostringstream stream;
332 stream <<
"skewX(" << factor <<
")";
339 std::ostringstream stream;
340 stream <<
"skewY(" << factor <<
")";
347 std::ostringstream stream;
348 stream <<
"translate(" <<
x << k::comma << y <<
")";
450 using enum_map_type = std::map<align, std::string>;
452 static enum_map_type enum_map;
453 if (enum_map.empty())
473 using enum_map_type = std::map<anchor, std::string>;
475 static enum_map_type enum_map;
476 if (enum_map.empty())
489 using enum_map_type = std::map<weight, std::string>;
491 static enum_map_type enum_map;
492 if (enum_map.empty())
507 using enum_map_type = std::map<baseline, std::string>;
509 static enum_map_type enum_map;
510 if (enum_map.empty())
530 using enum_map_type = std::map<property, std::string>;
532 static enum_map_type enum_map;
533 if (enum_map.empty())
544 const string name(
"__name");
545 const string size(
"__size");
546 const string anchor(
"__anchor");
547 const string align(
"__align");
548 const string len(
"__lentype");
550 std::string strip1 = \
551 R
"(font-family="__name" font-size="__size__lentype" text-anchor="__anchor" text-align="__align" )";
559 const std::string
weight(
"__weight");
560 const std::string
property(
"__prop");
562 std::string strip2 = \
563 R
"(font-weight="__weight" font-style="__prop")";
572 stripb +=
"dominant-baseline=";
578 return strip1 + stripb + strip2;
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.
unsigned short ushort
Base integer type: positive and negative, signed integral value.
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.
marker_shape
Marker shape.
@ octahedron
Octahedron (8) 3D.
@ icosahedron
Icosahedron.
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space, space_type defaults to double.
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. NB: https://yuanchuan.dev/fun-with-stroke-dasharray.
string dashoffset
Starting offset for line dashes. https://developer.mozilla.org/en-US/docs/Web/CSS/stroke-dashoffset.
static string create_dasharray_n(const uint lsize, const uint n)
Create dash array variations with exponentially-increasing spaces. dasharray 1 = solid line dasharray...
ushort marker_reps
Marker repetitions, if any. Default is zero, no repitition, single marker.
string dasharray
Line dash vs. space configuration. Options are single value, like 2, meaning 2 sized dash 2 sized spa...
marker_shape marker_form
Marker shapes. For graph_mode 2, this means the marker_shape of the mark.
string linecap
Shape of end of line segments in line dashes. SVG Values are: butt, round, square....
string marker_defs
Marker string pointing to definitions elements. For graph_mode 1, this means the SVG equivalent of CS...
Datum consolidating style preferences.
void set_colors(const color_qi &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