Skip to content

Instantly share code, notes, and snippets.

@amstee
Last active January 15, 2017 00:10
Show Gist options
  • Select an option

  • Save amstee/26c11708a9dc79fc9e0b7bb9f935134f to your computer and use it in GitHub Desktop.

Select an option

Save amstee/26c11708a9dc79fc9e0b7bb9f935134f to your computer and use it in GitHub Desktop.
An answer for the exercise images
import "image"
import "image/color"
type Image struct{
x int
y int
}
func (im Image) Bounds() (image.Rectangle) {
return image.Rect(0, 0, im.x, im.y)
}
func (im Image) ColorModel() (color.Model) {
return color.RGBAModel
}
func (im Image) At(x, y int) (color.Color) {
v := uint8((x + y) / 2)
return color.RGBA{v, v, 255, 255}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment