Skip to content

canvas.pathIntersections index out of range #280

Closed
@geniot

Description

I'm trying to convert a large SVG to PNG:
score

But I'm getting an exception:

panic: runtime error: index out of range [11] with length 11
goroutine 1 [running]:
github.com/tdewolff/canvas.pathIntersections(0xc044b9a1c8, 0xc044b9a1c8, 0x0, 0x0)
C:/Users/vitaly/go/pkg/mod/github.com/tdewolff/canvas@v0.0.0-20240305210031-9a377e2a1436/path_intersection_util.go:605 +0x34ee

So I found this place in the source code and fixed it somehow. If you could you take a look at my PR, maybe you find it ok and merge it.

Next step: performance, it takes ages to convert this SVG. I'm looking at JSVG (written in Java), it takes a second or two there.

My conversion code:

	file, err := os.Open("score.svg")
	reader := bufio.NewReader(file)
	c, err := canvas.ParseSVG(reader)
	if err != nil {
		panic(err)
	}
	if err := renderers.Write("score.png", c, canvas.DPMM(3.2)); err != nil {
		panic(err)
	}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions