From 4ce170694c301445c05497132eda2b69d9e08c21 Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Fri, 19 Feb 2016 20:54:59 -0500 Subject: [PATCH] refactor --- context.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/context.go b/context.go index 1d25e46..bacc9f5 100644 --- a/context.go +++ b/context.go @@ -204,28 +204,34 @@ func (dc *Context) ClearPath() { // Path Drawing -func (dc *Context) StrokePreserve() { - var capper raster.Capper +func (dc *Context) capper() raster.Capper { switch dc.lineCap { case LineCapButt: - capper = raster.ButtCapper + return raster.ButtCapper case LineCapRound: - capper = raster.RoundCapper + return raster.RoundCapper case LineCapSquare: - capper = raster.SquareCapper + return raster.SquareCapper } - var joiner raster.Joiner + return nil +} + +func (dc *Context) joiner() raster.Joiner { switch dc.lineJoin { case LineJoinBevel: - joiner = raster.BevelJoiner + return raster.BevelJoiner case LineJoinRound: - joiner = raster.RoundJoiner + return raster.RoundJoiner } + return nil +} + +func (dc *Context) StrokePreserve() { painter := raster.NewRGBAPainter(dc.im) painter.SetColor(dc.color) r := raster.NewRasterizer(dc.width, dc.height) 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) }