HTML 画布 shadowBlur 属性
htmlweb developmentfront end technology更新于 2026/2/3 5:32:17
HTML 画布的 shadowBlur 属性用于设置阴影的模糊级别。默认值为 0。<canvas> 元素允许您使用 JavaScript 在网页上绘制图形。每个画布都有两个元素,分别描述画布的高度和宽度。
以下是语法 −
ctx.shadowBlur=num;
上面的 num 表示阴影的模糊级别。
现在让我们看一个实现画布 shadowBlur 属性的示例 −
示例
<!DOCTYPE html>
<html>
<body>
<canvas id="newCanvas" width="600" height="350" style="border:2px solid orange;">
</canvas>
<script>
var c = document.getElementById("newCanvas");
var ctx = c.getContext("2d");
ctx.shadowBlur = 20;
ctx.shadowColor = "black";
ctx.fillStyle = "green";
ctx.fillRect(40, 40, 100, 250);
ctx.shadowBlur = 30;
ctx.shadowColor = "blue";
ctx.fillStyle = "orange";
ctx.fillRect(200, 40, 200, 150);
</script>
</body>
</html>
输出

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

