Skip to content

Instantly share code, notes, and snippets.

@smikes
Created November 9, 2013 17:04
Show Gist options
  • Save smikes/7387488 to your computer and use it in GitHub Desktop.
Save smikes/7387488 to your computer and use it in GitHub Desktop.
Draw an atom with label and gradient fill
<!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>
@smikes
Copy link
Author

smikes commented Nov 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment