0

How do i use the built in line function

I know that the beginning of drawing the line after the canvas is set up should look like this ctx is my canvas context ctx.moveTo(0,0); ctx.lineTo(20,20); I know this should draw a line from point 0,0 to 20,20 but it didnt work for me i think it just sets up the line but doesnt draw it. Please tell me if im missing something.

15th May 2017, 9:47 PM
Cathal Poon
Cathal Poon - avatar
1 ответ
0
Is this all your code? Try to make a diagonal line like: var c = document.getElementById("canvasLine"); var ctx = c.getContext("2d"); ctx.moveTo(0,0); ctx.lineTo(20,10); ctx.stroke();
17th May 2017, 6:42 AM
Elias Papachristos
Elias Papachristos - avatar