Skip to content

Instantly share code, notes, and snippets.

@lewis500
Last active July 7, 2019 03:41
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 lewis500/b3c3b25f03056e8bd9598b7fe423942e to your computer and use it in GitHub Desktop.
Save lewis500/b3c3b25f03056e8bd9598b7fe423942e to your computer and use it in GitHub Desktop.
lewislehe
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500)
var colorScale = d3.scaleSequential(d3.interpolateInferno)
.domain([0, 1])
d3.interval(()=>{
let circle = svg.append('circle')
.attr('cx', Math.random()*960)
.attr('cy', Math.random()*500)
.attr('r',0)
.attr('fill', colorScale(Math.random()))
circle
.transition()
.duration(1600)
.ease(Math.random() < .5 ? d3.easeBounceOut : d3.easeCubicOut)
.attr('r', Math.random()*20)
.attr('fill', colorScale(Math.random()))
d3.timeout(()=> {
circle.transition().ease(d3.easeCubic).attr('r',0).on('end',()=> circle.remove())
}, 1800)
},100)
svg.append("text")
.text("I'm Lewis Lehe!")
.attr("y", 200)
.attr("x", 120)
.attr("font-size", 36)
.attr("font-family", "monospace")
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment