From dd57f5c1f5daf4da4d6f8e21fc51e15d99e4d838 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Wed, 26 Apr 2023 16:54:12 +0200 Subject: [PATCH] stroke: add ArcTo Signed-off-by: Sebastien Binet --- stroke/clip_test.go | 28 ++++++++++++++++++++++++++++ stroke/refs/TestStrokedPathArc.png | Bin 0 -> 2165 bytes stroke/stroke.go | 14 ++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 stroke/refs/TestStrokedPathArc.png diff --git a/stroke/clip_test.go b/stroke/clip_test.go index 6277941..9ce6abb 100644 --- a/stroke/clip_test.go +++ b/stroke/clip_test.go @@ -327,6 +327,34 @@ func TestStrokedPathBalloon(t *testing.T) { }) } +func TestStrokedPathArc(t *testing.T) { + run(t, func(o *op.Ops) { + p := Path{ + Segments: []Segment{ + MoveTo(f32.Pt(0, 65)), + LineTo(f32.Pt(20, 65)), + ArcTo(f32.Pt(70, 65), +math.Pi/3), + LineTo(f32.Pt(70, 65)), + LineTo(f32.Pt(20, 65)), + ArcTo(f32.Pt(70, 65), -math.Pi/2), + LineTo(f32.Pt(70, 65)), + }, + } + cl := Stroke{ + Path: p, + Width: 2.83, + Cap: RoundCap, + Join: RoundJoin, + }.Op(o).Push(o) + paint.Fill(o, red) + cl.Pop() + }, func(r result) { + r.expect(0, 0, transparent) + r.expect(70, 65, colornames.Red) + r.expect(35, 65, colornames.Red) + }) +} + var fruit = Path{ Segments: []Segment{ MoveTo(f32.Pt(10, 50)), diff --git a/stroke/refs/TestStrokedPathArc.png b/stroke/refs/TestStrokedPathArc.png new file mode 100644 index 0000000000000000000000000000000000000000..e1a64034873896c44251896b942ac6cbbc767b4a GIT binary patch literal 2165 zcma)8`#;kS8=hfKo3nC0PLkp&a%xT`IfuqD3adP3N-CT4z9pN(cuI1NQ6ZT_n(c|S z8YYU$X^I)yL#dg{A@q2?|G@isf4J}ahwJ`)uIu{Y`rLQ6pYI8ntfnjo1cG_Ey9Vq` z;(tpTveVg)kpm!*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