Skip to content

Instantly share code, notes, and snippets.

@nilsmagnus
Created January 29, 2015 19:56
Show Gist options
  • Save nilsmagnus/c97e8012f92b67664fd3 to your computer and use it in GitHub Desktop.
Save nilsmagnus/c97e8012f92b67664fd3 to your computer and use it in GitHub Desktop.
Exercise: Images
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