Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "golang.org/x/tour/pic"
- "image"
- "image/color"
- )
- type Image struct{
- w int
- h int
- }
- func (Image) ColorModel() color.Model {
- return color.RGBAModel
- }
- func (img Image) Bounds() image.Rectangle {
- return image.Rect(0, 0, img.w, img.h)
- }
- func (Image) At(x, y int) color.Color {
- //v := uint8((x + y) / 2) // gradient
- v := uint8(x*y) // hypnotize
- //v := uint8(x^y) // gradient checkers
- return color.RGBA{v, v, 255, 255}
- }
- func main() {
- m := Image{ 600, 250 }
- pic.ShowImage(m)
- }
Add Comment
Please, Sign In to add comment