Created
December 18, 2017 09:19
-
-
Save kidinamoto01/7d7275a37d657bb2ac869aefe090f72c to your computer and use it in GitHub Desktop.
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 { | |
w, h int | |
c uint8 | |
} | |
func (img *Image) Bounds() image.Rectangle { | |
return image.Rect(0, 0, img.w, img.h) | |
} | |
func (img *Image) ColorModel() color.Model { | |
return color.RGBAModel | |
} | |
func (img *Image) At(x, y int) color.Color { | |
return color.RGBA{img.c + uint8(x*y+x*y), img.c + uint8(x*y+x*y), 255, 255} | |
} | |
func main() { | |
m := Image{100, 100, 128} | |
pic.ShowImage(&m) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment