Script Categories













Calculators >>> Field Depth.

For all you photography enthusiasts out there, this script makes it a breeze to determine the field depth and amount that will be in focus in a photograph. Includes other measurements such as nearest and furthest points of focus, too.

Depth of Field Calculator
Negative Format
Lens focal length
Selected aperture
Subject distance (Meters)


Hyperfocal distance for this lens/aperture combination.
Near limit of acceptable sharpness.
Far limit of acceptable sharpness.
Total depth of field.

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function doField(form) {
distance = (form.distance.value)*1000;
CoC = (document.form.format.options[document.form.format.selectedIndex].value);
aperture = (document.form.aperture.options[document.form.aperture.selectedIndex].value);
focal = (document.form.focal.options[document.form.focal.selectedIndex].value);
if (isNaN(distance))  {
alert('Please enter a numerical value for subject distance.');
document.form.distance.focus();
document.form.distance.select();
}
else {
hyperFocal = (focal * focal) / (aperture * CoC);
form.hyperFocal.value  = Math.round(hyperFocal) / 1000 + " m";
dofNear = (hyperFocal * distance) / (hyperFocal + (distance - focal));
form.dofNear.value = Math.round(dofNear) / 1000 + " m";
dofFar = (hyperFocal * distance) / (hyperFocal - (distance - focal));
if (dofFar < 0) {
form.dofFar.value  = "Infinity.";
}
else {
form.dofFar.value  = Math.round(dofFar)/1000+" m";
}
dofTotal = Math.round(dofFar - dofNear);
if (dofTotal < 0) {
form.dofTotal.value  = "Infinite.";
}
else {
if (dofTotal >= 0 && dofTotal < 0.001) {
form.dofTotal.value  = ">1 mm "; 
}
else {
form.dofTotal.value = dofTotal / 1000 + " m"; 
        
}
      }
   }
}
//  End -->
</script>
<form method=post name=form>
<table border=3 cellpadding=10 cellspacing=0 width=500>
<tr>
<td
align=center colspan=2>
Depth of Field Calculator
</td>
</tr>
<tr>
<td
align=left>
Negative Format
</td>
<td
align=left>
<select name=format>
<option
value=0.033>35 mm
<option value=0.025>APS
<option value=0.05>6x45 cm 
<option value=0.06>6x6 cm
<option value=0.065>6x7 cm
<option value=0.15>5x4 inch
<option value=0.3>10x8 inch
</select>
</td>
</tr>
<tr>
<td
align=left>
Lens focal length
</td>
<td
align=left>
<select name=focal>
<option
value=17>17 mm
<option value=20>20 mm
<option value=24>24 mm
<option value=28>28 mm
<option value=35>35 mm
<option value=50>50 mm
<option value=70>70 mm
<option value=80>80 mm
<option value=100>100 mm
<option value=135>135 mm
<option value=150>150 mm
<option value=200>200 mm
<option value=210>210 mm
<option value=300>300 mm
<option value=350>350 mm
<option value=400>400 mm
</select>
</td>
</tr>
<tr>
<td
align=left>
Selected aperture
</td>
<td
align=left>
<select name=aperture>
<option
value=1.4>F 1.4
<option value=1.8>F 1.8
<option value=2>F 2
<option value=2.8>F 2.8
<option value=4>F 4
<option value=5.6>F 5.6
<option value=8> F 8
<option value=11>F 11
<option value=16>F 16
<option value=22>F 22
<option value=32>F 32
<option value=45>F 45
<option value=64>F 64
<option value=90>F 90
</select>
</td>
</tr>
<tr>
<td
align=left>
Subject distance (Meters)
</td>
<td
align=left>
<input type=text name=distance value="" size=6>
</td>
</tr>
<tr>
<td
colspan=2 align=left>
<br>
<
center><input type=button value="Calculate." onclick="doField(this.form)"></center>
<
br>
<input name=hyperFocal type=text value="" size=6> Hyperfocal distance for this lens/aperture combination.
<BR>
<input name=dofNear type=text value="" size=6> Near limit of acceptable sharpness.
<BR>
<input name=dofFar type=text value="" size=6> Far limit of acceptable sharpness.
<BR>
<input name=dofTotal type=text value="" size=6> Total depth of field.
<BR>
<
br>
</td></tr>
</form>
</table>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©