Repository: gonum/plot
Pull request #530 (2019-02-21 10:15:19)

vg/vgimg: handle dash offsets
Updates fogleman/gg#64.

Please take a look.

<!--
Checklist:

- API changes have been discussed
- code is goformated correctly (goimports)
- packages with generated code have had code generation run
- tests pass locally
- linked to relevant issues

Please make sure your commit message summary line and pull request
title match the Go convention; a one-line summary of the change,
prefixed by the primary affected package that should complete the
sentence, "This change modifies Gonum to _____."
-->



Patch:
diff --git a/internal/cmpimg/checkplot.go b/cmpimg/checkplot.go
similarity index 100%
rename from internal/cmpimg/checkplot.go
rename to cmpimg/checkplot.go
diff --git a/internal/cmpimg/cmpimg.go b/cmpimg/cmpimg.go
similarity index 98%
rename from internal/cmpimg/cmpimg.go
rename to cmpimg/cmpimg.go
index 4c715ad..150ab1f 100644
--- a/internal/cmpimg/cmpimg.go
+++ b/cmpimg/cmpimg.go
@@ -4,7 +4,7 @@
 
 // Package cmpimg compares the raw representation of images taking into account
 // idiosyncracies related to their underlying format (SVG, PDF, PNG, ...).
-package cmpimg // import "gonum.org/v1/plot/internal/cmpimg"
+package cmpimg // import "gonum.org/v1/plot/cmpimg"
 
 import (
 	"bytes"
diff --git a/internal/cmpimg/cmpimg_test.go b/cmpimg/cmpimg_test.go
similarity index 100%
rename from internal/cmpimg/cmpimg_test.go
rename to cmpimg/cmpimg_test.go
diff --git a/internal/cmpimg/testdata/failed_input.png b/cmpimg/testdata/failed_input.png
similarity index 100%
rename from internal/cmpimg/testdata/failed_input.png
rename to cmpimg/testdata/failed_input.png
diff --git a/internal/cmpimg/testdata/good_golden.png b/cmpimg/testdata/good_golden.png
similarity index 100%
rename from internal/cmpimg/testdata/good_golden.png
rename to cmpimg/testdata/good_golden.png
diff --git a/go.mod b/go.mod
index eee23d2..28f3f10 100644
--- a/go.mod
+++ b/go.mod
@@ -2,7 +2,7 @@ module gonum.org/v1/plot
 
 require (
 	github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af
-	github.com/fogleman/gg v1.2.0
+	github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90
 	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
 	github.com/jung-kurt/gofpdf v1.0.0
 	golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f
diff --git a/go.sum b/go.sum
index f7a66f5..13860cb 100644
--- a/go.sum
+++ b/go.sum
@@ -1,7 +1,7 @@
 github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af h1:wVe6/Ea46ZMeNkQjjBW6xcqyQA/j5e0D6GytH95g0gQ=
 github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
-github.com/fogleman/gg v1.2.0 h1:Z0uOlqo+EbPQwdbrpKV1/jEcefXGPICDtGmS/gwly30=
-github.com/fogleman/gg v1.2.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
+github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90 h1:WXb3TSNmHp2vHoCroCIB1foO/yQ36swABL8aOVeDpgg=
+github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
 github.com/jung-kurt/gofpdf v1.0.0 h1:EroSdlP9BOoL5ssLYf3uLJXhCQMMM2fFxCJDKA3RhnA=
diff --git a/vg/vgimg/vgimg.go b/vg/vgimg/vgimg.go
index b199822..35b9ee6 100644
--- a/vg/vgimg/vgimg.go
+++ b/vg/vgimg/vgimg.go
@@ -195,11 +195,7 @@ func (c *Canvas) SetLineDash(ds []vg.Length, offs vg.Length) {
 	for i, d := range ds {
 		dashes[i] = d.Dots(c.DPI())
 	}
-	// FIXME(sbinet): handle offs (the distance into the dash pattern
-	// to start the dash.)
-	// this needs to be implemented on the gg side.
-	// see:
-	//  - https://github.com/fogleman/gg/issues/64
+	c.ctx.SetDashOffset(offs.Dots(c.DPI()))
 	c.ctx.SetDash(dashes...)
 }
 


Test patch:
diff --git a/align_test.go b/align_test.go
index 3eac655..250206e 100644
--- a/align_test.go
+++ b/align_test.go
@@ -9,7 +9,7 @@ import (
 	"os"
 	"testing"
 
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
 	"gonum.org/v1/plot/vg/vgimg"
diff --git a/legend_test.go b/legend_test.go
index fe4e55a..f8ef77f 100644
--- a/legend_test.go
+++ b/legend_test.go
@@ -9,7 +9,7 @@ import (
 	"os"
 	"testing"
 
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
 	"gonum.org/v1/plot/vg/vgimg"
diff --git a/palette/moreland/example_test.go b/palette/moreland/example_test.go
index c60872e..cc4a6be 100644
--- a/palette/moreland/example_test.go
+++ b/palette/moreland/example_test.go
@@ -12,7 +12,7 @@ import (
 
 	"gonum.org/v1/gonum/mat"
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/palette"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
diff --git a/palette/reverse_test.go b/palette/reverse_test.go
index ec8f4b9..aba47a4 100644
--- a/palette/reverse_test.go
+++ b/palette/reverse_test.go
@@ -10,7 +10,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/palette"
 	"gonum.org/v1/plot/palette/moreland"
 	"gonum.org/v1/plot/plotter"
diff --git a/plotter/barchart_test.go b/plotter/barchart_test.go
index a051090..cb42b57 100644
--- a/plotter/barchart_test.go
+++ b/plotter/barchart_test.go
@@ -12,7 +12,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 )
 
diff --git a/plotter/boxplot_test.go b/plotter/boxplot_test.go
index 48dda82..8b68853 100644
--- a/plotter/boxplot_test.go
+++ b/plotter/boxplot_test.go
@@ -12,7 +12,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 )
 
diff --git a/plotter/bubbles_test.go b/plotter/bubbles_test.go
index 425ad83..0365b60 100644
--- a/plotter/bubbles_test.go
+++ b/plotter/bubbles_test.go
@@ -13,7 +13,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
 )
diff --git a/plotter/colorbar_test.go b/plotter/colorbar_test.go
index 4e99a91..78e00a7 100644
--- a/plotter/colorbar_test.go
+++ b/plotter/colorbar_test.go
@@ -10,7 +10,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/palette/moreland"
 )
 
diff --git a/plotter/errbars_test.go b/plotter/errbars_test.go
index 7f19625..90d8541 100644
--- a/plotter/errbars_test.go
+++ b/plotter/errbars_test.go
@@ -11,7 +11,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg/draw"
 )
 
