From 2163132ad60bd69cdda3d2be3afd46c2d9254444 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 2 Nov 2019 03:08:42 +0100 Subject: [PATCH] Increased drawing resolution for scaled screens --- touchscreen/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/touchscreen/__init__.py b/touchscreen/__init__.py index 41bdb11..d727ec2 100644 --- a/touchscreen/__init__.py +++ b/touchscreen/__init__.py @@ -314,6 +314,19 @@ def ts_onload(): canvas.style.height = ctx.canvas.height + 'px'; wrapper.style.width = ctx.canvas.width + 'px'; + + /* Get DPR with 1 as fallback */ + var dpr = window.devicePixelRatio || 1; + + /* CSS size is the same */ + canvas.style.height = ctx.canvas.height + 'px'; + wrapper.style.width = ctx.canvas.width + 'px'; + + /* Increase DOM size and scale */ + ctx.canvas.width *= dpr; + ctx.canvas.height *= dpr; + ctx.scale(dpr, dpr); + update_pen_settings() }