fill canvas with color code example

Example 1: js canvas fill color

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

Example 2: javascript context color

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

Example 3: canvas set background color

var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, canvas.width, canvas.height);

Example 4: fill and no repeat background image css

/* with CSS 3 */
#yourdiv {  
    background: url('bgimage.jpg') no-repeat;
    background-size: 100%;
}

Example 5: 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()

Tags:

Css Example