From 28068e8ecfd9802f40689ff2ed5760751db67835 Mon Sep 17 00:00:00 2001 From: Emirhan Yener <97049246+emirhanyener@users.noreply.github.com> Date: Tue, 28 Jun 2022 08:30:45 +0300 Subject: [PATCH] gg: add draw_polygon_filled test (#14871) --- vlib/gg/testdata/draw_simple_polygons.vv | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 vlib/gg/testdata/draw_simple_polygons.vv diff --git a/vlib/gg/testdata/draw_simple_polygons.vv b/vlib/gg/testdata/draw_simple_polygons.vv new file mode 100644 index 0000000000..ba41701f5b --- /dev/null +++ b/vlib/gg/testdata/draw_simple_polygons.vv @@ -0,0 +1,61 @@ +import gg +import gx + +struct App { +mut: + gg &gg.Context = 0 + rotation f32 = f32(0) +} + +[console] +fn main() { + mut app := &App{} + + app.gg = gg.new_context( + window_title: 'Simple Polygons' + width: 500 + height: 500 + bg_color: gx.black + event_fn: event + frame_fn: render + user_data: app + ) + + app.gg.run() +} + +fn render(app &App) { + app.gg.begin() + + color := gx.Color{ + r: 175 + g: 0 + b: 0 + a: 200 + } + mut shape := 3 + for i := 1; i < 5; i++ { + for j := 1; j < 5; j++ { + app.gg.draw_polygon_filled(100 * j, 100 * i, 30, shape, app.rotation, color) + shape++ + } + } + + app.gg.end() +} + +fn event(e &gg.Event, mut app App) { + match e.typ { + .key_down { + match e.key_code { + .right { app.rotation++ } + .left { app.rotation-- } + .escape { app.gg.quit() } + else {} + } + print('rotation: ') + println(app.rotation) + } + else {} + } +}