Skip to content

Instantly share code, notes, and snippets.

@tarsisazevedo
Created December 29, 2013 21:37
Show Gist options
  • Select an option

  • Save tarsisazevedo/8175182 to your computer and use it in GitHub Desktop.

Select an option

Save tarsisazevedo/8175182 to your computer and use it in GitHub Desktop.
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