0

Why can't I draw a line with this code? Rectangle was successful

<html> <head></head> <body> <canvas id="canvas1" width="1000" height="1000"> </canvas> <script> var canvas=document.getElementById("canvas1"); var ctx=canvas.getContext("2d"); ctx.fillStyle ="rgba(0, 200, 0, 1)"; ctx.fillRect (36, 10, 22, 22); var ctx = canvas.getContext("2d"); ctx.moveTo(50,50); ctx.lineTo(100,100); </script> </body> </html>

4th Nov 2017, 7:20 AM
Abdussamad Nasir
Abdussamad Nasir - avatar
1 Respuesta
+ 13
You forgot an 'ink' method? There's no way you can draw a line without any ink... i.e. add 'ctx.stroke()' at the end of your JS!
4th Nov 2017, 7:22 AM
Dev
Dev - avatar