Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/08/2013, 11:46
silviano
 
Fecha de Ingreso: agosto-2013
Ubicación: queretaro
Mensajes: 78
Antigüedad: 10 años, 8 meses
Puntos: 1
canvas pizarra para dibujar

Alguien que sepa de canvas, html5, si me podría decir por que no me corre el siguiente codigo, segun yo esta bien, se los muestro.

<html>
<head>
<title>Probando canvas</title>
<canvas id="pizarra" width="300px" height="200px"></canvas>

<script type="text/javascript">
<canvas id="pizarra" width="300px" height="200px"></canvas>
var pizarra_canvas
var pizarra_context
function init(){
if(!Modernizr.canvas){
document.getElementById("contenedor_pizarra").styl e.display = "none";
}else{
document.getElementById("no_html5").style.display = "none";
pizarra_canvas = document.getElementById("pizarra");
pizarra_context = pizarra_canvas.getContext("2d");
pizarra_context.strokeStyle = "#000";
pizarra_canvas.addEventListener("mousedown",empeza rPintar,false);
pizarra_canvas.addEventListener("mouseup",terminar Pintar,false);
}
}
function empezarPintar(e){
pizarra_context.beginPath();
pizarra_context.moveTo(e.clientX-pizarra_canvas.offsetLeft,e.clientY-pizarra_canvas.offsetTop);
pizarra_canvas.addEventListener("mousemove",pintar ,false)
}

function terminarPintar(e){
pizarra_canvas.removeEventListener("mousemove",pin tar,false);
}
function pintar(e) {
pizarra_context.lineTo(e.clientX-pizarra_canvas.offsetLeft,e.clientY-pizarra_canvas.offsetTop);
pizarra_context.stroke();
}
function borrar(){
pizarra_canvas.width = pizarra_canvas.width;
}
</script>
</head>

<body>

<canvas id="pizarra" width="300px" height="200px"></canvas>

</body>
</html>