Created
July 30, 2012 12:55
-
-
Save anonymous/3206702 to your computer and use it in GitHub Desktop.
created by livecoding - http://livecoding.gabrielflor.it
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
svg { | |
background: #000000; | |
} | |
path { | |
stroke: #FFFFFF; | |
} |
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
var width = $('svg').width(); | |
var height = $('svg').height(); | |
var svg = d3.select('svg'); | |
var g = svg.append('g'); | |
var branches = []; | |
var line; | |
var trunk; | |
var createLeftBranch; | |
svg | |
.attr('width', width) | |
.attr('height', height); | |
line = d3.svg.line() | |
.x(function(d) { return d.x; }) | |
.y(function(d) { return d.y; }) | |
.interpolate('basis'); | |
trunk = [ | |
{ 'x': width/2, 'y': height }, | |
{ 'x': width/2, 'y': height - 100 } | |
]; | |
branches.push(trunk); | |
createLeftBranch = function(parent) { | |
var angle_degrees = 10; | |
var branch = [ | |
{ 'x': parent[1].x, 'y': parent[1].y }, | |
{ 'x': 0, 'y': 10 } | |
]; | |
return branch; | |
}; | |
branches.push(createLeftBranch(trunk)); | |
g.selectAll('path') | |
.data(branches) | |
.enter().append('path') | |
.attr('d', line) | |
.style('stroke-width', 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment