GraphvizNode::GraphvizNode(SVG::SVGElement &svg_element)
: m_node_id(svg_element.graphviz_id), m_svg_g_element(svg_element) {}
+SVG::SVGPoint GraphvizNode::center() const { return bbox().center(); }
+
std::string_view GraphvizNode::node_id() const { return m_node_id; }
SVG::SVGRect GraphvizNode::bbox() const { return m_svg_g_element.bbox(); }
/// Return the node's bounding box
SVG::SVGRect bbox() const;
+ /// Return the center of the node's bounding box
+ SVG::SVGPoint center() const;
/// Return the node's `node_id` as defined by the DOT language
std::string_view node_id() const;
/// Return a non-mutable reference to the SVG `g` element corresponding to the
height = ymax - ymin;
}
+SVG::SVGPoint SVG::SVGRect::center() const {
+ return {x + width / 2, y + height / 2};
+}
+
void SVG::SVGRect::extend(const SVG::SVGRect &other) {
const auto xmin = std::min(x, other.x);
const auto ymin = std::min(y, other.y);
double y;
double width;
double height;
+ SVGPoint center() const;
void extend(const SVGPoint &point);
void extend(const SVGRect &other);
};