-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfov_cal.html
152 lines (141 loc) · 6.07 KB
/
fov_cal.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html>
<head>
<title>Horizontal/Vertical FOV Calculator</title>
<link rel="icon" type="image/png" href="icon.png">
<link rel="icon" sizes="196x196" href="bigicon.png">
<meta name="viewport" content="width=device-width">
<meta charset="UTF-8">
<meta name="description" content="Online Horizontal / Vertical Field of View calculator and converter for games, including popular monitor setup presets.">
<meta name="keywords" content="fov,field of view,calculator,horizontal,vertical,converter">
<script type="text/javascript">
function calc()
{
var width = document.getElementById("hres").value;
var height = document.getElementById("vres").value;
var hfovRad = document.getElementById("hfov").value * Math.PI / 180;
var vfovRad = 2*Math.atan(Math.tan(hfovRad/2)*height/width);
document.getElementById("vfov").value = Math.ceil(vfovRad* 180 / Math.PI);
}
function setRes (horz, vert) {
document.getElementById("hres").value = horz;
document.getElementById("vres").value = vert;
calc();
}
window.onload = calc;
</script>
<style type="text/css">
body {
margin-left: auto;
margin-right: auto;
background-color: gainsboro;
max-width: 400px;
padding: 0;
font-family: sans-serif;
}
fieldset {
border-radius: 5px;
border: 3px solid #333
}
.aspectButton {
border: 3px solid #111;
border-radius: 3px;
background-color: #333;
color: gainsboro;
display: inline-block;
font-size: 15px;
vertical-align: middle;
line-height: 27px;
cursor: pointer;
}
input[type=text], input[type=number] {
width: 50px;
}
input[type='range'] {
-webkit-appearance: none;
border-radius: 2px;
background-color: #999;
height: 4px;
vertical-align: middle;
}
input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none !important;
border-radius: 25%;
background-color: #FFF;
border: 1px solid #999;
height: 20px;
width: 20px;
}
</style>
</head>
<body>
<h1 style="text-align:center">Horizontal/Vertical FOV Calculator</h1>
<p style="text-align:justify;text-justify:inter-word;padding:5px;">
This calculator will convert an aspect ratio and horizontal FOV to a vertical FOV, useful for setting your favorite horizontal FOV in a game that uses vertical FOV. You can use either an aspect ratio, or, if you do not know your screen's aspect ratio, you can input your screen's resolution.
</p>
<form>
<fieldset>
<legend>Aspect Ratio Presets</legend>
<table style="width:100%;">
<tr style="text-align:center;">
<td><div class="aspectButton" style="width:50px;height:27px;" onclick="setRes(16, 9)" title="e.g. 1920x1080" >16:9</div></td>
<td><div class="aspectButton" style="width:45px;height:27px;" onclick="setRes(16, 10)" title="e.g. 1920x1200" >16:10</div></td>
<td><div class="aspectButton" style="width:67px;height:27px;" onclick="setRes(21, 9)" title="e.g. 2560x1080" >21:9</div></td>
<td><div class="aspectButton" style="width:37px;height:27px;" onclick="setRes(4, 3)" title="e.g. 1024x768" >4:3</div></td>
<td><div class="aspectButton" style="width:35px;height:27px;" onclick="setRes(5, 4)" title="e.g. 1280x1024" >5:4</div></td>
</tr>
</table>
<table style="width:100%;">
<tr style="text-align:center;">
<td><div onclick="setRes(12, 3)" title="e.g. 3x1024x768"> <div class="aspectButton" style="width:37px;height:27px;">4:3</div><div class="aspectButton" style="width:37px;height:27px;">4:3</div><div class="aspectButton" style="width:37px;height:27px;">4:3</div></div></td>
<td><div onclick="setRes(48, 9)" title="e.g. 3x1920x1080"><div class="aspectButton" style="width:51px;height:27px;">16:9</div><div class="aspectButton" style="width:51px;height:27px;">16:9</div><div class="aspectButton" style="width:51px;height:27px;">16:9</div></div></td>
</tr>
</table>
<table style="width:100%;">
<tr style="text-align:center;">
<td><div onclick="setRes(27, 16)" title="e.g. 3x1920x1080"><div class="aspectButton" style="width:27px;height:51px;line-height:51px;font-size:10px;">16:9</div><div class="aspectButton" style="width:27px;height:51px;line-height:51px;font-size:10px;">16:9</div><div class="aspectButton" style="width:27px;height:51px;line-height:51px;font-size:10px;">16:9</div></div></td>
</tr>
</table>
</fieldset>
<br>
<fieldset>
<legend>Calculator</legend>
<table style="text-align:center;">
<tr>
<td>
<p><label for="hres">Horizontal Resolution / Aspect</label></p>
</td>
<td>
<p><input name="hres" id="hres" type="number" value="16" onchange="calc()"></p>
</td>
</tr>
<tr>
<td>
<p><label for="vres">Vertical Resolution / Aspect</label></p>
</td>
<td>
<p><input name="vres" id="vres" type="number" value="9" onchange="calc()"></p>
</td>
</tr>
<tr>
<td>
<p><label for="hfov">Horizontal FOV</label></p>
</td>
<td>
<p><input name="hfov" min="1" max="180" id="hfov" type="number" value="90" onchange="hfovslider.value=hfov.value; calc()">°</p>
<p><input id="hfovslider" type="range" min="1" max="180" step="1" value="90" oninput="hfov.value=hfovslider.value; calc();" onchange="hfov.value=hfovslider.value; calc();"></p>
</td>
</tr>
<tr>
<td>
<p><label for="vfov">Vertical FOV</label></p>
</td>
<td>
<p><input name="vfov" id="vfov" type="text" readonly>°</p>
</td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>