Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created July 12, 2012 07:31
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 roundrobin/3096463 to your computer and use it in GitHub Desktop.
Save roundrobin/3096463 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var r = 153
var draw = false
keypress = function(){
console.log('Hello',this,d3.event)
var keyChar = d3.event.keyCode
if(keyChar == '67'){
var radius = Math.random(2)*40;
console.log(radius)
g.append('rect').attr('r',radius)
.attr('width',Math.random(2)*20)
.attr('height',Math.random(2)*20)
.attr('x',Math.random(2)*800)
.attr('y',Math.random(2)*400)
}
if(keyChar == '68'){
var radius = Math.random(2)*40;
console.log(radius)
g.append('circle').attr('r',radius)
.attr('cx',Math.random(2)*900)
.attr('cy',Math.random(2)*400)
}
}
d3.select(window).on("keydown", keypress);
g.append('text').text('The Drawing Piano')
.attr('y',50).attr('x',500).attr('font-size',50)
g.append('text').text('Use your keyboard to paint your dreams')
.attr('y',91).attr('x',503).attr('font-size',23)
g.append('path')
.attr('d','M100,100')
.attr('stroke-width',11.56)
.attr('stroke','black')
.attr('fill','none')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment