Created
August 21, 2012 03:53
-
-
Save gabrielflorit/3411372 to your computer and use it in GitHub Desktop.
circle and ball
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"> | |
<title>livecoding</title> | |
<link rel="stylesheet" href="http://livecoding.io/static/css/iframe.css"> | |
<style> | |
</style> | |
</head> | |
<body> | |
<h1>Hello! This is a graphic! Try:</h1> | |
<ul> | |
<li>placing the circle inside the square</li> | |
<li>making the circle touch the square</li> | |
</ul> | |
<svg></svg> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script>window.jQuery || document.write('<script src="http://livecoding.io/static/js/libs/jquery-1.7.1.min.js"><\/script>')</script> | |
<script src="http://livecoding.io/static/js/libs/d3.v2.min.js"></script> | |
<script> | |
$(function() { | |
var width = $('svg').width(); | |
var height = $('svg').height(); | |
var svg = d3.select('svg'); | |
svg | |
.attr('width', width) | |
.attr('height', height); | |
svg.selectAll('circle') | |
.data([18]) | |
.enter().append('circle') | |
.attr('cy', 236) | |
.attr('cx', String) | |
.attr('r', Math.sqrt); | |
svg.selectAll('rect') | |
.data([200]) | |
.enter().append('rect') | |
.attr('x', String) | |
.attr('y', String) | |
.attr('width', String) | |
.attr('height', String) | |
.style('fill', 'none') | |
.style('stroke', '#000000'); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment