Hello,
While writing a little program on android processing, I noticed that the rendering was not the same depending on the screen I was using. Here is the code:
i would assume that this is because the proportion of the screen varies between devices. I would first calculate the proportion of the screen and then i would use that info to calculate the position (and size) of the ellipses.
If you follow the link above, it says you need to use displayDensity():
void setup() {
fullScreen();
noStroke();
}
void draw() {
background(0);
float r = 50 * displayDensity; // <------ This ensures this value is independent on screen specifications
int maxi = int(width/r);
int maxj = int(height/r);
for (int i = 0; i <= maxi; i++) {
float x = map(i, 0, maxi, 0, width);
for (int j = 0; j <= maxj; j++) {
float y = map(j, 0, maxj, 0, height);
ellipse(x, y, r, r);
}
}
}
I do not have much experience with this topic, but I believe this is the way to do it. Give it a try and tell us if it works for you, or if it doesn’t.
I do not know too much, but I think the problem does not come from the dpi but rather a problem of compatibility between the screen ratio (16 / 9,18 / 9,4 / 3).
Can you verify this? You have two dimensions, along the width and the height of the display. But your ellipses are based on the height only. Shouldn’t it be:
if I use the line " ellipse(width / 3.71824f, height / 1.73, width/ 18.5, height / 18.5); " I would need a square screen (width=height), otherwise the ellipse is not round.
Here is the result of the next line " println(nf(1.0/displayDensity,0,4), width, height, nf(width*1.0/height, 0, 2)); "
Consol : 0,3333 1080 1920 0,56
My phone is an Asus zenfone 3 laser ,DPI = 401, screen = 1080*1920.
I only considered screens with different width. If the height of the screen changes the center circle also changes. Maybe you should make it independent from the height.
An other idea is to always use a fixed 16:9 rectangle inside of the screen.
If there is a 16:9 phone it will display fullscreen, but width a 18:9 smartphone there will be a black line on the bottom.
If to define the size of the circle I use the width instead of the height, the problem is the same.
About your other idea you may be right for the 18/9 screen but it may be more embarrassing if the user uses a screen 4/3.