notnil / chess

chess package for go
MIT License
508 stars 126 forks source link

How to generate a flipped svg file? #101

Closed aimerneige closed 2 years ago

aimerneige commented 2 years ago

Hello! I am trying to generate a flipped SVG file for the black player.

I write code like this:

    board := pos.Board()
    if pos.Turn() == chess.Black {
        board = board.Flip(chess.UpDown).Flip(chess.LeftRight)
    }
    if err := image.SVG(f, board); err != nil {
        log.Fatal(err)
    }

But I got this, where the a1 should be at the left top

image

What should I do to generate a correct SVG file? Or is this a bug?

notnil commented 2 years ago

Thanks for the visualization. Yeah chess/image will likely need to be updated to support "from black" view. Flipping flips the pieces, not the board.

notnil commented 2 years ago

Fixed in #109