-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
53 lines (44 loc) · 1.22 KB
/
main.go
File metadata and controls
53 lines (44 loc) · 1.22 KB
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
package main
import (
"image/png"
"os"
cv "github.com/hvuhsg/render/canvas"
"github.com/hvuhsg/render/render_objects"
"github.com/hvuhsg/render/types"
)
func main() {
// Create a new canvas
canvas := cv.NewCanvas(types.Size{Width: 800, Height: 600}, false)
// Create some colored boxes
redBox := &render_objects.ColoredBox{Width: 100, Height: 100, Color: cv.Red}
blueBox := &render_objects.ColoredBox{Width: 100, Height: 100, Color: cv.Blue}
greenBox := &render_objects.ColoredBox{Width: 100, Height: 100, Color: cv.Green}
// Create a row of boxes
row := &render_objects.Row{
Children: []render_objects.RenderObject{
redBox,
blueBox,
greenBox,
},
Alignment: types.MainAxisAlignmentSpaceBetween,
Sizing: types.MainAxisSizeMax,
}
// Create a column with some text
textColumn := &render_objects.Column{
Children: []render_objects.RenderObject{
render_objects.NewText("Layout Example", cv.White, 24, "default"),
row,
},
}
// Center everything
align := &render_objects.Align{
Child: textColumn,
Align: render_objects.AlignCenter,
}
// Render the layout
align.Paint(canvas)
// Save the result
file, _ := os.Create("layout_composition.png")
defer file.Close()
png.Encode(file, canvas.Img)
}