|
A library for working with phylogenetic and population genetic data.
v0.27.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_FORMATS_SVG_HELPER_H_
2 #define GENESIS_UTILS_FORMATS_SVG_HELPER_H_
91 explicit SvgMargin(
double top_bottom,
double right_left )
92 :
SvgMargin( top_bottom, right_left, top_bottom, right_left )
214 return "<!-- " + content +
" -->";
217 template<
typename T >
219 std::string
const& name,
221 std::string
const& unit =
""
223 std::stringstream ss;
224 ss <<
" " << name <<
"=\"" << value << unit <<
"\"";
241 double center_x,
double center_y,
double radius,
double start_angle,
double end_angle
243 std::string large_arc;
244 if( start_angle > end_angle ) {
245 large_arc = ( end_angle - start_angle <=
utils::PI ?
"1" :
"0" );
247 large_arc = ( end_angle - start_angle <=
utils::PI ?
"0" :
"1" );
250 double start_x = center_x + ( radius * std::cos( end_angle ));
251 double start_y = center_y + ( radius * std::sin( end_angle ));
252 double end_x = center_x + ( radius * std::cos( start_angle ));
253 double end_y = center_y + ( radius * std::sin( start_angle ));
255 std::ostringstream os;
256 os <<
"M " << start_x <<
" " << start_y <<
" ";
257 os <<
"A " << radius <<
" " << radius <<
" " << 0 <<
" " << large_arc <<
" " << 0 <<
" ";
258 os << end_x <<
" " << end_y;
263 std::string
const& media_type,
264 std::string
const& content,
265 bool encode_base64 =
false
267 return "data:" + media_type + (
288 #endif // include guard
void swap(Sample &lhs, Sample &rhs)
std::string svg_data_uri(std::string const &media_type, std::string const &content, bool encode_base64=false)
static SvgBox combine(SvgBox const &lhs, SvgBox const &rhs)
SvgMargin(double top, double right_left, double bottom)
std::string svg_comment(std::string const &content)
std::string base64_encode(std::vector< std::uint8_t > const &input, size_t line_length)
SvgBox(SvgPoint top_left_v, double width, double height)
SvgMargin(double top, double right, double bottom, double left)
constexpr double PI
Make the world go round.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
std::string svg_attribute(std::string const &name, T const &value, std::string const &unit="")
SvgSize(double width=0.0, double height=0.0)
SvgMargin(double top_bottom, double right_left)
SvgBox(SvgPoint top_left, SvgPoint bottom_right)
std::string svg_arc(double center_x, double center_y, double radius, double start_angle, double end_angle)
Create an arc to use in an SvgPath.
SvgPoint(double x=0.0, double y=0.0)