|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
123 : position( position )
163 if(
rx != 0.0 ||
ry != 0.0 ) {
195 double cx,
double cy,
246 double rx,
double ry,
258 double cx,
double cy,
259 double rx,
double ry,
316 std::vector< SvgPoint > points,
360 for(
size_t i = 0; i <
points.size(); ++i ) {
392 std::vector< SvgPoint >
const& points,
436 for(
size_t i = 0; i <
points.size(); ++i ) {
468 std::vector< std::string >
const& elements,
497 std::vector<SvgPoint> points;
503 auto read_value_ = []( std::vector<std::string>
const& list,
size_t& i,
double& value )
505 if( i >= list.size() ) {
508 assert( ! list[i].empty() );
516 auto read_coord_ = []( std::vector<std::string>
const& list,
size_t& i,
SvgPoint& coord )
518 if( i + 1 >= list.size() ) {
521 assert( ! list[ i + 0 ].empty() );
522 assert( ! list[ i + 1 ].empty() );
534 for(
auto const& elem :
elements ) {
535 auto const list =
split( elem,
" \t," );
543 for(
size_t i = 0; i < list.size(); ) {
544 auto const& tok = list[i];
545 if( start && tok !=
"M" && tok !=
"m" ) {
546 throw std::invalid_argument(
"SvgPath has to start with an M or m command." );
559 if( tok ==
"M" || tok ==
"m" || tok ==
"L" || tok ==
"l" ) {
561 while( read_coord_( list, i, coord )) {
562 if( tok ==
"M" || tok ==
"L" ) {
565 if( tok ==
"m" || tok ==
"l" ) {
568 points.push_back( cur );
572 throw std::runtime_error(
"Invalid SvgPath moveto or lineto command." );
579 if( tok ==
"Z" || tok ==
"z" ) {
585 if( tok ==
"H" || tok ==
"h" || tok ==
"V" || tok ==
"v" ) {
587 while( read_value_( list, i, value )) {
600 points.push_back( cur );
604 throw std::runtime_error(
"Invalid SvgPath hor or ver line command." );
613 tok ==
"C" || tok ==
"c" || tok ==
"S" || tok ==
"s" ||
614 tok ==
"Q" || tok ==
"q" || tok ==
"T" || tok ==
"t"
617 while( read_coord_( list, i, coord )) {
621 tok ==
"C" || tok ==
"c" ||
622 tok ==
"S" || tok ==
"s" ||
623 tok ==
"Q" || tok ==
"q"
625 good &= read_coord_( list, i, coord );
627 if( tok ==
"C" || tok ==
"c" ) {
628 good &= read_coord_( list, i, coord );
631 throw std::runtime_error(
"Invalid SvgPath Bezier command." );
635 if( tok ==
"C" || tok ==
"S" || tok ==
"Q" || tok ==
"T" ) {
638 if( tok ==
"c" || tok ==
"s" || tok ==
"q" || tok ==
"t" ) {
641 points.push_back( cur );
645 throw std::runtime_error(
"Invalid SvgPath Beziercommand." );
652 if( tok ==
"A" || tok ==
"a" ) {
654 while( read_coord_( list, i, coord )) {
658 good &= read_value_( list, i, value );
659 good &= read_coord_( list, i, coord );
660 good &= read_coord_( list, i, coord );
662 throw std::runtime_error(
"Invalid SvgPath elliptical arc curve command." );
672 points.push_back( cur );
676 throw std::runtime_error(
"Invalid SvgPath elliptical arc curve command." );
682 throw std::runtime_error(
"Invalid SvgPath command '" + tok +
"'." );
703 for(
size_t i = 0; i <
elements.size(); ++i ) {
728 auto ob =
object->bounding_box();
SvgBox bounding_box() const
std::vector< SvgPoint > points
std::vector< std::string > elements
std::string indent(std::string const &text, std::string const &indentation)
Indent each line of text with indentation and return the result.
SvgEllipse(SvgPoint const ¢er, double rx, double ry, SvgStroke const &stroke=SvgStroke(), SvgFill const &fill=SvgFill())
self_type & operator<<(std::string elem)
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
self_type & operator<<(SvgPoint p)
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
std::string const & id() const
SvgBox bounding_box() const
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
self_type & add(double x, double y)
SvgBox bounding_box() const
SvgBox bounding_box() const
SvgBox bounding_box() const
Compute the bounding box of the path.
std::vector< std::string > split(std::string const &str, char delimiter, const bool trim_empty)
Spilt a string into parts, given a delimiter char.
self_type & add(double x, double y)
static std::string indentation_string
void convert_to_double(Dataframe &df, size_t col_index)
Provides some commonly used string utility functions.
SvgLine(SvgPoint const &point_1, SvgPoint const &point_2, SvgStroke const &stroke=SvgStroke())
std::vector< SvgPoint > points
SvgBox bounding_box() const
SvgPolyline(SvgStroke const &stroke=SvgStroke(), SvgFill const &fill=SvgFill())
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
SvgPolygon(SvgStroke const &stroke=SvgStroke(), SvgFill const &fill=SvgFill())
std::string svg_attribute(std::string const &name, T const &value, std::string const &unit="")
SvgPath(SvgStroke const &stroke=SvgStroke(), SvgFill const &fill=SvgFill())
void write(std::ostream &out) const
SvgBox bounding_box() const
SvgBox bounding_box() const
SvgRect(SvgPoint const &position, SvgSize const &size, SvgStroke const &stroke=SvgStroke(), SvgFill const &fill=SvgFill())
SvgCircle(SvgPoint const ¢er, double radius, SvgStroke const &stroke=SvgStroke(), SvgFill const &fill=SvgFill())
self_type & add(std::string elem)
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
self_type & operator<<(SvgPoint p)
std::string repeat(std::string const &word, size_t times)
Take a string and repeat it a given number of times.
SvgBox svg_bounding_box(std::vector< SvgPoint > const &points)
Compute the bounding box of a set of points.
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
void write(std::ostream &out) const
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
constexpr bool is_alpha(char c) noexcept
Return whether a char is a letter (a-z or A-Z), ASCII-only.