git.haldean.org monte / 0cd503c
Make pretty red pictures Will Brown 9 years ago
1 changed file(s) with 38 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 package main
1
2 import (
3 "flag"
4 "fmt"
5 "image"
6 "image/color"
7 "image/png"
8 "os"
9 )
10
11 var Width = flag.Int("width", 300, "width of output image")
12 var Height = flag.Int("height", 300, "height of output image")
13 var Output = flag.String("output", "output.png", "output PNG file")
14
15 func NewColor(r, g, b, a uint8) color.Color {
16 return color.NRGBA{R: r, G: g, B: b, A: a}
17 }
18
19 func main() {
20 flag.Parse()
21
22 println("Monte is go.")
23 img := image.NewNRGBA(image.Rect(0, 0, *Width, *Height))
24 for i := 0; i < *Width; i++ {
25 for j := 0; j < *Height; j++ {
26 img.Set(i, j, NewColor(255, 0, 0, 255))
27 }
28 }
29
30 w, err := os.Create(*Output)
31 if err != nil {
32 fmt.Printf("Could not open output file: %v\n", err)
33 return
34 }
35 png.Encode(w, img)
36 w.Close()
37 }