Skip to content

Instantly share code, notes, and snippets.

@romsson
Created November 8, 2018 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romsson/a04b27560605488cef80ab1c83901521 to your computer and use it in GitHub Desktop.
Save romsson/a04b27560605488cef80ab1c83901521 to your computer and use it in GitHub Desktop.
Venn diagram canvas
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var width = 800,
height = 600;
var canvas = d3.select('body')
.append('canvas')
.attr('width', width)
.attr('height', height);
var context = canvas.node().getContext('2d');
var r = 100;
context.clearRect(0, 0, width, height);
context.globalAlpha = 0.5
context.fillStyle = 'red';
context.beginPath();
context.arc(150, 150, r, 0, 2*Math.PI);
context.fill();
context.fillStyle = 'green';
context.beginPath();
context.arc(250, 150, r, 0, 2*Math.PI);
context.fill();
context.fillStyle = 'blue';
context.beginPath();
context.arc(200, 250, r, 0, 2*Math.PI);
context.fill();
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment