Created
January 29, 2015 19:56
-
-
Save nilsmagnus/c97e8012f92b67664fd3 to your computer and use it in GitHub Desktop.
Exercise: Images
This file contains 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{} | |
func(im Image) ColorModel() color.Model{ | |
return color.RGBAModel | |
} | |
func(im Image) Bounds() image.Rectangle { | |
return image.Rect(0,0,200,100) | |
} | |
func(im Image) At(x, y int) color.Color{ | |
return color.Gray{ uint8(x*x+y) } | |
} | |
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