คุณสมบัติ shadowColor ของแคนวาส HTML ใช้เพื่อกำหนดสีให้กับเงา ค่าเริ่มต้นคือ #000000
ต่อไปนี้เป็นไวยากรณ์ -
ctx.shadowColor=color;
ด้านบน กำหนดสีของเงา
ให้เราดูตัวอย่างการใช้คุณสมบัติ shadowColor ของผ้าใบ -
ตัวอย่าง
<!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 = "gray";
ctx.fillStyle = "blue";
ctx.fillRect(40, 40, 200, 250);
</script>
</body>
</html> ผลลัพธ์
