// FillStroke first fills the paths and than strokes them func (gc *GraphicContext) FillStroke(paths ...*draw2d.Path) { paths = append(paths, gc.Current.Path) gc.fillRasterizer.UseNonZeroWinding = gc.Current.FillRule == draw2d.FillRuleWinding gc.strokeRasterizer.UseNonZeroWinding = true flattener := draw2dbase.Transformer{Tr: gc.Current.Tr, Flattener: FtLineBuilder{Adder: gc.fillRasterizer}} stroker := draw2dbase.NewLineStroker(gc.Current.Cap, gc.Current.Join, draw2dbase.Transformer{Tr: gc.Current.Tr, Flattener: FtLineBuilder{Adder: gc.strokeRasterizer}}) stroker.HalfLineWidth = gc.Current.LineWidth / 2 var liner draw2dbase.Flattener if gc.Current.Dash != nil && len(gc.Current.Dash) > 0 { liner = draw2dbase.NewDashConverter(gc.Current.Dash, gc.Current.DashOffset, stroker) } else { liner = stroker } demux := draw2dbase.DemuxFlattener{Flatteners: []draw2dbase.Flattener{flattener, liner}} for _, p := range paths { draw2dbase.Flatten(p, demux, gc.Current.Tr.GetScale()) } // Fill gc.paint(gc.fillRasterizer, gc.Current.FillColor) // Stroke gc.paint(gc.strokeRasterizer, gc.Current.StrokeColor) }
// Fill fills the paths with the color specified by SetFillColor func (gc *GraphicContext) Fill(paths ...*draw2d.Path) { paths = append(paths, gc.Current.Path) gc.fillRasterizer.UseNonZeroWinding = gc.Current.FillRule == draw2d.FillRuleWinding /**** first method ****/ flattener := draw2dbase.Transformer{Tr: gc.Current.Tr, Flattener: FtLineBuilder{Adder: gc.fillRasterizer}} for _, p := range paths { draw2dbase.Flatten(p, flattener, gc.Current.Tr.GetScale()) } gc.paint(gc.fillRasterizer, gc.Current.FillColor) }