-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext.bah
76 lines (61 loc) · 1.9 KB
/
text.bah
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
/////////////////////////////////////////////////////////////
// Shapes demo using OpenGL and GLUT in Bah. //
// To compile, use 'bah ./text.bah -d'. //
// //
// © Aloïs Laurent Boë //
/////////////////////////////////////////////////////////////
#import "iostream.bah"
#import "../vbah.bah"
win = new window
helloFont font
vbahFont font
m = []textMarkup
const TEXT1 = "VBAH"
const TEXT2 = "Hello World!"
const TEXT3 = "This text is antialiased."
display() {
textSize = vec(<float>vbahFont.calcWidth(TEXT1), 40.0)
pixelsDimToCoords(&textSize)
vbahFont.writeMarkup(vec(0.0 - textSize.x/2.0, textSize.y), m, 0, TEXT1)
textSize = vec(<float>helloFont.calcWidth(TEXT2), 0.0)
pixelsDimToCoords(&textSize)
helloFont.write(vec(0.0 - textSize.x/2.0 ,0.0), rgb(1.0,1.0,1.0), TEXT2)
textSize = vec(<float>helloFont.calcWidth(TEXT3), <float>helloFont.getHeight() + 10.0)
pixelsDimToCoords(&textSize)
helloFont.write(vec(0.0 - textSize.x/2.0 , 0.0 - textSize.y), rgb(0.8,0.8,0.8), TEXT3)
}
init() {
helloFont = font{}
helloFont.load("./assets/font/DroidSansMono.ttf")
helloFont.setSize(20)
vbahFont = font{}
vbahFont.load("./assets/font/Fast Hand.ttf")
vbahFont.setSize(50)
m = []textMarkup{
textMarkup{
pos: 0
color: rgb(1.00,0.00,0.00)
},
textMarkup{
pos: 1
color: rgb(1.00,1.00,0.00)
},
textMarkup{
pos: 2
color: rgb(0.00,1.00,0.33)
},
textMarkup{
pos: 3
color: rgb(0.00,0.80,1.00)
}
}
}
main(args []str) int {
//launching the window
win = window(600, 600, "Text")
win.autoLoop = false
win.display = display
win.init = init
win.launch()
return 0
}