根据屏幕尺寸转换X和Y px [英] Convert X and Y px base on Screen size

查看:119
本文介绍了根据屏幕尺寸转换X和Y px的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在屏幕分辨率为720 x 1280的手机中使用此命令input tap x y(input tap 600 500)在如何转换x y以便在分辨率为1080 x 1920的手机中它是同一点.谢谢

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

推荐答案

此伪代码应为您提供所需的值:

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;

这篇关于根据屏幕尺寸转换X和Y px的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