Skip to content

Instantly share code, notes, and snippets.

@jsmits
Created April 27, 2014 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsmits/11350420 to your computer and use it in GitHub Desktop.
Save jsmits/11350420 to your computer and use it in GitHub Desktop.
package main
import (
"code.google.com/p/go-tour/pic"
"image"
"image/color"
"math"
)
type Image struct {
Width int
Height int
}
func (i Image) ColorModel() color.Model {
return color.RGBAModel
}
func (i Image) Bounds() image.Rectangle {
return image.Rect(0,0, i.Width, i.Height)
}
func (i Image) At(x, y int) color.Color {
v := math.Sqrt(float64(x*x*x + y*y*y))
return color.RGBA{uint8(v), uint8(v), 0, 255}
}
func main() {
m := Image{255, 255}
pic.ShowImage(m)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment