From e030d6f60cf314ced56da10898f60da30a711c8a Mon Sep 17 00:00:00 2001 From: Nilesh Patra Date: Tue, 20 Oct 2020 15:10:57 +0530 Subject: [PATCH 1/2] Call QuadratcBezier function in Quadraticto --- context.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/context.go b/context.go index 1ddb09f..2810411 100644 --- a/context.go +++ b/context.go @@ -319,13 +319,22 @@ func (dc *Context) QuadraticTo(x1, y1, x2, y2 float64) { if !dc.hasCurrent { dc.MoveTo(x1, y1) } + x0, y0 := dc.current.X, dc.current.Y x1, y1 = dc.TransformPoint(x1, y1) x2, y2 = dc.TransformPoint(x2, y2) - p1 := Point{x1, y1} - p2 := Point{x2, y2} - dc.strokePath.Add2(p1.Fixed(), p2.Fixed()) - dc.fillPath.Add2(p1.Fixed(), p2.Fixed()) - dc.current = p2 + points := QuadraticBezier(x0, y0, x1, y1, x2, y2) + previous := dc.current.Fixed() + for _, p := range points[1:] { + f := p.Fixed() + if f == previous { + // TODO: this fixes some rendering issues but not all + continue + } + previous = f + dc.strokePath.Add1(f) + dc.fillPath.Add1(f) + dc.current = p + } } // CubicTo adds a cubic bezier curve to the current path starting at the From e12d8682d53425bfd06001f000e0b8dfc1cd3c28 Mon Sep 17 00:00:00 2001 From: Nilesh Patra Date: Tue, 20 Oct 2020 15:11:15 +0530 Subject: [PATCH 2/2] Update checksum according to changed Quadraticto function --- context_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/context_test.go b/context_test.go index 206816e..1db0fa0 100644 --- a/context_test.go +++ b/context_test.go @@ -91,7 +91,7 @@ func TestCircles(t *testing.T) { dc.Stroke() } saveImage(dc, "TestCircles") - checkHash(t, dc, "c52698000df96fabafe7863701afe922") + checkHash(t, dc, "7a99b51d2442662c611420751b393d28") } func TestQuadratic(t *testing.T) { @@ -113,7 +113,7 @@ func TestQuadratic(t *testing.T) { dc.Stroke() } saveImage(dc, "TestQuadratic") - checkHash(t, dc, "56b842d814aee94b52495addae764a77") + checkHash(t, dc, "6d13f76e5fca2c4297aa44c3fbf0f876") } func TestCubic(t *testing.T) { @@ -176,7 +176,7 @@ func TestClip(t *testing.T) { dc.Fill() } saveImage(dc, "TestClip") - checkHash(t, dc, "762c32374d529fd45ffa038b05be7865") + checkHash(t, dc, "a3793e533d9334b697ec73ce8b6633bb") } func TestPushPop(t *testing.T) { @@ -191,7 +191,7 @@ func TestPushPop(t *testing.T) { dc.Pop() } saveImage(dc, "TestPushPop") - checkHash(t, dc, "31e908ee1c2ea180da98fd5681a89d05") + checkHash(t, dc, "3e05bd5e9c7e8b65c6b6a82181ce4e42") } func TestDrawStringWrapped(t *testing.T) { @@ -255,7 +255,7 @@ func TestDrawPoint(t *testing.T) { } } saveImage(dc, "TestDrawPoint") - checkHash(t, dc, "55af8874531947ea6eeb62222fb33e0e") + checkHash(t, dc, "6f56cf1206fd2d730e57d8a579354cfc") } func TestLinearGradient(t *testing.T) {