Created
December 29, 2013 21:37
-
-
Save tarsisazevedo/8175182 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 { | |
| width int | |
| height int | |
| } | |
| func (img Image) Bounds() image.Rectangle { | |
| return image.Rect(0, 0, img.width, img.height) | |
| } | |
| func (img Image) At(x, y int) color.Color { | |
| xy := uint8(x + y) | |
| return color.RGBA{xy, xy, xy, 255} | |
| } | |
| func (img Image) ColorModel() color.Model { | |
| return color.RGBAModel | |
| } | |
| func main() { | |
| m := Image{100, 100} | |
| m.Bounds() | |
| pic.ShowImage(m) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment