Created
February 17, 2017 06:00
-
-
Save fortitudepub/c10f8da6e840f6d80b3a96852fa69aa4 to your computer and use it in GitHub Desktop.
golang to calc pic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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