Skip to content

Instantly share code, notes, and snippets.

@flc
Created August 28, 2013 18:40
Show Gist options
  • Save flc/6369657 to your computer and use it in GitHub Desktop.
Save flc/6369657 to your computer and use it in GitHub Desktop.
A Tour of Go - Exercise: Slices http://tour.golang.org/#36
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
img_func := func(x, y int) uint8 {
//return uint8(x*y)
//return uint8((x+y) / 2)
return uint8(x^y)
}
img := make([][]uint8, dy)
for i := range(img) {
img[i] = make([]uint8, dx)
for j := range(img[i]) {
img[i][j] = img_func(i, j)
}
}
return img
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment