Created
July 12, 2012 21:02
-
-
Save roundrobin/3100975 to your computer and use it in GitHub Desktop.
just another inlet to tributary
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 r = 153 | |
var i = 0; | |
var draw = false | |
var element; | |
keyup = function(){element = undefined}; | |
keydown = function(){}; | |
keypress = function(){ | |
console.log('Hello',this,d3.event) | |
var keyChar = d3.event.keyCode | |
if(keyChar == 99){ | |
if(element){ | |
console.log(element) | |
if(i % 10 == 0) | |
element.attr('r',Math.random(2)*40) | |
element.attr('transform','translate('+[Math.random(2)*800,Math.random(2)*80]+')') | |
}else{ | |
element = g.append('circle') | |
g.append('circle').attr('r',Math.random(2)*40) | |
.attr('cx',Math.random(2)*900) | |
.attr('cy',Math.random(2)*400) | |
.attr('id','element') | |
} | |
} | |
i++; | |
} | |
d3.select(window).on("keypress", keypress); | |
d3.select(window).on("keyup", keyup); | |
d3.select(window).on("keydown", keydown); | |
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