Skip to content

Instantly share code, notes, and snippets.

@masarakki
Created December 31, 2014 07:03
Show Gist options
  • Save masarakki/b7ad54a0f7521be6cd2a to your computer and use it in GitHub Desktop.
Save masarakki/b7ad54a0f7521be6cd2a 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{}
type MyColor struct{
R, G, B, A uint32
}
func (img *Image) ColorModel() color.Model {
return color.RGBAModel
}
func (img *Image) Bounds() image.Rectangle {
return image.Rect(0, 0, 100, 100)
}
func (img *Image) At(x, y int) color.Color {
return &MyColor{255, 0, 0, 100}
}
func (c *MyColor) RGBA() (r, g, b, a uint32) {
return c.R, c.G, c.B, c.A
}
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