Code
Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy HTML Canvas createRadialGradient() with example</title> </head> <body> <h1>Wikitechy HTML Canvas createRadialGradient() with example</h1> <canvas id="wikitechyCanvas" width="350" height="170" style="border:1px solid #d3d3d3;"> </canvas> <script> var x = document.getElementById("wikitechyCanvas"); var y = x.getContext("2d"); var crg = y.createRadialGradient(80, 60, 8, 100, 70, 75); crg.addColorStop(0, "red"); crg.addColorStop(1, "blue"); y.fillStyle = crg; y.fillRect(20, 20, 150, 120); </script> </body> </html>
Result