elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


  Mostrar Temas
Páginas: [1]
1  Programación / Desarrollo Web / javascript/canvas|| hacer un triangulo y darle la medida de los catetos en: 21 Junio 2016, 22:11 pm
hola necesito ayuda en este codigo lo que pasa es que quiero que se pueda hacer el triangulo pero hay un error si pones 50 y 0 se hace un triangulo y no debe ser asi debe ser una linea y no se  como resolver eso bn GRACIAS.
<html>
<head>
<title>Script para triángulos</title>
</head>

<body>
<form name="calc">
<input type="text" name="n1" value="50">
<input type="text" name="n2">
<input type="button" value="calcular"  onclick="calcular()">
<canvas id='canvas1' width="600" height="250" style= "border: 1px solid #CCF" >Tu navegador no soporta htmal5</canvas>
</form>
<script type= "text/javascript">
function calcular(){
var n1 =document.calc.n1.value;
var n2 =document.calc.n2.value;
var c=document.getElementById ('canvas1');
var r= c.getContext ('2d');
r.beginPath();
r.moveTo(n2,10);
r.lineTo(10,10);
r.lineTo(10,n1);
r.closePath();
r.stroke();
}
</script>
</body>
</html>
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines