Skip to content

Instantly share code, notes, and snippets.

@fernandojunior
Last active April 18, 2016 11:51
Show Gist options
  • Select an option

  • Save fernandojunior/6b909bf8240065aa8e1e520ae4836a79 to your computer and use it in GitHub Desktop.

Select an option

Save fernandojunior/6b909bf8240065aa8e1e520ae4836a79 to your computer and use it in GitHub Desktop.
Hello World
license: MIT
<!DOCTYPE>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<main>
<div class="container">
<div id="hello_world"></div>
</div>
</main>
<hr/>
<header>
<div class="container">
<h1>Hello World</h1>
</div>
</header>
<hr/>
<footer class="footer">
<div class="container"></div>
</footer>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="script.js"></script>
</body>
</html>
var randomInt = function(low, high) {
return Math.floor(Math.random() * (high - low + 1) + low);
}
var color = function(hue) {
return "hsl(" + hue + ", 100%, 50%)"
}
var helloWorld = function(msg) {
var random = randomInt(1, 360);
d3.select("#hello_world")
.style({color: color(random), "font-size": random})
.html(msg);
d3.select("footer .container")
.html(function () {
return "Random: " + random;
});
}
var loop = function(args) {
var duration = 1000/2;
var repeat = function() {
helloWorld.call(null, args);
setTimeout(repeat, duration);
};
repeat();
}
var msg = "Rebeca ♥";
// helloWorld(msg)
loop(msg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment