mirror of
https://github.com/vlang/v.git
synced 2025-09-16 10:57:25 -04:00
examples: add an even smaller gg usage example, demonstrating how to always show the builtin fps counter, and how to avoid importing gx
This commit is contained in:
parent
08ff84627c
commit
0b4a93c1c1
19
examples/gg/minimal.v
Normal file
19
examples/gg/minimal.v
Normal file
@ -0,0 +1,19 @@
|
||||
import gg
|
||||
|
||||
fn main() {
|
||||
mut ctx := gg.new_context(
|
||||
window_title: 'Hello'
|
||||
bg_color: gg.Color{240, 240, 128, 255}
|
||||
width: 320
|
||||
height: 240
|
||||
frame_fn: on_frame
|
||||
)
|
||||
ctx.run()
|
||||
}
|
||||
|
||||
fn on_frame(ctx &gg.Context) {
|
||||
ctx.begin()
|
||||
ctx.draw_text(40, 100, 'GG frame: ${ctx.frame:06}', size: 30, color: gg.Color{50, 50, 255, 255})
|
||||
ctx.show_fps()
|
||||
ctx.end()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user