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

gg: add draw_polygon_filled test (#14871)

This commit is contained in:
Emirhan Yener 2022-06-28 08:30:45 +03:00 committed by GitHub
parent 42df154399
commit 28068e8ecf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {}
}
}