Skip to content

Instantly share code, notes, and snippets.

@fortitudepub
Created February 17, 2017 06:00
Show Gist options
  • Save fortitudepub/c10f8da6e840f6d80b3a96852fa69aa4 to your computer and use it in GitHub Desktop.
Save fortitudepub/c10f8da6e840f6d80b3a96852fa69aa4 to your computer and use it in GitHub Desktop.
golang to calc pic.
package main
import "golang.org/x/tour/pic"
import "math/rand"
func Pic(dx, dy int) [][]uint8 {
// Initial zero.
s := make([][]uint8, 0)
for i:=0;i<dy;i++ {
v := make([]uint8, dx)
for j:=0;j<dx;j++ {
r := rand.Uint32()
v = append(v, uint8(r))
}
s = append(s, v)
}
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