Convert X and Y px base on Screen size

走远了吗. 提交于 2019-12-11 11:38:50

问题


im using this command input tap x y (input tap 600 500) in a phone with a screen resolution of 720 x 1280 how do I convert the x y so it will be same point in a phone with a resolution of 1080 x 1920. Thanks


回答1:


This pseudo code should get you the values you're looking for:

resolution_width = 720;
resolution_height = 1280;

input_x = 600;
input_y = 500;

target_width = 1080;
target_height = 1920;

percent_width = input_x / resolution_width;
percent_height = input_y / resolution_height;

output_x = target_width * percent_width;
output_y = target_height * percent_height;


来源:https://stackoverflow.com/questions/21581265/convert-x-and-y-px-base-on-screen-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!