1 out of 1 rated this helpful - Rate this topic

fill method

[This documentation is preliminary and is subject to change.]

Fills subpaths by using the current fill style.

HTML Canvas 2D Context, Section 9Internet Explorer 9

Syntax

var retval = CanvasRenderingContext2D.fill();

Standards information

Parameters

This method has no parameters.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

The following code example uses the lineTo and closePath methods to create a shape and then fills the shape.


<!DOCTYPE html> <html>
<head>
    <title>Canvas fill example</title>
    <script>
    function fillDemo()
                  {
            var canvas = document.getElementById("demo")
			var ctx = canvas.getContext('2d');        
            ctx.beginPath();              
            ctx.lineWidth="3";
            ctx.strokeStyle="blue";  // This path is blue.
            ctx.fillStyle="red";    // The fill is red.
            ctx.moveTo(0,0);
            ctx.lineTo(150,150);
            ctx.lineTo(200,150);
            ctx.closePath();
            ctx.fill();            
            ctx.stroke();           // Draw it.                      
            }
  		</script>
</head>
    <body onload="fillDemo();">
	    <canvas id="demo" width="300" height="300"></canvas>
  </body>
</html> 

See also

CanvasRenderingContext2D

 

 

Build date: 2/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