From 170df8474957306bdff6674d869944e60375cc06 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Mon, 10 Feb 2020 19:56:18 -0600 Subject: [PATCH] image "fun" --- exercise-images.go | 27 +++++++++++++++++++++++++++ images.go | 12 ++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 exercise-images.go create mode 100644 images.go diff --git a/exercise-images.go b/exercise-images.go new file mode 100644 index 0000000..e79b1f7 --- /dev/null +++ b/exercise-images.go @@ -0,0 +1,27 @@ +package main + +import ( + "image" + "image/color" + "golang.org/x/tour/pic" +) + +type Image struct{} + +func (i Image) ColorModel() color.Model { + return color.RGBAModel +} + +func (i Image) Bounds() image.Rectangle { + return image.Rect(0, 0, 100, 100) +} + +func (i Image) At(x, y int) color.Color { + v := uint8(x) ^ uint8(y) + return color.RGBA{v, v, 255, 255} +} + +func main() { + m := Image{} + pic.ShowImage(m) +} diff --git a/images.go b/images.go new file mode 100644 index 0000000..4467138 --- /dev/null +++ b/images.go @@ -0,0 +1,12 @@ +package main + +import ( + "fmt" + "image" +) + +func main() { + m := image.NewRGBA(image.Rect(0, 0, 100, 100)) + fmt.Println(m.Bounds()) + fmt.Println(m.At(0, 0).RGBA()) +}