Created
September 12, 2024 08:32
-
-
Save tompng/acc69dc24428e0be419dc25e2cfccee3 to your computer and use it in GitHub Desktop.
stickynote shadow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas> | |
<script> | |
ctx = document.querySelector('canvas').getContext('2d') | |
ctx.clearRect(0, 0, 1000, 1000) | |
const blur = 12 | |
ctx.shadowBlur = blur | |
ctx.shadowColor = 'black' | |
ctx.shadowOffsetX = blur | |
ctx.shadowOffsetY = blur | |
const x = 20 | |
const y = 20 | |
const w = 150 | |
const h = 100 | |
const a = 0 | |
ctx.globalAlpha = 0.5 | |
ctx.fillStyle = 'black' | |
ctx.beginPath() | |
ctx.moveTo(x, y) | |
ctx.lineTo(x + w - blur, y) | |
ctx.lineTo(x + w + h * a, y + h + h * a) | |
ctx.lineTo(x, y + h + h * a) | |
ctx.fill() | |
ctx.filter = 'none' | |
ctx.fillStyle = 'silver' | |
ctx.globalAlpha = 1 | |
ctx.shadowColor = 'transparent' | |
ctx.strokeStyle = 'red' | |
ctx.beginPath() | |
ctx.strokeStyle = 'red' | |
ctx.strokeRect(x,y,w,h) | |
ctx.globalAlpha = 1 | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment