Device independent pixels
Device independent pixels
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
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() .
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
Can you test this code with an Android terminal ? http://forums.spiderbasic.com/viewtopic.php?f=13&t=1288mdp 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.
➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
➽ http://falsam.com
Sorry for my poor english
Re: Device independent pixels
This is great, it works!falsam wrote:Can you test this code with an Android terminal ? http://forums.spiderbasic.com/viewtopic.php?f=13&t=1288
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 + "%"