From 08a6c87a0be561f1d6db6a0831cd55168a58dca8 Mon Sep 17 00:00:00 2001 From: Stani Date: Sat, 11 Jul 2015 01:22:50 +0200 Subject: [PATCH] replace gc.Current.Path.Clear() with gc.Current.Path = draw2d.NewPathStorage(); fixes #61 --- draw2dgl/gc.go | 4 ++-- draw2dpdf/gc.go | 2 +- image.go | 2 +- path_storage.go | 6 ------ stack_gc.go | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/draw2dgl/gc.go b/draw2dgl/gc.go index 2833dcc..66e25cb 100644 --- a/draw2dgl/gc.go +++ b/draw2dgl/gc.go @@ -199,7 +199,7 @@ func (gc *GraphicContext) Stroke(paths ...*draw2d.PathStorage) { pathConverter.Convert(paths...) gc.paint(gc.strokeRasterizer, gc.Current.StrokeColor) - gc.Current.Path.Clear() + gc.Current.Path = draw2d.NewPathStorage() } func (gc *GraphicContext) Fill(paths ...*draw2d.PathStorage) { @@ -211,7 +211,7 @@ func (gc *GraphicContext) Fill(paths ...*draw2d.PathStorage) { pathConverter.Convert(paths...) gc.paint(gc.fillRasterizer, gc.Current.FillColor) - gc.Current.Path.Clear() + gc.Current.Path = draw2d.NewPathStorage() } func (gc *GraphicContext) FillStroke(paths ...*draw2d.PathStorage) { diff --git a/draw2dpdf/gc.go b/draw2dpdf/gc.go index 51c0fd5..fd9563a 100644 --- a/draw2dpdf/gc.go +++ b/draw2dpdf/gc.go @@ -205,7 +205,7 @@ func (gc *GraphicContext) draw(style string, paths ...*draw2d.PathStorage) { pathConverter := NewPathConverter(gc.pdf) pathConverter.Convert(paths...) gc.pdf.DrawPath(style) - gc.Current.Path.Clear() + gc.Current.Path = draw2d.NewPathStorage() } // overwrite StackGraphicContext methods diff --git a/image.go b/image.go index bc4d403..8e5fa72 100644 --- a/image.go +++ b/image.go @@ -269,7 +269,7 @@ func (gc *ImageGraphicContext) paint(rasterizer *raster.Rasterizer, color color. gc.painter.SetColor(color) rasterizer.Rasterize(gc.painter) rasterizer.Clear() - gc.Current.Path.Clear() + gc.Current.Path = NewPathStorage() } // Stroke strokes the paths with the color specified by SetStrokeColor diff --git a/path_storage.go b/path_storage.go index a7e1662..b19ea3d 100644 --- a/path_storage.go +++ b/path_storage.go @@ -32,12 +32,6 @@ func NewPathStorage() (p *PathStorage) { return } -func (p *PathStorage) Clear() { - p.Commands = p.Commands[0:0] - p.Vertices = p.Vertices[0:0] - return -} - func (p *PathStorage) appendToPath(cmd PathCmd, Vertices ...float64) { if cap(p.Vertices) <= len(p.Vertices)+6 { a := make([]PathCmd, len(p.Commands), cap(p.Commands)+256) diff --git a/stack_gc.go b/stack_gc.go index c1ac309..1e09e8f 100644 --- a/stack_gc.go +++ b/stack_gc.go @@ -125,7 +125,7 @@ func (gc *StackGraphicContext) GetFontData() FontData { } func (gc *StackGraphicContext) BeginPath() { - gc.Current.Path.Clear() + gc.Current.Path = NewPathStorage() } func (gc *StackGraphicContext) IsEmpty() bool {