Revisions
-
intel352 revised this gist
Sep 17, 2012 . 1 changed file with 8 additions and 20 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,28 +3,16 @@ package main import "code.google.com/p/go-tour/pic" func Pic(dx, dy int) [][]uint8 { x := make([]uint8, dx) y := make([][]uint8, dy) for n := range y { y[n] = x for m := range x { y[n][m] = uint8((n+m)/2) } } return y } func main() { -
Tetsuo Kiso revised this gist
Apr 2, 2012 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,18 +12,18 @@ func Pic(dx, dy int) [][]uint8 { // Do something. for i := 0; i < dy; i++ { for j := 0; j < dx; j++ { switch { case j % 15 == 0: a[i][j] = 240 case j % 3 == 0: a[i][j] = 120 case j % 5 == 0: a[i][j] = 150 default: a[i][j] = 100 } } } return a } -
Tetsuo Kiso created this gist
Apr 2, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ package main import "code.google.com/p/go-tour/pic" func Pic(dx, dy int) [][]uint8 { // Allocate two-dimensioanl array. a := make([][]uint8, dy) for i := 0; i < dy; i++ { a[i] = make([]uint8, dx) } // Do something. for i := 0; i < dy; i++ { for j := 0; j < dx; j++ { if j % 15 == 0 { a[i][j] = 240 } else if j % 3 == 0 { a[i][j] = 120 } else if j % 5 == 0 { a[i][j] = 150 } else { a[i][j] = 100 } } } return a } func main() { pic.Show(Pic) }