+ 2

Html canvas not not working

I'm trying to create a meme generator. But thus isn't working for me. <canvas id = "c" width = "500" height="200"></canvas> <script> var c = document.querySelector("#c"); var ctx = c.getContext("2d"); ctx.font = "36pt Impact"; ctx.fillStyle = "white"; ctx.fillText = ("Hello",c.width/2,40); ctx.strokeStyle ="black"; ctx.lineWidth =3; ctx.strokeText = ("Hello",c.width/2,40); </script>

11th Nov 2017, 1:42 PM
Pearlly
Pearlly - avatar
3 Respostas
+ 6
Change ctx.fillText = () to ctx.fillText(), and the same with ctx.strokeText(). Everything else should be correct
11th Nov 2017, 2:22 PM
The Coding Sloth
The Coding Sloth - avatar
+ 4
hmm strange,ill suggest you post the code so I can see it!
11th Nov 2017, 1:54 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 4
<canvas id = "cv" width = "500" height="200"> </canvas> <script> var c = document.getElementById("cv"); var ctx = c.getContext("2d"); ctx.font = "36pt Impact"; ctx.fillStyle = "blue"; ctx.fillText("Hello",40,40); ctx.strokeStyle ="black"; ctx.lineWidth =3; ctx.strokeText("Hello",40,40); </script>
11th Nov 2017, 3:24 PM
Sachin Artani
Sachin Artani - avatar