VX

vx

vx

Blog Article

Aspect Ratio Calculator

Enter values on the left side of the equation and one of the two values on the right side then click Calculate



























Enter the x1 value:





Enter the y1 value:

=














Enter the x2 value:





Enter the y2 value:

Ratio:


copyright>// function aspect_ratio() { var x1 = parseFloat(document.getElementById("x1").value); var y1 = parseFloat(document.getElementById("y1").value); if (isNaN(x1) || isNaN(y1) || x1 === 0 || y1 === 0) { alert("Please enter valid non-zero numbers for x1 and y1."); return; } var gcd = calc(x1, y1); var r1 = x1 / gcd; var r2 = y1 / gcd; var ratio = r1 + ":" + r2; document.getElementById("res").value = ratio; var x2 = parseFloat(document.getElementById("x2").value); var y2 = parseFloat(document.getElementById("y2").value); if (!isNaN(y2) && isNaN(x2)) { var res = y2 / r2; document.getElementById("x2").value = (r1 * res).toFixed(2); } else if (!isNaN(x2) && isNaN(y2)) { var res = x2 / r1; document.getElementById("y2").value = (r2 * res).toFixed(2); } } function calc(a, b) { while (b !== 0) { var t = b; b = a % b; a = t; } return a; } function reset() { document.getElementById("x1").value = ""; document.getElementById("y1").value = ""; document.getElementById("x2").value = ""; document.getElementById("y2").value = ""; document.getElementById("res").value = ""; }
// ]]>

Report this page