Answer the question
In order to leave comments, you need to log in
Canvas. Is it right to do this and is it possible to continue drawing figures in this form?
Hello. Is it correct to "draw" lines using the following code?:
var
canv = document.getElementById('canvas'),
ctx = canv.getContext('2d');
canv.width = window.innerWidth;
canv.height = window.innerHeight;
ctx.strokeStyle = 'red';
ctx.lineWidth = 5;
ctx.beginPath();
ctx.moveTo(50,50);
ctx.lineTo(25,100);
ctx.lineTo(75,100);
ctx.lineTo(50,50);
ctx.stroke();
ctx.strokeStyle = 'red';
ctx.lineWidth = 5;
ctx.beginPath();
ctx.moveTo(150,150);
ctx.lineTo(125,200);
ctx.lineTo(175,200);
ctx.closePath();
ctx.stroke();
Answer the question
In order to leave comments, you need to log in
Yes, this code loads the page like any other code =)
Well, by drawing lines, you are unlikely to be able to load the page so that it is noticeable at least somehow. And there is no easier way. On pure js, this is the only way, perhaps there are libraries that make it easier to write code.
Tyk
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question