js canvas fill code example

Example 1: js canvas fill color

// canvas context.fillStyle = "Color"
ctx.fillStyle = "#FF0000";

Example 2: canvas fillrect

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(20, 20, 150, 100);

Example 3: javascript context color

context.fillStyle = "Green";
context.fillStyle = "#FF0000";

Example 4: javascript fill circle with color

context.beginPath();
      context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
      context.fillStyle = 'green';
      context.fill();
      context.lineWidth = 5;
      context.strokeStyle = '#003300';
      context.stroke()