在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Remember the picture generator you wrote earlier? Let's write another one, but this time it will return an implementation of Define your own
package main import ( "code.google.com/p/go-tour/pic" "image" "image/color" ) type Image struct{} func (img Image) ColorModel() color.Model { return color.RGBAModel } func (img Image) Bounds() image.Rectangle { return image.Rect(0, 0, 100, 100) } func (img Image) At(x, y int) color.Color { return color.RGBA{uint8(x), uint8(y), 255, 255} } func main() { m := Image{} pic.ShowImage(m) }
|
请发表评论