Built with blockbuilder.org
| <!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% } | |
| </style> | |
| </head> | |
| <body> | |
| <script> | |
| var width = 800, height = 500; | |
| var stripWidth = 20, stripCount = 0; | |
| var radius = 30, moveCount = 0, index = 0; | |
| var factor = 0, factors = [1.0, 0.5]; | |
| var circleColors = ["#467864", "#C45F4B", "#86C4AC", "#5FC49C", "#784E46"]; | |
| var svg = d3.select("body") | |
| .append("svg") | |
| .attr("width", width) | |
| .attr("height", height); | |
| svg.on("mousemove", function() { | |
| index = (++moveCount) % circleColors.length; | |
| stripCount = Math.floor(moveCount/stripWidth); | |
| factor = factors[stripCount%2]; | |
| var circle = svg.append("circle") | |
| .attr("cx", d3.event.pageX) | |
| .attr("cy", d3.event.pageY) | |
| .attr("r", radius*factor); | |
| circle.attr("fill", circleColors[index]); | |
| }) | |
| </script> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment