Skip to content

Instantly share code, notes, and snippets.

@kidinamoto01
Created December 18, 2017 09:19
Show Gist options
  • Save kidinamoto01/7d7275a37d657bb2ac869aefe090f72c to your computer and use it in GitHub Desktop.
Save kidinamoto01/7d7275a37d657bb2ac869aefe090f72c 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 {
w, h int
c uint8
}
func (img *Image) Bounds() image.Rectangle {
return image.Rect(0, 0, img.w, img.h)
}
func (img *Image) ColorModel() color.Model {
return color.RGBAModel
}
func (img *Image) At(x, y int) color.Color {
return color.RGBA{img.c + uint8(x*y+x*y), img.c + uint8(x*y+x*y), 255, 255}
}
func main() {
m := Image{100, 100, 128}
pic.ShowImage(&m)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment