lafriks / go-svg

Golang SVG file parser and rasterizer library
BSD 3-Clause "New" or "Revised" License
5 stars 2 forks source link

transform scale is incorrectly parsed when only 'x' is present #1

Closed pekim closed 1 month ago

pekim commented 1 month ago

https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale

The scale(<x> [<y>]) transform function specifies a scale operation by x and y. If y is not provided, it is assumed to be equal to x.

https://github.com/lafriks/go-svg/blob/58ecbfca0208034d921c78d71cc0ac474c0e8f2f/parse.go#L83 I believe that

        if ln == 1 {
            m1 = m1.Scale(c.points[0], 0)

should be

        if ln == 1 {
            m1 = m1.Scale(c.points[0], c.points[0])
pekim commented 1 month ago

It looks like translate has the same issue. https://github.com/lafriks/go-svg/blob/58ecbfca0208034d921c78d71cc0ac474c0e8f2f/parse.go#L63

lafriks commented 1 month ago

Fixed in v0.4.1 release