Canvas 給圖形繪製陰影
阿新 • • 發佈:2022-05-03
/** * 圖形繪製陰影 */ function initDemo6() { var canvas = document.getElementById("demo6"); if (!canvas) return; var context = canvas.getContext("2d"); context.fillStyle = "#02c9e5"; context.shadowOffsetX = 10; // 陰影橫向位移 context.shadowOffsetY = 10; // 陰影縱向位移 context.shadowColor = 'rgba(100, 100, 100, 0.5)'; // 陰影顏色 context.shadowBlur = 7.5; // 陰影模糊範圍 context.fillRect(25, 25, 300, 300); }