diff --git a/plotter/filledLine_test.go b/plotter/filledLine_test.go
index 830d3cd..fab9b4b 100644
--- a/plotter/filledLine_test.go
+++ b/plotter/filledLine_test.go
@@ -12,7 +12,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 )
 
diff --git a/plotter/functions_test.go b/plotter/functions_test.go
index 9ead68f..1a92eaa 100644
--- a/plotter/functions_test.go
+++ b/plotter/functions_test.go
@@ -11,7 +11,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 )
 
diff --git a/plotter/general_test.go b/plotter/general_test.go
index afa1e69..b880fc0 100644
--- a/plotter/general_test.go
+++ b/plotter/general_test.go
@@ -9,7 +9,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 )
 
diff --git a/plotter/heat_test.go b/plotter/heat_test.go
index 96d1447..cf1d79a 100644
--- a/plotter/heat_test.go
+++ b/plotter/heat_test.go
@@ -13,7 +13,7 @@ import (
 
 	"gonum.org/v1/gonum/mat"
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/palette"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
diff --git a/plotter/histogram_test.go b/plotter/histogram_test.go
index 7785ae9..2fd1e1a 100644
--- a/plotter/histogram_test.go
+++ b/plotter/histogram_test.go
@@ -14,7 +14,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 )
 
diff --git a/plotter/image_test.go b/plotter/image_test.go
index 223a465..3b9d284 100644
--- a/plotter/image_test.go
+++ b/plotter/image_test.go
@@ -11,7 +11,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 )
 
diff --git a/plotter/invertedaxis_example_test.go b/plotter/invertedaxis_example_test.go
index e14890b..d5ebb18 100644
--- a/plotter/invertedaxis_example_test.go
+++ b/plotter/invertedaxis_example_test.go
@@ -11,7 +11,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
 )
