• 欢迎来到本站,本站主要做程序员相关技术、博客、笔记,如果喜欢本网站那么赶紧使用Ctrl+D 收藏吧!
  • 如果有任何疑问,可以在下方文章下方留下你的评论~

Example of using html canvas shadowColor property

生活日常 8个月前 (10-17) 1次浏览 0个评论

Browser support

Internet Explorer 9, Firefox, opera, chrome, and safari support the shadowColor property.

Note: the <canvas> element is not supported in Internet Explorer 8 and earlier.

Definition and Usage

The shadowcolor property sets or returns the color used for shadows.

Note: use the shadowcolor property with the shadowblur property to create shadows.

Tip: adjust the shadow effect by using the shadowoffsetx and shadowOffsetY properties.

JavaScript syntax: context.shadowColor=color;

Example

Draw a red rectangle with a black shadow:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>China Pen Pal</title>
</head>
<body>

<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
Hello World!
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.shadowBlur=20;
ctx.fillStyle="red";
ctx.shadowColor="black";
ctx.fillRect(20,20,100,80);
ctx.shadowColor="blue";
ctx.fillRect(140,20,100,80);
</script>

</body>
</html>

Example of using html canvas shadowColor property


中国笔友, 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Example of using html canvas shadowColor property
喜欢 (0)
发表我的评论
取消评论
表情 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址