aboutsummaryrefslogtreecommitdiff
path: root/image.go
diff options
context:
space:
mode:
authorMartin Lehoux <martin@lehoux.net>2020-04-05 22:46:01 -0700
committerMartin Lehoux <martin@lehoux.net>2020-04-05 22:46:01 -0700
commite93eee4bb96bd2d81e422dc9d453da6138fd6ba2 (patch)
tree0ef600be27a5bcde32d04283563c7b9fb8dd50d5 /image.go
parent8730659596dbfdb9625c0fc413625b261f7d6d70 (diff)
misc - Doc
Diffstat (limited to 'image.go')
-rw-r--r--image.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/image.go b/image.go
index fe9b67f..df9039a 100644
--- a/image.go
+++ b/image.go
@@ -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))