Last active
December 11, 2019 11:11
-
-
Save siisee11/6e3825982b6e4e841c2faf3e9894f628 to your computer and use it in GitHub Desktop.
Image type
This file contains 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{ | |
Height, Width int | |
} | |
func (m Image) ColorModel() color.Model { | |
return color.RGBAModel | |
} | |
func (m Image) Bounds() image.Rectangle { | |
return image.Rect(0, 0, m.Height, m.Width) | |
} | |
func (m Image) At(x, y int) color.Color { | |
c := uint8((x + y) / 2) | |
return color.RGBA{c, c, 255, 255} | |
} | |
func main() { | |
m := Image{256, 256} | |
pic.ShowImage(m) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment