go-tour/exercise-images.go

28 lines
426 B
Go
Raw Normal View History

2020-02-11 01:56:18 +00:00
package main
import (
"image"
"image/color"
"golang.org/x/tour/pic"
)
type Image struct{}
func (i Image) ColorModel() color.Model {
return color.RGBAModel
}
func (i Image) Bounds() image.Rectangle {
return image.Rect(0, 0, 100, 100)
}
func (i Image) At(x, y int) color.Color {
v := uint8(x) ^ uint8(y)
return color.RGBA{v, v, 255, 255}
}
func main() {
m := Image{}
pic.ShowImage(m)
}