UNPKG

screencalc

Version:

Calculate data about any display (width, height, ratio, area, density, etc.)

19 lines (18 loc) 1.28 kB
/** Calculate the height of a rectangle from its ratio and area */ export declare function heightFromRatioAndArea(ratio: number, area: number): number; /** Calculate the physical height of a rectangle from its ratio and diagonal size */ export declare function physicalHeightFromRatioAndDiagonalSize(ratio: number, diagonalSize: number): number; /** * Calculates the simplest fraction for a floating point number using continued fractions * (based on http://en.wikipedia.org/wiki/Continued_fraction#Infinite_continued_fractions) * Returns an array containing the numerator and denominator of the simplified fraction. * @param f The number to calculate the simplest fraction for * @param epsilon A number between 0 and 1 which determines precision. Values closer to * zero increase precision. Defaults to a magic number which returns the * "expected" ratio for common screen resolutions. */ export declare function calculateSimplestFraction(f: number, epsilon?: number): [number, number]; /** Returns true if the specified value is a positive integer */ export declare function isPositiveInt(val: any): boolean; /** Returns true if the value is a positive number */ export declare function isPositiveNum(val: any): boolean;