Created
July 10, 2012 00:17
-
-
Save jacksonhenry3/3080018 to your computer and use it in GitHub Desktop.
a present for you ;D
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> | |
<html> | |
<head> | |
<title>birthday present</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.5.0"></script> | |
</head> | |
<body> | |
move your mouse over the text<br> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
<script type="text/javascript"> | |
var data = ['p', 'a','b',' ','r','h','t','i','d','y','a','y', 'h', 'p']; | |
d3.selectAll("span") | |
.data(data) | |
.append("svg") | |
.attr("width", 50) | |
.attr("height", 90) | |
.append("text") | |
.attr("x", "50%") | |
.attr("y", "50%") | |
.attr("dy", ".35em") | |
.attr("text-anchor", "middle") | |
.attr("fill", "white") | |
.attr("stroke", "black") | |
.attr("stroke-width", 1.) | |
.style("font", "60pt Ubuntu") | |
.style("text-shadow", "3px 3px 3px rgba(0,0,0,.1)") | |
.text(function(d) { return d; }); | |
a = 0 | |
alphabet = ['h','a','p','p','y',' ','b','i','r','t','h','d','a','y'] | |
function refresh() { | |
for (var i = 0; i < data.length; i++) { | |
randomIndex = Math.floor(Math.random() * alphabet.length); | |
randomChr = alphabet[randomIndex]; | |
data[i] = randomChr; | |
} | |
if (a>=1000){data[0] = "H"} | |
if (a>=1200){data[1] = "a"} | |
if (a>=1400){data[2] = "p"} | |
if (a>=1600){data[3] = "p"} | |
if (a>=1800){data[4] = "y"} | |
if (a>=2000){data[5] = " "} | |
if (a>=2200){data[6] = "b"} | |
if (a>=2400){data[7] = "i"} | |
if (a>=2600){data[8] = "r"} | |
if (a>=2800){data[9] = "t"} | |
if (a>=3000){data[10] = "h"} | |
if (a>=3400){data[11] = "d"} | |
if (a>=3600){data[12] = "a"} | |
if (a>=3800){data[13] = "y"} | |
d3.selectAll("text") | |
.data(data) | |
.text(function(d) { return d; }); | |
a+=7 | |
} | |
window.addEventListener("mousedown", refresh, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment