saiteja242 / freetype-go

Automatically exported from code.google.com/p/freetype-go
Other
0 stars 0 forks source link

join/cap stroke polyline #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

When stroking polyline with a path, lines are not joined very well 
(see the Attached screenshot, line width is 20) 

I think this is a bug.
below you can see a short extract of the code(gc mean graphic context) that 
stroke a rectangle
func (gc *GC) StrokeRect(line [4]float) { 
        gc.path.Start(toPoint(line[0], line[1])) 
        gc.path.Add1(toPoint(line[2], line[1])) 
        gc.path.Add1(toPoint(line[2], line[3])) 
        gc.path.Add1(toPoint(line[0], line[3])) 
        gc.path.Add1(toPoint(line[0], line[1])) 
        raster.Stroke(gc.rasterizer, gc.path, raster.Fix32(gc.lineWidth*256), nil, nil) 
        b := gc.image.Bounds() 
        mask := image.NewAlpha(b.Dx(), b.Dy()) 
        painter := raster.NewAlphaOverPainter(mask) 
        gc.rasterizer.Rasterize(painter) 
        strokeColor := image.NewColorImage(gc.strokeColor) 
        draw.DrawMask(gc.image, gc.image.Bounds(), strokeColor, image.ZP, mask, image.ZP, draw.Over) 
        gc.rasterizer.Clear() 
        gc.path.Clear() 
} 

func toPoint(x, y float) raster.Point { 
        return raster.Point{raster.Fix32(int(x * 256)), raster.Fix32(int(y * 256))} 
} 

Original issue reported on code.google.com by legoff.l...@gmail.com on 14 Nov 2010 at 8:36

Attachments:

GoogleCodeExporter commented 9 years ago
I found the solution. I just have to set UseNonZeroWinding of rasterizer to 
true.
you can close this issue.
sorry for spamming

Original comment by legoff.l...@gmail.com on 16 Nov 2010 at 11:41

GoogleCodeExporter commented 9 years ago

Original comment by nigel...@golang.org on 22 Nov 2010 at 2:54