Skip to content

Instantly share code, notes, and snippets.

@heathhenley
Created March 28, 2020 18:38
Show Gist options
  • Save heathhenley/c717c20470dafb489d1fa73278789066 to your computer and use it in GitHub Desktop.
Save heathhenley/c717c20470dafb489d1fa73278789066 to your computer and use it in GitHub Desktop.
package main
import (
"image"
"image/color"
"golang.org/x/tour/pic"
)
type Image struct{}
func (img Image) ColorModel() color.Model {
return color.RGBAModel
}
func (img Image) Bounds() image.Rectangle {
return image.Rect(0, 0, 500, 500)
}
func (img Image) At(x, y int) color.Color {
v := uint8((x*x + y*y) / 2)
u := uint8(255-v)
return color.RGBA{v, u, 0, 255}
}
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