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:
Delyan Angelov 2023-12-29 16:30:54 +02:00
parent 08ff84627c
commit 0b4a93c1c1
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

19
examples/gg/minimal.v Normal file
View 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()
}