diff --git a/examples/hot_code_reloading/graph.v b/examples/hot_code_reloading/graph.v index 6372badd6b..3c23405509 100644 --- a/examples/hot_code_reloading/graph.v +++ b/examples/hot_code_reloading/graph.v @@ -8,7 +8,7 @@ import glfw import math const ( - Size = 1000 + Size = 700 Scale = 50.0 ) @@ -29,6 +29,7 @@ fn main() { always_on_top: true }) } + go update() // update the scene in the background in case the window isn't focused for { gg.clear(gx.White) ctx.draw() @@ -42,8 +43,18 @@ fn (ctx &Context) draw() { ctx.gg.draw_line(Size / 2, 0, Size / 2, Size) // y axis center := f64(Size / 2) for x := -10.0; x <= 10.0; x += 0.002 { - y := (x - 1) * (x - 1) - 2 - ctx.gg.draw_rect(center + x * Scale, - center - y * Scale, 1, 1, gx.Black) + y := x * x + 1 + //y := (x + 3) * (x + 3) - 1 + //y := math.sqrt(30.0 - x * x) + ctx.gg.draw_rect(center + x * Scale, center - y * Scale, 1, 1, gx.Black) + //ctx.gg.draw_rect(center + x * Scale, center + y * Scale, 1, 1, gx.Black) } } + +fn update() { + for { + gg.post_empty_event() + time.sleep_ms(300) + } + +} diff --git a/vlib/gg/gg.v b/vlib/gg/gg.v index 9f0af64235..8ada48c90b 100644 --- a/vlib/gg/gg.v +++ b/vlib/gg/gg.v @@ -329,6 +329,10 @@ fn update() { // # ui__post_empty_event(); } +pub fn post_empty_event() { + glfw.post_empty_event() +} + pub fn (c GG) circle(x, y, r int) { }