HTML5 Game - An arc stroke gradient

Description

An arc stroke gradient

Demo

ResultView the demo in separate window

<!DOCTYPE html>  
<html> 
<head> 
<style> 
#canvas { // w w  w . ja va2s.  c  o m
  border:1px solid #03F; 
  background:#CFC; 
} 
</style> 
</head> 
<body> 
<canvas id="canvas" width="640" height="480"></canvas> 
<script> 
  let context = document.getElementById('canvas').getContext('2d'); 
          let gr = context.createRadialGradient(50,50,25,100,100,100); 

      // Add the color stops. 
      gr.addColorStop(0,'rgb(255,0,0)'); 
      gr.addColorStop(.5,'rgb(0,255,0)'); 
      gr.addColorStop(1,'rgb(255,0,0)'); 

      // Use the gradient for the fillStyle. 
      context.strokeStyle = gr; 
      context.arc(100, 100, 50, (Math.PI/180)*0, (Math.PI/180)*360, false) 
      context.stroke(); 


</script> 



</body> 
</html>

Related Topic