Built with blockbuilder.org
Created
November 8, 2018 12:00
-
-
Save romsson/a04b27560605488cef80ab1c83901521 to your computer and use it in GitHub Desktop.
Venn diagram canvas
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
license: mit |
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> | |
<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