shadowColor property

Gets or sets the color to use for shadows.

This property is read/write.

HTML Canvas 2D Context, Section 7Internet Explorer 9

Syntax

JavaScript

object.shadowColor = color

color = object.shadowColor

Property values

Type: string

The CSS color.

Standards information

Remarks

Any values of the p parameter that are not CSS colors are ignored.

Examples

The following code example draws a series of squares that have different colors for shadowColor.


<html>
<head>
  <script type="text/javascript">
      function draw() {
          var canvas = document.getElementById("MyCanvas");
          if (canvas.getContext) {
              var ctx = canvas.getContext("2d");
              // Define the shadow parameters.
              ctx.shadowColor = "black";
              ctx.shadowBlur = "5";
              ctx.shadowOffsetX = "5";
              ctx.shadowOffsetY = "5";
              ctx.strokeRect(25, 25, 200, 200);
              ctx.shadowColor = "red";
              ctx.strokeRect(75, 75, 200, 200);
              ctx.shadowColor = "green";
              ctx.strokeRect(125, 125, 200, 200);
              ctx.shadowColor = "blue";
              ctx.strokeRect(175, 175, 200, 200);
              ctx.shadowColor = "purple";
              ctx.strokeRect(225, 225, 200, 200);
          }
      }
  </script>
</head>
<body onload="draw();">
  <canvas id="MyCanvas" width="600" height="500">This browser or document mode doesn't support canvas</canvas> 
</body>
</html>


See also

CanvasRenderingContext2D

 

 

Show:
© 2014 Microsoft