summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Path.h
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-02-11 17:47:39 +0000
committerAndreas Kling <kling@serenityos.org>2022-02-11 21:38:27 +0100
commitaa2f20fb601c27b60b4b79599163a01e76e3d9be (patch)
tree74c5be2e150a6d29c016e36db856f299b4d41934 /Userland/Libraries/LibGfx/Path.h
parent9424c67ed5ce5d29eb96f90b1e48700c1a7dd6b5 (diff)
downloadserenity-aa2f20fb601c27b60b4b79599163a01e76e3d9be.zip
LibGfx: Add Path::[horizontal,vertical]_path_to()
The SVG spec describes some path operations using these, so we might as well have them. :^)
Diffstat (limited to 'Userland/Libraries/LibGfx/Path.h')
-rw-r--r--Userland/Libraries/LibGfx/Path.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Path.h b/Userland/Libraries/LibGfx/Path.h
index 41c0d65ade..19dd40cb1c 100644
--- a/Userland/Libraries/LibGfx/Path.h
+++ b/Userland/Libraries/LibGfx/Path.h
@@ -150,6 +150,22 @@ public:
invalidate_split_lines();
}
+ void horizontal_line_to(float x)
+ {
+ float previous_y = 0;
+ if (!m_segments.is_empty())
+ previous_y = m_segments.last().point().y();
+ line_to({ x, previous_y });
+ }
+
+ void vertical_line_to(float y)
+ {
+ float previous_x = 0;
+ if (!m_segments.is_empty())
+ previous_x = m_segments.last().point().x();
+ line_to({ previous_x, y });
+ }
+
void quadratic_bezier_curve_to(const FloatPoint& through, const FloatPoint& point)
{
append_segment<QuadraticBezierCurveSegment>(point, through);