38 lines
1.1 KiB
Coq
38 lines
1.1 KiB
Coq
|
import gx
|
||
|
|
||
|
fn (game &Game) text_format(color gx.Color, size int, h_align gx.HorizontalAlign, v_align gx.VerticalAlign) gx.TextCfg {
|
||
|
return gx.TextCfg{
|
||
|
color: color
|
||
|
align: h_align
|
||
|
vertical_align: v_align
|
||
|
size: size
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn (game &Game) draw_text(x int, y int, text string, size int, color gx.Color, ha string, va string, shadow bool) {
|
||
|
mut v_align := gx.VerticalAlign.baseline
|
||
|
mut h_align := gx.HorizontalAlign.left
|
||
|
|
||
|
match va {
|
||
|
'top' { v_align = gx.VerticalAlign.top }
|
||
|
'middle' { v_align = gx.VerticalAlign.middle }
|
||
|
'bottom' { v_align = gx.VerticalAlign.bottom }
|
||
|
'baseline' { v_align = gx.VerticalAlign.baseline }
|
||
|
else { v_align = gx.VerticalAlign.top }
|
||
|
}
|
||
|
|
||
|
match ha {
|
||
|
'left' { h_align = gx.HorizontalAlign.left }
|
||
|
'center' { h_align = gx.HorizontalAlign.center }
|
||
|
'right' { h_align = gx.HorizontalAlign.right }
|
||
|
else { h_align = gx.HorizontalAlign.left }
|
||
|
}
|
||
|
|
||
|
if shadow {
|
||
|
game.gg.draw_text(x + 2, y + 2, text, game.text_format(gx.black, size, h_align,
|
||
|
v_align))
|
||
|
}
|
||
|
|
||
|
game.gg.draw_text(x, y, text, game.text_format(color, size, h_align, v_align))
|
||
|
}
|