xref: /MusicFree/src/utils/rpx.ts (revision ec4205c41122a549937356610b34e18616168da1)
1bf6e62f2S猫头猫import {Dimensions} from 'react-native';
2bf6e62f2S猫头猫
3bf6e62f2S猫头猫const windowWidth = Dimensions.get('window').width;
485661c25S猫头猫const windowHeight = Dimensions.get('window').height;
5*ec4205c4S猫头猫const minWindowEdge = Math.min(windowHeight, windowWidth);
6*ec4205c4S猫头猫const maxWindowEdge = Math.max(windowHeight, windowWidth);
7bf6e62f2S猫头猫
8bf6e62f2S猫头猫export default function (rpx: number) {
9*ec4205c4S猫头猫    return (rpx / 750) * minWindowEdge;
10bf6e62f2S猫头猫}
1185661c25S猫头猫
1285661c25S猫头猫export function vh(pct: number) {
13c446f2b8S猫头猫    return (pct / 100) * Dimensions.get('window').height;
1485661c25S猫头猫}
154173d3ebS猫头猫
164173d3ebS猫头猫export function vw(pct: number) {
17c446f2b8S猫头猫    return (pct / 100) * Dimensions.get('window').width;
18c446f2b8S猫头猫}
19c446f2b8S猫头猫
20*ec4205c4S猫头猫export function vmin(pct: number) {
21*ec4205c4S猫头猫    return (pct / 100) * minWindowEdge;
22*ec4205c4S猫头猫}
23*ec4205c4S猫头猫
24*ec4205c4S猫头猫export function vmax(pct: number) {
25*ec4205c4S猫头猫    return (pct / 100) * maxWindowEdge;
26*ec4205c4S猫头猫}
27*ec4205c4S猫头猫
28c446f2b8S猫头猫export function sh(pct: number) {
29c446f2b8S猫头猫    return (pct / 100) * Dimensions.get('screen').height;
30c446f2b8S猫头猫}
31c446f2b8S猫头猫
32c446f2b8S猫头猫export function sw(pct: number) {
33c446f2b8S猫头猫    return (pct / 100) * Dimensions.get('screen').width;
344173d3ebS猫头猫}
35