Drop Shadows in Canvas
<!DOCTYPE html> <html> <head> <title>Canvas Demo</title> <style> canvas { /*from w w w . j av a 2s . c o m*/ border: 1px solid #000; } </style> </head> <body> <canvas id="myCanvas" width="200" height="200">Did You Know: Every time you use a browser that doesn't support HTML5 </canvas> <script> // Get the context we will be using for drawing. let myCanvas = document.getElementById('myCanvas'); let myContext = myCanvas.getContext('2d'); // Define a shadow. myContext.shadowBlur = 2; myContext.shadowColor = 'rgba(0, 100, 0, 0.5)'; myContext.shadowOffsetX = 5; myContext.shadowOffsetY = 5; myContext.font = '35px sans-serif'; myContext.strokeStyle = '#000'; myContext.lineWidth = 2; myContext.textAlign = 'center'; myContext.strokeText('Hello World', 100, 100); </script> </body> </html>