Skip to content

Commit

Permalink
clean up arrows pr
Browse files Browse the repository at this point in the history
  • Loading branch information
notnil committed Nov 25, 2024
1 parent 03e8c09 commit 5e6af1d
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 570 deletions.
5 changes: 3 additions & 2 deletions image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ 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)
}
}
```

### 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)

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
}
Expand Down
32 changes: 0 additions & 32 deletions image/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"crypto/md5"
"fmt"
"image/color"
"io"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
}
}
534 changes: 0 additions & 534 deletions image/test.svg

This file was deleted.

0 comments on commit 5e6af1d

Please sign in to comment.