Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down