Created
April 28, 2016 22:46
-
-
Save zanarmstrong/b5175f84352b31cc9f9297e5a28dac3b to your computer and use it in GitHub Desktop.
forked from jsfire.io/animations
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> | |
<meta charset="utf-8"> | |
<title>2015-04-06</title> | |
<body> | |
<script src="/animations/d3.v3.min.js"></script> | |
<style> | |
html, body { | |
height: 100%; | |
background: #222; | |
margin: 0; | |
} | |
body, #prev, #next { | |
height: 100%; | |
box-sizing: border-box; | |
display: flex; | |
flex-direction: column; | |
justify-content: center; | |
display: -webkit-flex; | |
-webkit-flex-direction: column; | |
-webkit-justify-content: center; | |
} | |
#prev, #next { | |
position: absolute; | |
top: 0; | |
color: #d1d1d1; | |
font-size: 70px; | |
text-decoration: none; | |
padding: 20px; | |
} | |
#prev { | |
left: 0; | |
} | |
#next { | |
right: 0; | |
} | |
svg { | |
margin: auto; | |
} | |
@font-face { | |
font-family: 'FontAwesome'; | |
src: url('/animations/fonts/fontawesome-webfont.eot?v=4.2.0'); | |
src: url('/animations/fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype'), url('/animations/fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'), url('/animations/fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'), url('/animations/fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg'); | |
font-weight: normal; | |
font-style: normal; | |
} | |
.fa { | |
display: inline-block; | |
font: normal normal normal 14px/1 FontAwesome; | |
font-size: inherit; | |
text-rendering: auto; | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
} | |
.fa-twitter:before { | |
content: "\f099"; | |
} | |
.fa-github:before { | |
content: "\f09b"; | |
} | |
.fa-th:before { | |
content: "\f00a"; | |
} | |
footer { | |
text-align: center; | |
margin-bottom: 25px; | |
} | |
a { | |
color: #d1d1d1; | |
text-decoration: none; | |
padding: 10px; | |
} | |
</style> | |
<a id="prev" href="/animations/2015-04-03/">‹</a> | |
<script> | |
var width = 500, | |
height = 500, | |
n = 20, | |
m = 20, | |
r = 3, | |
dr = 20, | |
g = 137.5 * Math.PI / 180; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height) | |
.style("background", "#d1d1d1") | |
.append("g"); | |
var data = []; | |
for (var r = 1; r <= n; r++) { | |
for (var ø = 0; ø < Math.PI * 2; ø += 2 * Math.PI / m) { | |
data.push({r: r, ø: ø}); | |
} | |
} | |
var seeds = svg.selectAll("circle") | |
.data(data) | |
.enter().append("circle") | |
.attr("cx", function(d) { return d.r * d.r * Math.cos(d.ø + g * d.r); }) | |
.attr("cy", function(d) { return d.r * d.r * Math.sin(d.ø + g * d.r); }) | |
.attr("fill", "#000") | |
.attr("fill-opacity", 0.3); | |
d3.timer(function(t) { | |
seeds.attr("r", function(d, i) { return 0.12 * (Math.sin(i * t / 50000) + 1) * Math.pow(d.r, 1.9); }); | |
svg.attr("transform", "translate(" + [width / 2, height / 2] + ")rotate(" + t / 100 % 360 + ")"); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment