0
Please someone tell me what's wrong with my code.
<script> var c = document.getElementById("siya"); var ctx = c.getContext("2d"); ctx.font = 30px italic; ctx.fillText("Hello World!" 10, 50); ctx.font = 30px italic; //Create gradient var gradient = createLinearGradient(0, 0, c.width, 0); gradient.addColorStop("0", "gray"); gradient.addColorStop("0", "blue"); gradient.addColorStop("0", "black"); //Fill with gradient ctx.fillStyle = gradient; ctx.fillText("Khumaloâ, 10, 50); </script>
5 Answers
+ 7
Italic is not a type of font, try Verdana or something.
ctx.font= "30px Helvetica ";
Please, always try to include code so we can see the error.
+ 3
There are more problems with the code.
ctx.font = 30px italic;
-> wrong font type and missing quotation mark
ctx.fillText("Hello World!" 10, 50);
-> a missing comma
gradient.addColorStop("0", "gray");
gradient.addColorStop("0", "blue");
gradient.addColorStop("0", "black");
-> wrong numbers, must be different
ctx.fillText("Khumalo", 10, 50);
-> wrong closing quotation mark (and the same position as above)
See here: https://code.sololearn.com/Wi3m5cAiDGVC/?ref=app
https://code.sololearn.com/WOFbIqIPAbuF/?ref=app
+ 2
one problem is that 30px italic should be between quotes.
+ 1
Thank you guys I really appreciate it
0
Thanks but still it is only displaying border not text