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

50 lines
765 B
V
Raw Permalink Normal View History

2022-01-26 11:32:14 +03:00
module main
import gg
import gx
struct App {
mut:
2023-02-01 23:38:41 +03:00
gg &gg.Context = unsafe { nil }
2022-01-26 11:32:14 +03:00
radius f64 = 10.0
}
fn main() {
mut app := &App{}
app.gg = gg.new_context(
bg_color: gx.white
width: 300
height: 300
window_title: 'Circles'
frame_fn: frame
event_fn: on_event
user_data: app
)
app.gg.run()
}
fn on_event(e &gg.Event, mut app App) {
match e.typ {
.key_down {
match e.key_code {
.up {
app.radius += 1
}
.down {
app.radius -= 1
}
else {}
}
}
else {}
}
}
fn frame(mut app App) {
app.gg.begin()
app.gg.draw_circle_empty(150, 150, f32(app.radius), gx.blue)
2023-02-01 23:38:41 +03:00
app.gg.draw_text(20, 20, 'radius: ${app.radius}')
2022-01-26 11:32:14 +03:00
// app.gg.draw_text(20, 50, 'circle_segment_size: $circle_segment_size')
app.gg.end()
}