Skip to content

Instantly share code, notes, and snippets.

@nikushi
Created June 6, 2014 01:19
Show Gist options
  • Save nikushi/d06e4c62c5081f9da7b9 to your computer and use it in GitHub Desktop.
Save nikushi/d06e4c62c5081f9da7b9 to your computer and use it in GitHub Desktop.
@nikushi
Copy link
Author

nikushi commented Jun 6, 2014

http://go-tour-jp.appspot.com/#36

package main

import (
    "code.google.com/p/go-tour/pic"
  //  "log"
)

func Pic(dx, dy int) [][]uint8 {
    data := make([][]uint8, dy)
    for i := range data {
         data[i] = make([]uint8, dx)
    }
    for y := 0; y < dy; y++ {
        for x := 0; x < dx; x++ {
            data[y][x] = getValue(x, y)
        }
    }
    return data
}

func getValue(x, y int) uint8 {
    return uint8(x^y/2)
}

func main() {
    pic.Show(Pic)
    //log.Println(Pic(3,4))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment