Skip to content

Instantly share code, notes, and snippets.

@enjalot
Last active February 23, 2016 18:36
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 enjalot/21dd49a90c55348484f3 to your computer and use it in GitHub Desktop.
Save enjalot/21dd49a90c55348484f3 to your computer and use it in GitHub Desktop.
dance
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg { width:100%; height: 100% }
text {
font-size: 150;
font-family: "Courier"
}
</style>
</head>
<body>
<script>
var dance = [
"d<",
"d=",
"d<",
"dc",
"d<",
"d=",
"q<",
"d<",
"q<",
"q=",
"q<",
"qc",
"q<",
"q="
]
var svg = d3.select("body").append("svg")
var g = svg.append("g")
.attr({
transform: "translate(407,155)rotate(90)"
})
var dancer = g.append("text")
.text("d<")
var frameTime = 400;
function dancedance() {
dance.forEach(function(d,i) {
setTimeout(function() {
dancer.text(d)
if(i == dance.length-1) dancedance();
}, (i+1) * frameTime)
})
}
dancedance();
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment