Page 1 of 1
Device independent pixels
Posted: Fri Oct 06, 2017 6:40 pm
by mdp
To use device independent pixels (DIPs) for the coordinates, do you make an explicit calculation (e.g. width/density) or is there a systemic way?
Re: Device independent pixels
Posted: Sat Oct 07, 2017 4:23 am
by mdp
I was expecting to find something like GetScreenDensity() in either Desktop or System, I was surprised not to find it.
A 5'' device can have a long side of 640, or 1280, or 2560px, or other, and a desktop screen can easily be around 96ppi. This means ppi measures of, for example, 96ppi, 160ppi, 320ppi, 640ppi - roughly 6 times between these two extremes, and since we are talking of areas perceptually one element can occupy 30 or 40 times the space it takes on another device.
123 pixels on one device can be tiny, on another huge.
SB must have a way to abstract size, either with an internal transformation (e.g. use 2 real pixels per virtual pixel where 2 is internally computed as Round(detected_density/base_density), ), or letting the coder do it "manually" through a command like GetScreenDensity() .
Re: Device independent pixels
Posted: Sat Oct 07, 2017 10:34 pm
by falsam
mdp wrote:A 5'' device can have a long side of 640, or 1280, or 2560px, or other, and a desktop screen can easily be around 96ppi. This means ppi measures of, for example, 96ppi, 160ppi, 320ppi, 640ppi - roughly 6 times between these two extremes, and since we are talking of areas perceptually one element can occupy 30 or 40 times the space it takes on another device.
Can you test this code with an Android terminal ?
http://forums.spiderbasic.com/viewtopic.php?f=13&t=1288
Re: Device independent pixels
Posted: Sun Oct 08, 2017 7:44 pm
by mdp
This is great, it works!
So the idea is to use a
screen_density = 0
!v_screen_density = window.devicePixelRatio;
and you lock the zoom with both
!$('head').append('<meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=0">');
and
!document.body.style.zoom = 1 / window.devicePixelRatio * 100 + "%"