// Copyright 2012 The Go Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
package main | |
import ( | |
"image" | |
"image/color" | |
"tour/pic" | |
) | |
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) | |
return color.RGBA{c, c, 255, 255} | |
} | |
func main() { | |
m := Image{256, 256} | |
pic.ShowImage(m) | |
} |