programming-examples/html/_Basics/Filling radial gradient inside canvas shapes.html
2019-11-15 12:59:38 +01:00

28 lines
847 B
HTML

<!DOCTYPE html>
<html subLang="en">
<head>
<meta charset="UTF-8">
<title>Example of Filling Radial Gradient inside Canvas Shapes</title>
<style type="text/css">
canvas{
border: 1px solid #000;
}
</style>
<script type="text/javascript">
window.onload = function(){
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
context.arc(150, 100, 70, 0, 2 * Math.PI, false);
var grd = context.createRadialGradient(150, 100, 10, 160, 110, 100);
grd.addColorStop(0, '#8ED6FF');
grd.addColorStop(1, '#004CB3');
context.fillStyle = grd;
context.fill();
context.stroke();
};
</script>
</head>
<body>
<canvas id="myCanvas" width="300" height="200"></canvas>
</body>
</html>