来自golang tour 练习 https://tour.go-zh.org/methods/16
package main import "golang.org/x/tour/pic" import "image" import "image/color" type Image struct{} func (im Image) ColorModel() color.Model { return color.RGBAModel } func (im Image) Bounds() image.Rectangle { return image.Rect(0, 0, 200, 200) } func (im Image) At(x, y int) color.Color { return color.RGBA{uint8((x^y)/2), uint8((x+y)/2), 255, 255} } func main() { m := Image{} pic.ShowImage(m) }
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)