<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
var circlecenterX = canvas.width / 2; // x coordinate
var circlecenterY = canvas.height / 2; // y coordinate
// radius of the tracing circle
var radius = 100;
// Math.PI is HALF the circle, 2*Math.PI is the full circle
// use a number between 0 and 2 to declare the starting and ending angle
var startAngle = 1.1 * Math.PI;
var endAngle = 1.9 * Math.PI;
// draw the arc clockwise or counterclockwise
var counterClockwise = false; // if set to true it draws the complimentary arc
// draw the arc
context.arc(circlecenterX, circlecenterY, radius, startAngle, endAngle, counterClockwise);
var circlecenterX = canvas.width / 2; // x coordinate
var circlecenterY = canvas.height / 2; // y coordinate
// radius of the circle
var radius = 100;
// Math.PI is HALF the circle, 2*Math.PI is the full circle
// use a number between 0 and 2 to declare the starting and ending angle
var startAngle = 0; // start at the angle 0
var endAngle = 2 * Math.PI; // end at the full angle
// draw the arc clockwise or counterclockwise
var counterClockwise = false; // in this case it doesn't really matter unless you are drawing half a circle
// draw the arc
context.arc(circlecenterX, circlecenterY, radius, startAngle, endAngle, counterClockwise);
// create radial gradient
var grd = context.createRadialGradient(circ1X, circ1Y, circ1Radius, circ2X, circ2Y, circ2Radius);
// inner color
grd.addColorStop(0, "rgb(255,0,0)");
// you can add intermediate colors using N greater than 0 and smaller then 1
var N = 0.5;
grd.addColorStop(N, "rgb(0,0,255)");
// outer color
grd.addColorStop(1, "rgb(0,255,0)");
context.fillStyle = grd;
context.fill();