react-native-smart-dimension
Version:
A simple and lightweight React Native library for responsive dimensions, scaling, and adaptive UI design.
11 lines (9 loc) • 447 B
text/typescript
export const percentageCalculation = (max: number, val: number) => max * (val / 100);
export const fontCalculation = (height: number, width: number, val: number) => {
const widthDimension = Math.min(height, width);
const aspectRatioBasedHeight = (16 / 9) * widthDimension;
const diagonal = Math.sqrt(
Math.pow(aspectRatioBasedHeight, 2) + Math.pow(widthDimension, 2)
);
return percentageCalculation(diagonal, val);
};