+ 2

Canvas drawing syntax doesn't support Sololearn in js section.

Canvas drawing syntax doesn't support Sololearn in js section. Why?

16th Dec 2017, 2:46 PM
Satish Kumar Sharma
Satish Kumar Sharma - avatar
4 odpowiedzi
+ 7
can you show your code
16th Dec 2017, 3:05 PM
Amethyst Animion
Amethyst Animion - avatar
+ 6
corrected code window.onload = function(){ var cnvs = document.getElementById("can"); var c = cnvs.getContext("2d"); // you must write it inside a function function draw() { c.moveTo(20, 20); c.lineTo(200, 20); c.stroke(); } draw(); // you must call the function to make it work } hope this help
16th Dec 2017, 3:36 PM
Amethyst Animion
Amethyst Animion - avatar
+ 4
var cnvs = document.getElementById("can"); var c = cnvs.getContext("2d"); c.moveTo(20, 20); c.lineTo(200, 20); c.stroke();
16th Dec 2017, 3:09 PM
Satish Kumar Sharma
Satish Kumar Sharma - avatar
+ 4
Use window.onload =function () {/*your code*/}
14th Aug 2019, 12:31 PM
Nerderkips
Nerderkips - avatar