Guest User

Untitled

a guest
Nov 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "golang.org/x/tour/pic"
  5. "image"
  6. "image/color"
  7. )
  8.  
  9. type Image struct{
  10. w int
  11. h int
  12. }
  13.  
  14. func (Image) ColorModel() color.Model {
  15. return color.RGBAModel
  16. }
  17.  
  18. func (img Image) Bounds() image.Rectangle {
  19. return image.Rect(0, 0, img.w, img.h)
  20. }
  21.  
  22. func (Image) At(x, y int) color.Color {
  23. //v := uint8((x + y) / 2) // gradient
  24. v := uint8(x*y) // hypnotize
  25. //v := uint8(x^y) // gradient checkers
  26. return color.RGBA{v, v, 255, 255}
  27. }
  28.  
  29. func main() {
  30. m := Image{ 600, 250 }
  31. pic.ShowImage(m)
  32. }
Add Comment
Please, Sign In to add comment