Created
April 11, 2013 06:21
-
-
Save royling/75c566edc9a1e8facfe1 to your computer and use it in GitHub Desktop.
Ex2: Implement Pic. It should return a slice of length dy, each element of which is a slice of dx 8-bit unsigned integers. When you run the program, it will display your picture, interpreting the integers as grayscale (well, bluescale) values. The choice of image is up to you. Interesting functions include x^y, (x+y)/2, and x*y.
This file contains 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 "code.google.com/p/go-tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
p := make([][]uint8, dy) | |
for y := range p { | |
p[y] = make([]uint8, dx) | |
for x := range p[y] { | |
p[y][x] = uint8(x^y) | |
} | |
} | |
return p | |
} | |
func main() { | |
pic.Show(Pic) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment