diff --git a/image/README.md b/image/README.md index 9356521..da5bee8 100644 --- a/image/README.md +++ b/image/README.md @@ -84,7 +84,8 @@ func main() { // write board SVG to file yellow := color.RGBA{255, 255, 0, 1} mark := image.MarkSquares(yellow, chess.D2, chess.D4) - if err := image.SVG(f, pos.Board(), mark); err != nil { + arrows := image.MarkArrows(image.Arrow(chess.D2, chess.D4)) + if err := image.SVG(f, pos.Board(), mark, arrows); err != nil { log.Fatal(err) } } @@ -92,5 +93,5 @@ func main() { ### Example Program Result -![rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 0 1](example.svg) +![rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 0 1](examples/example.svg) diff --git a/image/black_example.svg b/image/examples/black_example.svg similarity index 100% rename from image/black_example.svg rename to image/examples/black_example.svg diff --git a/image/example.png b/image/examples/example.png similarity index 100% rename from image/example.png rename to image/examples/example.png diff --git a/image/example.svg b/image/examples/example.svg similarity index 100% rename from image/example.svg rename to image/examples/example.svg diff --git a/image/knight_arrows_example.svg b/image/examples/knight_arrows_example.svg similarity index 100% rename from image/knight_arrows_example.svg rename to image/examples/knight_arrows_example.svg diff --git a/image/image.go b/image/image.go index 72e948a..4a4035a 100755 --- a/image/image.go +++ b/image/image.go @@ -48,8 +48,8 @@ func (arrow arrow) WithColor(col color.Color) arrow { // MarkArrows is designed to be used as an optional argument // to the SVG function. It marks an arrow between the given // squares with the an Arrow of the given color. -func MarkArrows(arrows ...arrow) func(*encoder) { - return func(e *encoder) { +func MarkArrows(arrows ...arrow) func(*Encoder) { + return func(e *Encoder) { e.arrows = append(e.arrows, arrows...) } } diff --git a/image/image_test.go b/image/image_test.go index 0894180..0b84ab3 100755 --- a/image/image_test.go +++ b/image/image_test.go @@ -5,8 +5,6 @@ import ( "crypto/md5" "fmt" "image/color" - "io" - "os" "strings" "testing" @@ -38,16 +36,6 @@ func TestSVG(t *testing.T) { if actualMD5 != expectedMD5 { t.Errorf("expected actual md5 hash to be %s but got %s", expectedMD5, actualMD5) } - - // create actual svg file for visualization - f, err := os.Create("example.svg") - defer f.Close() - if err != nil { - t.Error(err) - } - if _, err := io.Copy(f, bytes.NewBufferString(actualSVG)); err != nil { - t.Error(err) - } } func TestSVGFromBlack(t *testing.T) { @@ -71,16 +59,6 @@ func TestSVGFromBlack(t *testing.T) { if actualMD5 != expectedMD5Black { t.Errorf("expected actual md5 hash to be %s but got %s", expectedMD5Black, actualMD5) } - - // create actual svg file for visualization - f, err := os.Create("black_example.svg") - defer f.Close() - if err != nil { - t.Error(err) - } - if _, err := io.Copy(f, bytes.NewBufferString(actualSVG)); err != nil { - t.Error(err) - } } func TestSVGKnightsAndDiagonals(t *testing.T) { @@ -125,14 +103,4 @@ func TestSVGKnightsAndDiagonals(t *testing.T) { if actualMD5 != expectedMD5KnightsAndDiagonalArrows { t.Errorf("expected actual md5 hash to be %s but got %s", expectedMD5KnightsAndDiagonalArrows, actualMD5) } - - // create actual svg file for visualization - f, err := os.Create("knight_arrows_example.svg") - defer f.Close() - if err != nil { - t.Error(err) - } - if _, err := io.Copy(f, bytes.NewBufferString(actualSVG)); err != nil { - t.Error(err) - } } diff --git a/image/test.svg b/image/test.svg deleted file mode 100644 index 85eaaae..0000000 --- a/image/test.svg +++ /dev/null @@ -1,534 +0,0 @@ - - - - - - - - - - - - - - - - -1 -a - - - - - - - - - -b - - - - - - - - - - - -c - - - - - - - - - - - - - - -d - - - - - - - - - - - - -e - - - - - - - - - - - -f - - - - - - - - - -g - - - - - - - - - - - - -h - - - - -2 - - - - - - - - - - - - - - - - - - - - - - - - - - - -3 - - - - - - - - -4 - - - - - - - - - - - - -5 - - - - - - - - -6 - - - - - - - - - - - -7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -