Skip to content

Instantly share code, notes, and snippets.

@MattSurabian
Last active December 19, 2015 17:39
Show Gist options
  • Save MattSurabian/5993257 to your computer and use it in GitHub Desktop.
Save MattSurabian/5993257 to your computer and use it in GitHub Desktop.
My implementation of Pic in Go. Part of the Go tour: http://tour.golang.org/#35
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
picData := make([][]uint8, dy)
for y := range picData {
picData[y] = make([]uint8, dx)
for x := range picData[y] {
picData[y][x] = uint8(y+x/(x+1)) // this function draws a relaxing gradient
}
}
return picData
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment