RoundCapper seems to be "working in reverse", shape is spiky not round
tv42 opened this issue · 7 comments
tv42 commented
package main
import (
"image"
"image/png"
"log"
"os"
"github.com/golang/freetype/raster"
"golang.org/x/image/math/fixed"
)
func main() {
const (
w = 400
h = 400
)
var p raster.Path
p.Start(fixed.P(150, 150))
p.Add1(fixed.P(200, 250))
p.Add1(fixed.P(300, 250))
r := raster.NewRasterizer(w, h)
r.UseNonZeroWinding = true
r.AddStroke(p, fixed.I(80), raster.RoundCapper, raster.RoundJoiner)
rgba := image.NewRGBA(image.Rect(0, 0, w, h))
painter := raster.NewRGBAPainter(rgba)
painter.SetColor(image.Black)
r.Rasterize(painter)
f, err := os.Create("out.png")
if err != nil {
log.Fatalf("cannot create file: %v", err)
}
defer f.Close()
if err := png.Encode(f, rgba); err != nil {
log.Fatalf("writing png: %v", err)
}
if err := f.Close(); err != nil {
log.Fatalf("closing file: %v", err)
}
}
tv42 commented
@fogleman No clue about the internals. I skimmed the repo just enough to think that the bug was probably introduced at the same time as the math/fixed
change, but the commit in question was a bit too verbose to find anything relevant in.
fogleman commented
Any insight into this, @nigeltao ? I can try to fix it if you can point me in the right direction.
nigeltao commented
fogleman commented
I can confirm that the bug was introduced in 856a70c - worked properly before that.
fogleman commented