From 62daadb37c9d38e3e10170730a24fc0cd6052765 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 7 Oct 2021 17:30:24 +0200 Subject: [PATCH] op/clip: add absolute Path.ArcTo for completeness Signed-off-by: Elias Naur --- op/clip/clip.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/op/clip/clip.go b/op/clip/clip.go index aec3a536..9605a126 100644 --- a/op/clip/clip.go +++ b/op/clip/clip.go @@ -297,14 +297,12 @@ func (p *Path) QuadTo(ctrl, to f32.Point) { p.expand(to) } -// Arc adds an elliptical arc to the path. The implied ellipse is defined +// ArcTo adds an elliptical arc to the path. The implied ellipse is defined // by its focus points f1 and f2. // The arc starts in the current point and ends angle radians along the ellipse boundary. // The sign of angle determines the direction; positive being counter-clockwise, // negative clockwise. -func (p *Path) Arc(f1, f2 f32.Point, angle float32) { - f1 = f1.Add(p.pen) - f2 = f2.Add(p.pen) +func (p *Path) ArcTo(f1, f2 f32.Point, angle float32) { const segments = 16 m := stroke.ArcTransform(p.pen, f1, f2, angle, segments) @@ -317,6 +315,13 @@ func (p *Path) Arc(f1, f2 f32.Point, angle float32) { } } +// Arc is like ArcTo where f1 and f2 are relative to the current position. +func (p *Path) Arc(f1, f2 f32.Point, angle float32) { + f1 = f1.Add(p.pen) + f2 = f2.Add(p.pen) + p.ArcTo(f1, f2, angle) +} + // Cube records a cubic Bézier from the pen through // two control points ending in to. func (p *Path) Cube(ctrl0, ctrl1, to f32.Point) {