/
view.go
66 lines (55 loc) · 1003 Bytes
/
view.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
58
59
60
61
62
63
64
65
66
package view
import (
"github.com/mcustiel/read-game/events"
)
const WINDOW_TITLE string = "Learning Go/SDL"
const WINDOW_WIDTH, WINDOW_HEIGHT int32 = 800, 600
type Coord struct {
X int32
Y int32
}
type Just int
const (
LEFT Just = iota
CENTER
RIGHT
TOP
MIDDLE
BOTTOM
)
type Rect struct {
W int32
H int32
}
type Button struct {
Coord
Rect
Text string
BgColor RGBA
BorderColor RGBA
TextColor RGBA
OnClick func(event events.Event, args ...interface{}) error
}
type RGBA struct {
R uint8
G uint8
B uint8
A uint8
}
type Display interface {
Init() error
DrawText(text string, pos Coord, color RGBA, hJust Just, vJust Just) error
DrawRect(pos Coord, size Rect, bgColor RGBA, fgColor RGBA) error
DrawButton(button Button) error
DisplayImage(image Image, pos Coord) error
Refresh()
Clear() error
Terminate() error
}
type ImageLoader interface {
Load(imagePath string, size Rect) (Image, error)
}
type Image interface {
GetSize() Rect
Close() error
}