Created
July 17, 2012 23:37
-
-
Save jadeallenx/3132933 to your computer and use it in GitHub Desktop.
learngo image solution (#79)
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 ( | |
"image" | |
"tour/pic" | |
"image/color" | |
) | |
type Image struct{ | |
w int | |
h int | |
v uint8 | |
} | |
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 { | |
return color.RGBA{uint8(x^y), uint8(y), i.v, 255} | |
} | |
func main() { | |
m := Image{ | |
w: 400, | |
h: 400, | |
v: 128} | |
pic.ShowImage(m) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment