From 0b4a93c1c1dd33a24f53613beaa34fbc6b4f2814 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 29 Dec 2023 16:30:54 +0200 Subject: [PATCH] examples: add an even smaller gg usage example, demonstrating how to always show the builtin fps counter, and how to avoid importing gx --- examples/gg/minimal.v | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/gg/minimal.v diff --git a/examples/gg/minimal.v b/examples/gg/minimal.v new file mode 100644 index 0000000000..682ce30cb6 --- /dev/null +++ b/examples/gg/minimal.v @@ -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() +}