op/clip: automatically close Path in Outlines

Unclosed path segments in Path will be automatically
closed by a line.

Fixes: https://todo.sr.ht/~eliasnaur/gio/320
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
Pierre Curto
2021-12-19 17:09:54 +01:00
committed by Elias Naur
parent 0117de71d3
commit 11bb86166a
10 changed files with 123 additions and 28 deletions
+13 -3
View File
@@ -11,6 +11,7 @@ import (
"image/draw"
"image/png"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"testing"
@@ -143,11 +144,20 @@ func multiRun(t *testing.T, frames ...frameT) {
func verifyRef(t *testing.T, img *image.RGBA, frame int) (ok bool) {
// ensure identical to ref data
path := filepath.Join("refs", t.Name()+".png")
if frame != 0 {
path = filepath.Join("refs", t.Name()+"_"+strconv.Itoa(frame)+".png")
var path string
if frame == 0 {
path = t.Name()
} else {
path = t.Name() + "_" + strconv.Itoa(frame)
}
path = filepath.Join("refs", path+".png")
if *dumpImages {
if err := os.MkdirAll(filepath.Dir(path), 0766); err != nil {
if !os.IsExist(err) {
t.Error(err)
return
}
}
saveImage(t, path, img)
return true
}