https://github.com/shubhranshu/aspect-ratio
Library to calculate aspect ratios and provide conversion between different dimensions
https://github.com/shubhranshu/aspect-ratio
16-9 4k aspect aspect-ratio device-ratio display fullhd hd ratio screen sd
Last synced: 15 days ago
JSON representation
Library to calculate aspect ratios and provide conversion between different dimensions
- Host: GitHub
- URL: https://github.com/shubhranshu/aspect-ratio
- Owner: shubhranshu
- License: mit
- Created: 2020-04-18T08:35:10.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T04:03:57.000Z (over 2 years ago)
- Last Synced: 2025-03-18T06:29:45.924Z (about 1 month ago)
- Topics: 16-9, 4k, aspect, aspect-ratio, device-ratio, display, fullhd, hd, ratio, screen, sd
- Language: JavaScript
- Size: 282 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Aspect ratio
[](https://github.com/shubhranshu/aspect-ratio/actions?query=workflow%3ABuild)
[](https://github.com/shubhranshu/aspect-ratio/issues)
[](https://github.com/shubhranshu/aspect-ratio)
[](https://www.npmjs.com/package/@stubbydigits/aspect-ratio)
[](https://www.npmjs.com/package/@stubbydigits/aspect-ratio)[NPM Package](https://www.npmjs.com/package/@stubbydigits/aspect-ratio)
Calculate aspect ratios.
## Usage
Library exports a single function `calculateRatio(x, y)` which returns the result object.
x and y are numbers. X is always the bigger number.### Result object
The program returns an object with two properties
```javascript
{
match : {},
sortedRatios : [],
}
```- ```match``` : Calculated aspect ratio if there is an exact match
- ```sortedRatios``` : List of aspect ratios ordered by proximity to the original dimensions#### Result format
Result for both match and sortedRatios is of the following format
```javascript
{
name: "19by16", // usable name for program literals
ratio: "19:16", // Common name for the aspect ratio, if any
proximity : "0.123", // ascending numeric valu to represent closeness to the dimensions provided
description: "Sometimes referred to as the Movietone ratio, this ratio was used briefly during the transitional period when the film industry was converting to sound, from 1926 to 1932 approx. It is produced by superimposing an optical soundtrack over a full-gate 1.3 aperture in printing, resulting in an almost square image. Films shot in this ratio are often projected or transferred to video incorrectly using a 1.37 mask or squashed to 1.37. Examples of films shot in the Movietone ratio include Sunrise, M, Hallelujah! and The Lighthouse."
// Description for the aspect ratio, usages and history.
}
```