From ea31c2a64368a6f6892bb0ff59fc4853dd2d63af Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 30 Aug 2020 19:58:09 +0300 Subject: [PATCH] examples: fix graph for hdpi screens --- examples/hot_reload/graph.v | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/hot_reload/graph.v b/examples/hot_reload/graph.v index 7ae0d62b30..2a35711f76 100644 --- a/examples/hot_reload/graph.v +++ b/examples/hot_reload/graph.v @@ -44,8 +44,12 @@ fn frame(mut ctx Context) { [live] fn (ctx &Context) draw() { - w := sapp.width() - h := sapp.height() + mut w := sapp.width() + mut h := sapp.height() + if sapp.high_dpi() { + w /= 2 + h /= 2 + } ctx.gg.draw_line(0, h/2, w, h/2, gx.gray) // x axis ctx.gg.draw_line(w/2, 0, w/2, h, gx.gray) // y axis atime := f64(time.ticks() / 10) @@ -54,7 +58,7 @@ fn (ctx &Context) draw() { blue := gx.Color {r:100, g:100, b:200} red := gx.Color {r:200, g:100, b:100} y = 1.0 - max := f32(w)/scale + max := f32(w)/(2*scale) min := -max for x := min; x <= max; x += 0.01 { // y = x*x + 2