+ 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>
3 Answers
+ 6
Change ctx.fillText = () to ctx.fillText(), and the same with ctx.strokeText().
Everything else should be correct
+ 4
hmm strange,ill suggest you post the code so I can see it!
+ 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>