Created
December 31, 2014 07:03
-
-
Save masarakki/b7ad54a0f7521be6cd2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"code.google.com/p/go-tour/pic" | |
"image" | |
"image/color" | |
) | |
type Image struct{} | |
type MyColor struct{ | |
R, G, B, A uint32 | |
} | |
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 &MyColor{255, 0, 0, 100} | |
} | |
func (c *MyColor) RGBA() (r, g, b, a uint32) { | |
return c.R, c.G, c.B, c.A | |
} | |
func main() { | |
m := &Image{} | |
pic.ShowImage(m) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment