Skip to content

Commit 9b830c7

Browse files
committed
Images
1 parent 44484e2 commit 9b830c7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

60-images.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"code.google.com/p/go-tour/pic"
5+
"image/color"
6+
"image"
7+
)
8+
9+
type Image struct{
10+
Width int
11+
Height int
12+
Color int
13+
}
14+
15+
func (i Image) ColorModel() color.Model {
16+
return color.RGBAModel
17+
}
18+
19+
func (i Image) Bounds() image.Rectangle {
20+
return image.Rect(0, 0, i.Width, i.Height)
21+
}
22+
23+
func (i Image) At(x, y int) color.Color {
24+
return color.RGBA{uint8(i.Color + x), uint8(i.Color + y), 255, 255}
25+
}
26+
27+
func main() {
28+
m := Image{150, 250, 250}
29+
pic.ShowImage(m)
30+
}

0 commit comments

Comments
 (0)