Created
March 28, 2020 18:38
-
-
Save heathhenley/c717c20470dafb489d1fa73278789066 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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