veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.17k stars 219 forks source link

Fix my panic on (*Surface).Set() #520

Closed neputevshina closed 2 years ago

neputevshina commented 2 years ago

Your color models return the color.Color implementation of type they are converting to. This contradicts to the code of (*Surface).Set. sdl/pixel.go:

func rgba8888Model(c color.Color) color.Color {
    if _, ok := c.(color.RGBA); ok {
        return c
    }
    r, g, b, a := c.RGBA()
    return RGBA8888{uint8(r), uint8(g), uint8(b), uint8(a)}
}
veeableful commented 2 years ago

Thank you @neputevshina! I will merge this and tag it as v0.4.21.