-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (44 loc) · 1020 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"image/color"
"io/ioutil"
"log"
"os"
"github.com/fogleman/gg"
)
// This is a comment.
func main() {
overflowB := NewLinearLayout(Horizontal, 10, 10)
overflowC := NewLinearLayout(Vertical, 10, 0)
overflowC.Add(NewTestView())
overflowC.Add(NewTestView())
overflowC.Add(NewTestView())
filename := "main.go"
source, err := ioutil.ReadFile(filename)
if err != nil {
log.Fatal(err)
}
overflowB.Add(NewTestView())
overflowB.Add(NewCodeView(filename, source))
overflowB.Add(overflowC)
alloc := &Allocation{
X: 0,
Y: 0,
Width: 1920,
Height: 1080,
}
overflowB.Allocate(alloc)
context := gg.NewContext(int(alloc.Width), int(alloc.Height))
context.SetColor(color.RGBA{255, 255, 255, 255})
context.Clear()
overflowB.Render(context)
out := "out.png"
if len(os.Args) >= 2 {
out = os.Args[1]
}
fmt.Printf("Saving %dx%d image in %s\n", context.Width(), context.Height(), out)
if err := context.SavePNG(out); err != nil {
log.Fatal(err)
}
}