Skip to content

Instantly share code, notes, and snippets.

@ksomemo
Last active August 29, 2015 14:04
Show Gist options
  • Save ksomemo/2f2c89352e9294830603 to your computer and use it in GitHub Desktop.
Save ksomemo/2f2c89352e9294830603 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 {
// Bounds
Width, Hight int
// At
color uint8
}
func (i Image) ColorModel() color.Model {
return color.RGBAModel
}
func (i Image) Bounds() image.Rectangle {
return image.Rect(0, 0, i.Width, i.Hight)
}
func (i Image) At(x, y int) color.Color {
return color.RGBA{i.color + uint8(x), i.color + uint8(y), 255, 255}
}
func main() {
m := Image{255, 255, 128}
pic.ShowImage(m)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment