refactor
This commit is contained in:
parent
cf2e9fdfaf
commit
4ce170694c
24
context.go
24
context.go
@ -204,28 +204,34 @@ func (dc *Context) ClearPath() {
|
|||||||
|
|
||||||
// Path Drawing
|
// Path Drawing
|
||||||
|
|
||||||
func (dc *Context) StrokePreserve() {
|
func (dc *Context) capper() raster.Capper {
|
||||||
var capper raster.Capper
|
|
||||||
switch dc.lineCap {
|
switch dc.lineCap {
|
||||||
case LineCapButt:
|
case LineCapButt:
|
||||||
capper = raster.ButtCapper
|
return raster.ButtCapper
|
||||||
case LineCapRound:
|
case LineCapRound:
|
||||||
capper = raster.RoundCapper
|
return raster.RoundCapper
|
||||||
case LineCapSquare:
|
case LineCapSquare:
|
||||||
capper = raster.SquareCapper
|
return raster.SquareCapper
|
||||||
}
|
}
|
||||||
var joiner raster.Joiner
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dc *Context) joiner() raster.Joiner {
|
||||||
switch dc.lineJoin {
|
switch dc.lineJoin {
|
||||||
case LineJoinBevel:
|
case LineJoinBevel:
|
||||||
joiner = raster.BevelJoiner
|
return raster.BevelJoiner
|
||||||
case LineJoinRound:
|
case LineJoinRound:
|
||||||
joiner = raster.RoundJoiner
|
return raster.RoundJoiner
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dc *Context) StrokePreserve() {
|
||||||
painter := raster.NewRGBAPainter(dc.im)
|
painter := raster.NewRGBAPainter(dc.im)
|
||||||
painter.SetColor(dc.color)
|
painter.SetColor(dc.color)
|
||||||
r := raster.NewRasterizer(dc.width, dc.height)
|
r := raster.NewRasterizer(dc.width, dc.height)
|
||||||
r.UseNonZeroWinding = true
|
r.UseNonZeroWinding = true
|
||||||
r.AddStroke(dc.path, fi(dc.lineWidth), capper, joiner)
|
r.AddStroke(dc.path, fi(dc.lineWidth), dc.capper(), dc.joiner())
|
||||||
r.Rasterize(painter)
|
r.Rasterize(painter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user