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

examples: fix graph for hdpi screens

This commit is contained in:
Delyan Angelov 2020-08-30 19:58:09 +03:00
parent d33f68ff54
commit ea31c2a643

View File

@ -44,8 +44,12 @@ fn frame(mut ctx Context) {
[live] [live]
fn (ctx &Context) draw() { fn (ctx &Context) draw() {
w := sapp.width() mut w := sapp.width()
h := sapp.height() 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(0, h/2, w, h/2, gx.gray) // x axis
ctx.gg.draw_line(w/2, 0, w/2, h, gx.gray) // y axis ctx.gg.draw_line(w/2, 0, w/2, h, gx.gray) // y axis
atime := f64(time.ticks() / 10) atime := f64(time.ticks() / 10)
@ -54,7 +58,7 @@ fn (ctx &Context) draw() {
blue := gx.Color {r:100, g:100, b:200} blue := gx.Color {r:100, g:100, b:200}
red := gx.Color {r:200, g:100, b:100} red := gx.Color {r:200, g:100, b:100}
y = 1.0 y = 1.0
max := f32(w)/scale max := f32(w)/(2*scale)
min := -max min := -max
for x := min; x <= max; x += 0.01 { for x := min; x <= max; x += 0.01 {
// y = x*x + 2 // y = x*x + 2