Created
April 21, 2013 06:32
-
-
Save vly/5428697 to your computer and use it in GitHub Desktop.
Golang tour #59
This file contains hidden or 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 ( | |
| "code.google.com/p/go-tour/pic" | |
| "image" | |
| "image/color" | |
| ) | |
| type Image struct{ | |
| W, H int | |
| } | |
| func (m Image) ColorModel() color.Model { | |
| return color.RGBAModel | |
| } | |
| func (m Image) Bounds() image.Rectangle { | |
| return image.Rect(0,0,m.W, m.H) | |
| } | |
| func (m Image) At(x,y int) color.Color { | |
| return color.RGBA{uint8(x),uint8(y),255,255} | |
| } | |
| func main() { | |
| m := Image{150,150} | |
| pic.ShowImage(m) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment