From 5e38e7bee00e97400f27f4c2c171d1d2d41582f1 Mon Sep 17 00:00:00 2001 From: "Stephen M. McQuay" Date: Tue, 28 Aug 2012 22:18:10 -0600 Subject: [PATCH] added Images exercise --- exercises/06-images/go.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 exercises/06-images/go.go diff --git a/exercises/06-images/go.go b/exercises/06-images/go.go new file mode 100644 index 0000000..39309d6 --- /dev/null +++ b/exercises/06-images/go.go @@ -0,0 +1,29 @@ +package main + +import ( + "code.google.com/p/go-tour/pic" + "image" + "image/color" +) + +type Image struct { + w, h int +} + +func (i *Image) ColorModel() color.Model { + return color.RGBAModel +} + +func (i *Image) Bounds() image.Rectangle { + return image.Rect(0, 0, i.w, i.h) +} + +func (i *Image) At(x, y int) color.Color { + v := uint8(x & y) + return color.RGBA{v, v, 255, 255} +} + +func main() { + m := &Image{256, 512} + pic.ShowImage(m) +}