Skip to content

Instantly share code, notes, and snippets.

@mtso
Created December 14, 2016 21:10
Show Gist options
  • Save mtso/27bb4cdebb9eefef00615f42eec2820a to your computer and use it in GitHub Desktop.
Save mtso/27bb4cdebb9eefef00615f42eec2820a to your computer and use it in GitHub Desktop.
package main
import (
"golang.org/x/tour/pic"
"image"
"image/color"
)
type Image struct {
w int
h int
}
func (i Image) Bounds() image.Rectangle {
return image.Rect(0, 0, i.w, i.h)
}
func (i Image) ColorModel() color.Model {
return color.RGBAModel
}
func (i Image) At(x, y int) color.Color {
return color.RGBA{(uint8(x*i.w + 1)) * 10, 0, uint8(y), 255}
}
func main() {
m := Image{100, 100}
pic.ShowImage(m)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment