1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

examples: simpify text rendering examples

This commit is contained in:
Alexander Medvednikov 2020-07-06 19:55:49 +02:00
parent 1f3d7d393e
commit ebb4935703
2 changed files with 2 additions and 13 deletions

View File

@ -1,7 +1,6 @@
module main
import gg
import gg.ft
import gx
import os
@ -62,18 +61,8 @@ lines = text.split('\n')
struct App {
mut:
gg &gg.Context
ft &ft.FT
}
fn init_gui(mut game App){
x := ft.new({
font_size: 13
scale: 2
font_path: os.resource_abs_path('../assets/fonts/RobotoMono-Regular.ttf')
}) or { panic(err) }
game.ft = x
}
fn main() {
mut app := &App{}
app.gg = gg.new_context({
@ -86,17 +75,17 @@ fn main() {
bg_color: bg_color
init_fn: init_gui
frame_fn: frame
font_path: os.resource_abs_path('../assets/fonts/RobotoMono-Regular.ttf')
//window_user_ptr: ctx
})
app.gg.run()
}
fn frame(mut app App) {
app.ft.flush()
app.gg.begin()
mut y := 10
for line in lines {
app.ft.draw_text_def(10,y, line)
app.gg.draw_text_def(10, y, line)
y += 30
}
app.gg.end()