Skip to content

Instantly share code, notes, and snippets.

@piecedigital
Created March 30, 2016 22:47
Show Gist options
  • Save piecedigital/7cf2dec0ea2567b464d42faa68da5277 to your computer and use it in GitHub Desktop.
Save piecedigital/7cf2dec0ea2567b464d42faa68da5277 to your computer and use it in GitHub Desktop.
package main
import (
"golang.org/x/tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
// this makes "s" a slice ready to hold slices
s := make([][]uint8, dy)
// iterate through "y", slices in "s"
for y := range s {
// this makes the slices IN "s" ready to hold unsigned 8-bit integers
s[y] = make([]uint8, dx)
// iterrate through "x", the integers in "y"
for x := range s[y] {
s[y][x] = uint8(x/(4)^y/(4))
}
}
return s
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment