-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Completed
Showing
7 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This is a simple Aspect Ratio Calculator that allows users to input width and height values and calculates the simplified aspect ratio. The calculator uses the greatest common divisor (GCD) to simplify the ratio. | ||
|
||
## Tech Stacks | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Screenshots | ||
![image](calculator.png) | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Aspect Ratio Calculator</title> | ||
|
||
</head> | ||
<body> | ||
<div class="calculator"> | ||
<h2>Aspect Ratio Calculator</h2> | ||
|
||
<label for="width">Width:</label> | ||
<input type="number" id="width" placeholder="Enter width" oninput="calculateAspectRatio()"> | ||
|
||
<label for="height">Height:</label> | ||
<input type="number" id="height" placeholder="Enter height" oninput="calculateAspectRatio()"> | ||
|
||
<h3>Aspect Ratio:</h3> | ||
<p id="aspectRatio"></p> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function calculateAspectRatio() { | ||
const width = document.getElementById('width').value; | ||
const height = document.getElementById('height').value; | ||
|
||
if (width && height && width > 0 && height > 0) { | ||
const gcd = findGCD(width, height); | ||
const aspectRatio = `${width / gcd}:${height / gcd}`; | ||
document.getElementById('aspectRatio').innerHTML = `Aspect Ratio: ${aspectRatio}`; | ||
} else { | ||
document.getElementById('aspectRatio').innerHTML = 'Enter valid width and height.'; | ||
} | ||
} | ||
|
||
function findGCD(a, b) { | ||
return b === 0 ? a : findGCD(b, a % b); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap'); | ||
|
||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
font-family: "Roboto Condensed", sans-serif; | ||
background:url(./bg.jpg); | ||
color: #fff; | ||
|
||
} | ||
|
||
.calculator { | ||
text-align: center; | ||
border: 1px solid #fff; | ||
width: 500px; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
background: transparent; | ||
backdrop-filter: blur(10px); | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
input { | ||
margin: 10px 5px; | ||
padding: 10px; | ||
font-size: 16px; | ||
background: transparent; | ||
color: #fff; | ||
border: none; | ||
border-bottom: 1px solid; | ||
} | ||
|
||
p { | ||
font-size: 16px; | ||
margin: 5px 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters