-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
43 lines (35 loc) · 1020 Bytes
/
Copy pathmain.go
File metadata and controls
43 lines (35 loc) · 1020 Bytes
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
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 text objects with different properties
title := render_objects.NewText("Hello, Render!", cv.Red, 48, "default")
subtitle := render_objects.NewText("A Simple Text Example", cv.Blue, 24, "default")
body := render_objects.NewText("This demonstrates different text styles and colors", cv.Gray, 18, "default")
// Arrange text in a column
textColumn := &render_objects.Column{
Children: []render_objects.RenderObject{
title,
subtitle,
body,
},
}
// Center the text column
align := &render_objects.Align{
Child: textColumn,
Align: render_objects.AlignCenter,
}
// Render the text
align.Paint(canvas)
// Save the result
file, _ := os.Create("text_rendering.png")
defer file.Close()
png.Encode(file, canvas.Img)
}