Created
November 9, 2013 17:04
-
-
Save smikes/7387488 to your computer and use it in GitHub Desktop.
Draw an atom with label and gradient fill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<style> | |
body { | |
margin: 0px; | |
padding: 0px; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas id="myCanvas" width="200" height="200"></canvas> | |
<script> | |
var canvas = document.getElementById('myCanvas'); | |
var context = canvas.getContext('2d'); | |
context.arc(100, 100, 100, 0, Math.PI*2, true); | |
// create radial gradient | |
var grd = context.createRadialGradient(140, 50, 10, 140, 50, 300); | |
// light blue | |
grd.addColorStop(0, '#8ED6FF'); | |
// dark blue | |
grd.addColorStop(1, '#004CB3'); | |
context.fillStyle = grd; | |
context.fill(); | |
context.fillStyle='black'; | |
context.font='60pt Calibri'; | |
context.textAlign='center'; | |
context.textBaseline='middle'; | |
context.fillText('N', 100, 90); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
created by playing around with http://www.html5canvastutorials.com/tutorials/html5-canvas-radial-gradients/