gpu,op/clip: implement stroked paths with round joins

Signed-off-by: Sebastien Binet <s@sbinet.org>
This commit is contained in:
Sebastien Binet
2020-11-11 12:57:17 +00:00
committed by Elias Naur
parent f3f32ed7aa
commit 700cec440e
7 changed files with 90 additions and 9 deletions
+33 -3
View File
@@ -107,7 +107,8 @@ func TestStrokedPathBevelFlat(t *testing.T) {
run(t, func(o *op.Ops) {
const width = 2.5
sty := clip.StrokeStyle{
Cap: clip.FlatCap,
Cap: clip.FlatCap,
Join: clip.BevelJoin,
}
p := new(clip.Path)
@@ -133,7 +134,8 @@ func TestStrokedPathBevelRound(t *testing.T) {
run(t, func(o *op.Ops) {
const width = 2.5
sty := clip.StrokeStyle{
Cap: clip.RoundCap,
Cap: clip.RoundCap,
Join: clip.BevelJoin,
}
p := new(clip.Path)
@@ -159,7 +161,35 @@ func TestStrokedPathBevelSquare(t *testing.T) {
run(t, func(o *op.Ops) {
const width = 2.5
sty := clip.StrokeStyle{
Cap: clip.SquareCap,
Cap: clip.SquareCap,
Join: clip.BevelJoin,
}
p := new(clip.Path)
p.Begin(o)
p.Move(f32.Pt(10, 50))
p.Line(f32.Pt(10, 0))
p.Arc(f32.Pt(10, 0), f32.Pt(20, 0), math.Pi)
p.Line(f32.Pt(10, 0))
p.Line(f32.Pt(10, 10))
p.Arc(f32.Pt(0, 30), f32.Pt(0, 30), 2*math.Pi)
p.Line(f32.Pt(-20, 0))
p.Quad(f32.Pt(-10, -10), f32.Pt(-30, 30))
p.Stroke(width, sty).Add(o)
paint.Fill(o, colornames.Red)
}, func(r result) {
r.expect(0, 0, colornames.White)
r.expect(10, 50, colornames.Red)
})
}
func TestStrokedPathRoundRound(t *testing.T) {
run(t, func(o *op.Ops) {
const width = 2.5
sty := clip.StrokeStyle{
Cap: clip.RoundCap,
Join: clip.RoundJoin,
}
p := new(clip.Path)
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB