Last active
December 28, 2015 07:39
-
-
Save cockscomb/7465620 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
package main | |
import ( | |
"math" | |
"code.google.com/p/go-tour/pic" | |
) | |
func Pic(dx, dy int) [][]uint8 { | |
pic := make([][]uint8, dy) | |
for y := range pic { | |
pic[y] = make([]uint8, dx) | |
for x := range pic[y] { | |
half_dx := float64(dx) / 2 | |
half_dy := float64(dy) / 2 | |
_x := (float64(x) - half_dx) / half_dx | |
_y := (float64(y) - half_dy) / half_dy | |
theta := math.Atan(_x / _y) | |
pixel := theta / math.Pi | |
pic[y][x] = uint8(pixel * 128 + 128) | |
} | |
} | |
return pic | |
} | |
func main() { | |
pic.Show(Pic) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment