diff options
| author | Martin Lehoux <martin@lehoux.net> | 2020-04-05 22:46:01 -0700 |
|---|---|---|
| committer | Martin Lehoux <martin@lehoux.net> | 2020-04-05 22:46:01 -0700 |
| commit | e93eee4bb96bd2d81e422dc9d453da6138fd6ba2 (patch) | |
| tree | 0ef600be27a5bcde32d04283563c7b9fb8dd50d5 /image.go | |
| parent | 8730659596dbfdb9625c0fc413625b261f7d6d70 (diff) | |
misc - Doc
Diffstat (limited to 'image.go')
| -rw-r--r-- | image.go | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -5,19 +5,22 @@ import ( "os" ) +// Pixel contains color between 0 and 255 type Pixel struct { r, g, b int } -type Frame [HEIGHT][WIDTH]Pixel +// Frame contains image data +type Frame [Height][Width]Pixel +// Save saves frame to PPM file func (frame Frame) Save(filename string) { f, err := os.Create(filename) if err != nil { panic(nil) } defer f.Close() - f.WriteString(fmt.Sprintf("P3\n%d %d\n255\n", WIDTH, HEIGHT)) + f.WriteString(fmt.Sprintf("P3\n%d %d\n255\n", Width, Height)) for _, row := range frame { for _, pixel := range row { f.WriteString(fmt.Sprintf("%d %d %d ", pixel.r, pixel.g, pixel.b)) |
