added Images exercise
This commit is contained in:
parent
8c02a18ea6
commit
5e38e7bee0
29
exercises/06-images/go.go
Normal file
29
exercises/06-images/go.go
Normal file
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user