Repository navigation
Expand file tree
/
Copy pathtxt.go
More file actions
125 lines (119 loc) · 4.01 KB
/
Copy pathtxt.go
File metadata and controls
125 lines (119 loc) · 4.01 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package main
import (
z "github.com/gen2brain/raylib-go/raylib"
)
var (
FONT1, FONT2 z.Font
)
func mFONTS() {
FONT1 = z.LoadFont("data/Rubik-Medium.ttf")
FONT2 = z.LoadFont("data/Rancho-Regular.ttf")
}
// UTILS
func qTXTlenFont1(t string, siz float32) z.Vector2 {
return z.MeasureTextEx(FONT1, t, float32(FONT1.BaseSize)*siz, 0)
}
func qTXTlenFont2(t string, siz float32) z.Vector2 {
return z.MeasureTextEx(FONT2, t, float32(FONT1.BaseSize)*siz, 0)
}
func qTXTheight(f z.Font, siz float32) float32 {
v2 := z.MeasureTextEx(f, "Text", float32(f.BaseSize)*siz, 0)
return v2.Y
}
// DRAW
func dTXTfont1XYbgrec(t string, x, y, siz float32, cTXT, cBG z.Color, offsetBGREC float32) {
v2 := qTXTlenFont1(t, siz)
r := z.NewRectangle(x-offsetBGREC, y-offsetBGREC/2, v2.X+offsetBGREC*2, v2.Y+offsetBGREC)
dREC(r, cBG)
dTXTfont1XY(t, x, y, siz, cTXT)
}
func dTXTfont2XYbgrec(t string, x, y, siz float32, cTXT, cBG z.Color, offsetBGREC float32) {
v2 := qTXTlenFont2(t, siz)
r := z.NewRectangle(x-offsetBGREC, y-offsetBGREC/2, v2.X+offsetBGREC*2, v2.Y+offsetBGREC)
dREC(r, cBG)
dTXTfont2XY(t, x, y, siz, cTXT)
}
func dTXTcntXFont2(t string, xMiddle, y, siz float32, c z.Color) {
v2 := qTXTlenFont2(t, siz)
x := xMiddle - v2.X/2
dTXTfont2XY(t, x, y, siz, c)
}
func dTXTcntRecYToffsetFont2(t string, r z.Rectangle, siz, offset float32, c z.Color) {
v2 := qTXTlenFont2(t, siz)
x := (r.X + r.Width/2) - v2.X/2
y := r.Y - offset - qTXTheight(FONT2, siz)
dTXTfont2XY(t, x, y, siz, c)
}
func dTXTcntRecYBoffsetFont2(t string, r z.Rectangle, siz, offset float32, c z.Color) {
v2 := qTXTlenFont2(t, siz)
x := (r.X + r.Width/2) - v2.X/2
y := r.Y + r.Height + offset
dTXTfont2XY(t, x, y, siz, c)
}
func dTXTcntRecWfont1(t string, r z.Rectangle, offsetY, siz float32, c z.Color) {
v2 := qTXTlenFont1(t, siz)
x := (r.X + r.Width/2) - v2.X/2
y := r.Y + offsetY
dTXTfont1XY(t, x, y, siz, c)
}
func dTXTcntRecWfont2(t string, r z.Rectangle, offsetY, siz float32, c z.Color) {
v2 := qTXTlenFont2(t, siz)
x := (r.X + r.Width/2) - v2.X/2
y := r.Y + offsetY
dTXTfont2XY(t, x, y, siz, c)
}
func dTXTcntRecFont2(t string, r z.Rectangle, siz float32, c z.Color) {
v2 := qTXTlenFont2(t, siz)
x := (r.X + r.Width/2) - v2.X/2
y := (r.Y + r.Height/2) - v2.Y/2
dTXTfont2XY(t, x, y, siz, c)
}
func dTXTcntRecFont2SHADOW(t string, r z.Rectangle, siz float32, c, cShadow z.Color, offsetShadow float32) {
v2 := qTXTlenFont2(t, siz)
x := (r.X + r.Width/2) - v2.X/2
y := (r.Y + r.Height/2) - v2.Y/2
x2 := x - offsetShadow
y2 := y + offsetShadow
dTXTfont2XY(t, x2, y2, siz, cShadow)
dTXTfont2XY(t, x, y, siz, c)
}
func dTXTcntRecFont1(t string, r z.Rectangle, siz float32, c z.Color) {
v2 := qTXTlenFont1(t, siz)
x := (r.X + r.Width/2) - v2.X/2
y := (r.Y + r.Height/2) - v2.Y/2
dTXTfont1XY(t, x, y, siz, c)
}
func dTXTcntRecWfont2SHADOW(t string, r z.Rectangle, offsetY, offsetShadow, siz float32, c, cShadow z.Color) {
w := qTXTlenFont2(t, siz)
x := (r.X + r.Width/2) - w.X/2
y := r.Y + offsetY
x2 := x - offsetShadow
y2 := y + offsetShadow
dTXTfont2XY(t, x2, y2, siz, CA(cShadow, 150))
dTXTfont2XY(t, x, y, siz, c)
}
func dTXTfont1XY(t string, x, y, siz float32, c z.Color) {
z.DrawTextEx(FONT1, t, z.NewVector2(x, y), float32(FONT1.BaseSize)*siz, 0, c)
}
func dTXTfont2XY(t string, x, y, siz float32, c z.Color) {
z.DrawTextEx(FONT2, t, z.NewVector2(x, y), float32(FONT2.BaseSize)*siz, 0, c)
}
func dTXTfont2XYSHADOW(t string, x, y, siz float32, c, cShadow z.Color, offsetShadow float32) {
z.DrawTextEx(FONT2, t, z.NewVector2(x-offsetShadow, y+offsetShadow), float32(FONT2.BaseSize)*siz, 0, cShadow)
z.DrawTextEx(FONT2, t, z.NewVector2(x, y), float32(FONT2.BaseSize)*siz, 0, c)
}
func dTXTDEFF32(t string, x, y float32) {
z.DrawText(t, int32(x), int32(y), 20, z.White)
}
func dTXTDEF10(t string, x, y int32) {
z.DrawText(t, x, y, 10, z.White)
}
func dTXTDEF10C(t string, x, y int32, c z.Color) {
z.DrawText(t, x, y, 10, c)
}
func dTXTDEF20(t string, x, y int32) {
z.DrawText(t, x, y, 20, z.White)
}
func dTXTDEF20C(t string, x, y int32, c z.Color) {
z.DrawText(t, x, y, 20, c)
}