canvas problems | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

canvas problems

So, I was online looking at how to make a canvas fit the page and i managed to gather enough knowledge to make one but obviously not without a flaw. I set the canvas to the colour red but it didn't work and displayed the colour black. Please help. Here is the code: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <style>body>{margin:0:}</style> <canvas id='ltpcanvas'></canvas> <script> window.onload = function(){ init(); window.addEventListener('resize', init,false); } function init(){ var ltpc = document.getElementById('ltpcanvas'); var context = ltpc.getContext('2d'); var myWidth = window.innerWidth -30; var myHeight = window.innerHeight -30; context.canvas.width = myWidth; context.canvas.height = myHeight; context.filStyle = "#FF0000"; context.fillRect(0,0,myWidth,myHeight); } </script> </body> </html>

27th Nov 2017, 8:59 PM
Zakariya
Zakariya - avatar
4 Answers
+ 4
filStyle -> fillStyle (two l's)
27th Nov 2017, 9:40 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
It happens :) This is a good example why pair programming works so well (another pair of eyes).
27th Nov 2017, 10:08 PM
Kirk Schafer
Kirk Schafer - avatar
0
Yeah. Thanks anyway
27th Nov 2017, 10:24 PM
Zakariya
Zakariya - avatar
- 1
oh. sorry about that
27th Nov 2017, 9:49 PM
Zakariya
Zakariya - avatar