]> granicus.if.org Git - graphviz/commitdiff
tests: SvgAnalyzer: SVGPoint: add checking of relative position to other point
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Wed, 17 Aug 2022 12:57:43 +0000 (14:57 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Tue, 23 Aug 2022 06:19:35 +0000 (08:19 +0200)
tests/svg_element.cpp
tests/svg_element.h

index 0d150c7ff1f492838edd1c6d45cfc88b80beef16..0209e95bfbdbda1da0ed9900966718c67e1911bf 100644 (file)
@@ -396,3 +396,21 @@ std::string_view SVG::tag(SVGElementType type) {
   }
   UNREACHABLE();
 }
+
+bool SVG::SVGPoint::is_higher_than(const SVGPoint &other) const {
+  // SVG uses inverted y axis, so smaller is higher
+  return y < other.y;
+}
+
+bool SVG::SVGPoint::is_lower_than(const SVGPoint &other) const {
+  // SVG uses inverted y axis, so larger is lower
+  return y > other.y;
+}
+
+bool SVG::SVGPoint::is_more_left_than(const SVGPoint &other) const {
+  return x < other.x;
+}
+
+bool SVG::SVGPoint::is_more_right_than(const SVGPoint &other) const {
+  return x > other.x;
+}
index 2837496dcf0083ea6013336bf28d77850dd0113f..11c3f5fe4247def3e4b7bb3bd0fd21a4f26a4c40 100644 (file)
@@ -11,6 +11,10 @@ namespace SVG {
 struct SVGPoint {
   double x;
   double y;
+  bool is_higher_than(const SVGPoint &other) const;
+  bool is_lower_than(const SVGPoint &other) const;
+  bool is_more_left_than(const SVGPoint &other) const;
+  bool is_more_right_than(const SVGPoint &other) const;
 };
 
 struct SVGRect {