-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculatorHAHAHA.HTML
48 lines (45 loc) · 2.28 KB
/
CalculatorHAHAHA.HTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<title>Pixel Width Calculator</title>
<script>
function calculatePixelWidth() {
// Get input values
var aspectRatio = document.getElementById("aspectRatio").value;
var resolutionWidth = parseInt(document.getElementById("resolutionWidth").value);
var resolutionHeight = parseInt(document.getElementById("resolutionHeight").value);
var decimalPlaces = parseInt(document.getElementById("decimalPlaces").value);
// Calculate pixel width in degrees
var widthRatio = parseFloat(aspectRatio.split(":")[0]);
var heightRatio = parseFloat(aspectRatio.split(":")[1]);
var diagonal = Math.sqrt(resolutionWidth * resolutionWidth + resolutionHeight * resolutionHeight);
var pixelWidth = Math.atan2(heightRatio, widthRatio) * (180 / Math.PI);
// Display result without rounding
document.getElementById("result").innerHTML = "Pixel Width (no rounding): " + pixelWidth.toString() + " degrees";
// Calculate and display result with rounding
var roundedPixelWidth = pixelWidth.toFixed(decimalPlaces);
document.getElementById("roundedResult").innerHTML = "Pixel Width (rounded): " + roundedPixelWidth + " degrees";
}
</script>
</head>
<body>
<h1>Pixel Width Calculator</h1>
<form onsubmit="return false;">
<label for="aspectRatio">Aspect Ratio:</label>
<input type="text" id="aspectRatio" placeholder="Enter aspect ratio (e.g., 4:3)" required>
<br>
<label for="resolutionWidth">Resolution Width:</label>
<input type="text" id="resolutionWidth" placeholder="Enter resolution width" required>
<br>
<label for="resolutionHeight">Resolution Height:</label>
<input type="text" id="resolutionHeight" placeholder="Enter resolution height" required>
<br>
<label for="decimalPlaces">Decimal Places:</label>
<input type="text" id="decimalPlaces" placeholder="Enter decimal places for rounding" required>
<br>
<button onclick="calculatePixelWidth()">Calculate</button>
</form>
<p id="result"></p>
<p id="roundedResult"></p>
</body>
</html>