X
X
XiNull2021-07-20 05:41:32
Java
XiNull, 2021-07-20 05:41:32

How to calculate distance between objects with dynamic X and Y?

We have a screen, canvas or graphic, X (width) and Y (height), in pixels.
X and Y may change depending on the resolution of the device/screen/display.

For example:

X: ~1080 px
Y: ~218 px

You need to mark up 2 or n objects.
Let Y(obj) of each object be ~218 px, and X(obj) is unknown, but for example, you can take ~109 px.

Let's take d (distance) as the distance of objects from each other.

Purpose: The distance between objects should be the same despite different screens, canvases or graphics, i.e. X and Y screen, canvas or graphics may change. Those. we pass the same unit of distance and get the same distance between objects. Maybe someone has some ideas? I really need a formula.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hint000, 2021-07-20
@XiNull

It's all right?
60f64f27e096a052554223.png

L
LoliDeveloper, 2021-07-20
@LoliDeveloper

The distance between objects must be the same

Same in relation to the real world? Then forget about the screen resolution and stupidly cut to one resolution that you need, and on small screens it simply will not fit on the monitor. Otherwise, I don’t understand how you can keep the distance when the device can be at least a watch, even a plasma.
Or do you mean percentage?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question