diff --git a/plotter/logscale_example_test.go b/plotter/logscale_example_test.go
index 2262ead..b20bed9 100644
--- a/plotter/logscale_example_test.go
+++ b/plotter/logscale_example_test.go
@@ -11,7 +11,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
 )
diff --git a/plotter/polygon_test.go b/plotter/polygon_test.go
index b6f95ec..4b177a4 100644
--- a/plotter/polygon_test.go
+++ b/plotter/polygon_test.go
@@ -11,7 +11,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/palette/moreland"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
diff --git a/plotter/precision_test.go b/plotter/precision_test.go
index e0e906e..37be0b2 100644
--- a/plotter/precision_test.go
+++ b/plotter/precision_test.go
@@ -9,7 +9,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 )
 
diff --git a/plotter/quartile_test.go b/plotter/quartile_test.go
index 1c8195d..c88616c 100644
--- a/plotter/quartile_test.go
+++ b/plotter/quartile_test.go
@@ -11,7 +11,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 )
 
diff --git a/plotter/rotation_test.go b/plotter/rotation_test.go
index 7927536..ba8971b 100644
--- a/plotter/rotation_test.go
+++ b/plotter/rotation_test.go
@@ -11,7 +11,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
 )
diff --git a/plotter/sankey_test.go b/plotter/sankey_test.go
index 548ae99..9f7ffa6 100644
--- a/plotter/sankey_test.go
+++ b/plotter/sankey_test.go
@@ -12,7 +12,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
 	"gonum.org/v1/plot/vg/recorder"
diff --git a/plotter/scatterColor_test.go b/plotter/scatterColor_test.go
index 96d4657..0d09116 100644
--- a/plotter/scatterColor_test.go
+++ b/plotter/scatterColor_test.go
@@ -14,7 +14,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/palette/moreland"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
diff --git a/plotter/scatter_test.go b/plotter/scatter_test.go
index 8149082..71724c6 100644
--- a/plotter/scatter_test.go
+++ b/plotter/scatter_test.go
@@ -12,7 +12,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
 )
diff --git a/plotter/step_test.go b/plotter/step_test.go
index 1a4b95d..30b1b74 100644
--- a/plotter/step_test.go
+++ b/plotter/step_test.go
@@ -12,7 +12,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
diff --git a/plotter/timeseries_test.go b/plotter/timeseries_test.go
index bcb45c2..93a4ab0 100644
--- a/plotter/timeseries_test.go
+++ b/plotter/timeseries_test.go
@@ -13,7 +13,7 @@ import (
 	"golang.org/x/exp/rand"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
 )
diff --git a/vg/vg_test.go b/vg/vg_test.go
index af3b002..873b45a 100644
--- a/vg/vg_test.go
+++ b/vg/vg_test.go
@@ -13,7 +13,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
 )
diff --git a/vg/vgimg/vgimg_test.go b/vg/vgimg/vgimg_test.go
index 4b381d5..d57af34 100644
--- a/vg/vgimg/vgimg_test.go
+++ b/vg/vgimg/vgimg_test.go
@@ -15,7 +15,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
diff --git a/vg/vgpdf/vgpdf_test.go b/vg/vgpdf/vgpdf_test.go
index fb95608..76b9507 100644
--- a/vg/vgpdf/vgpdf_test.go
+++ b/vg/vgpdf/vgpdf_test.go
@@ -14,7 +14,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
diff --git a/vg/vgsvg/vgsvg_test.go b/vg/vgsvg/vgsvg_test.go
index 694a5ae..8d22ac6 100644
--- a/vg/vgsvg/vgsvg_test.go
+++ b/vg/vgsvg/vgsvg_test.go
@@ -11,7 +11,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"
diff --git a/vg/vgtex/canvas_test.go b/vg/vgtex/canvas_test.go
index 6063820..9405112 100644
--- a/vg/vgtex/canvas_test.go
+++ b/vg/vgtex/canvas_test.go
@@ -10,7 +10,7 @@ import (
 	"testing"
 
 	"gonum.org/v1/plot"
-	"gonum.org/v1/plot/internal/cmpimg"
+	"gonum.org/v1/plot/cmpimg"
 	"gonum.org/v1/plot/plotter"
 	"gonum.org/v1/plot/vg"
 	"gonum.org/v1/plot/vg/draw"