How can a canvas be given color attribute | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How can a canvas be given color attribute

7th Jan 2018, 1:35 PM
toykam
toykam - avatar
6 Answers
+ 14
or ctx.strokeStyle=color in case you want to change line color
7th Jan 2018, 1:57 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 13
color or background color? For background color, do this in css: canvas{ background-color:red; }
7th Jan 2018, 1:43 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 13
ctx.fillStyle=color
7th Jan 2018, 1:52 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 3
You can draw a rectangle in the color you want. context.fillRect(0,0,canvas.width,canvas.height);
7th Jan 2018, 2:30 PM
Lil Taco
Lil Taco - avatar
+ 2
fill=color
7th Jan 2018, 1:43 PM
Max bax
Max bax - avatar
+ 2
please where should I insert the fill
7th Jan 2018, 1:48 PM
toykam
toykam - avatar