Created
November 28, 2018 23:58
-
-
Save yixiaoyx/1b86860e5164938404615d2d25607c97 to your computer and use it in GitHub Desktop.
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
// generates an image in grayscale | |
package main | |
import "golang.org/x/tour/pic" | |
// my solution | |
func Pic(dx, dy int) [][]uint8 { | |
p := make([][]uint8, dy) | |
for i := range p { | |
p[i] = make([]uint8, dx) | |
//p[i][int(i/2)] = 0xFF // this one draws a line | |
} | |
for x := range p { | |
for y := range p[x] { | |
//p[x][y] = uint8((x+y)/2*(x^y)) // combining two filters? | |
//p[x][y] = uint8(x*y) | |
p[x][y] = uint8(-x^y) // this is my favourite | |
//p[x][y] = uint8((x+y)/2) | |
} | |
} | |
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