Code
Execute
<!DOCTYPE html> <html> <head> <title>wikitechy addcolorstop method</title> </head> <body> <h1>wikitechy addcolorstop method</h1> <canvas id="wikitechyCanvas" width="300" height="150" style="border:1px solid #d3d3d3;"> </canvas> <script> var c = document.getElementById("wikitechyCanvas"); var context= c.getContext("2d"); var gradient= context.createLinearGradient(10,10,150,10); gradient.addColorStop(0, "red"); gradient.addColorStop(1, "pink"); context.fillStyle = gradient; context.fillRect(30, 20, 180, 100); </script> </body> </html>
Result