Skip to content

Instantly share code, notes, and snippets.

@siisee11
Last active December 11, 2019 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siisee11/6e3825982b6e4e841c2faf3e9894f628 to your computer and use it in GitHub Desktop.
Save siisee11/6e3825982b6e4e841c2faf3e9894f628 to your computer and use it in GitHub Desktop.
Image type
package main
import (
"code.google.com/p/go-tour/pic"
"image"
"image/color"
)
type Image struct{
Height, Width int
}
func (m Image) ColorModel() color.Model {
return color.RGBAModel
}
func (m Image) Bounds() image.Rectangle {
return image.Rect(0, 0, m.Height, m.Width)
}
func (m Image) At(x, y int) color.Color {
c := uint8((x + y) / 2)
return color.RGBA{c, c, 255, 255}
}
func main() {
m := Image{256, 256}
pic.ShowImage(m)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment