-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
86 lines (67 loc) · 1.33 KB
/
Copy pathmain.go
File metadata and controls
86 lines (67 loc) · 1.33 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"goBrowser/data"
"log"
"os"
rl "github.com/gen2brain/raylib-go/raylib"
)
//TODO: add support for these thingies: "<", ">"
const (
width = 600
height = 450
hStep = 13
vStep = 18
scrollSpeed = 5
)
type fontBook struct {
fonts map[int32]rl.Font
font string
}
func (fb *fontBook) getSize(size int32) rl.Font {
font, ok := fb.fonts[size]
if ok {
return font
}
font = rl.LoadFontEx(fb.font, size, nil)
fb.fonts[size] = font
return font
}
func newFontBook(font string) *fontBook {
return &fontBook{
font: font,
fonts: map[int32]rl.Font{},
}
}
var (
fonts = make([]*fontBook, 1)
scroll float32 = 0
entities map[string]data.Entity
)
func main() { //TODO: maybe switch to sdl2
entities = data.GetEntities()
rl.SetConfigFlags(rl.FlagWindowResizable)
rl.InitWindow(width, height, "Browser")
args := os.Args[1:]
pageUrl := ""
if len(args) > 0 {
pageUrl = args[0]
} else {
pageUrl = "https://browser.engineering/styles.html"
}
fonts[0] = newFontBook("fonts/Arial.ttf")
d := CreateDocument(pageUrl)
d.parseHTML()
style(d.nodes)
d.document = newDocumentLayout(d.nodes)
d.document.layout()
d.displayList = make([]drawItem, 0)
d.document.paint(&d.displayList)
for !rl.WindowShouldClose() {
d.Draw()
}
}
func checkErr(err error) {
if err != nil {
log.Fatal(err)
}
}