คุณสมบัติ shadowBlur ของแคนวาส HTML ใช้เพื่อกำหนดระดับการเบลอสำหรับเงา ค่าเริ่มต้นคือ 0 องค์ประกอบ
ต่อไปนี้เป็นไวยากรณ์ -
ctx.shadowBlur=num;
ด้านบน num แสดงถึงระดับความเบลอของเงา
ให้เรามาดูตัวอย่างการใช้คุณสมบัติ shadowBlur ของ canvas -
ตัวอย่าง
<!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> ผลลัพธ์
