circle wave js

Solutions on MaxInterview for circle wave js by the best coders in the world

showing results for - "circle wave js"
Lennart
06 Feb 2018
1<!DOCTYPE html>
2<svg width="960" height="500"> Test </svg>
3<script src="https://d3js.org/d3.v4.min.js"></script>
4<script>
5
6var svg = d3.select("svg"),
7    width = +svg.attr("width"),
8    height = +svg.attr("height"),
9    angles = d3.range(0, 2 * Math.PI, Math.PI / 200);
10
11var path = svg.append("g")
12    .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")")
13    .attr("fill", "none")
14    .attr("stroke-width", 10)
15    .attr("stroke-linejoin", "round")
16  .selectAll("path")
17  .data(["cyan", "magenta", "yellow"])
18  .enter().append("path")
19    .attr("stroke", function(d) { return d; })
20    .style("mix-blend-mode", "darken")
21    .datum(function(d, i) {
22      return d3.radialLine()
23          .curve(d3.curveLinearClosed)
24          .angle(function(a) { return a; })
25          .radius(function(a) {
26            var t = d3.now() / 1000;
27            return 200 + Math.cos(a * 8 - i * 2 * Math.PI / 3 + t) * Math.pow((1 + Math.cos(a - t)) / 2, 3) * 32;
28          });
29    });
30
31d3.timer(function() {
32  path.attr("d", function(d) {
33    return d(angles);
34  });
35});
36
37</script>
38
Neele
27 Nov 2016
1<!DOCTYPE html>
2<svg width="960" height="500"></svg>
3<script src="https://d3js.org/d3.v4.min.js"></script>
4<script>
5
6var svg = d3.select("svg"),
7    width = +svg.attr("width"),
8    height = +svg.attr("height"),
9    angles = d3.range(0, 2 * Math.PI, Math.PI / 200);
10
11var path = svg.append("g")
12    .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")")
13    .attr("fill", "none")
14    .attr("stroke-width", 10)
15    .attr("stroke-linejoin", "round")
16  .selectAll("path")
17  .data(["cyan", "magenta", "yellow"])
18  .enter().append("path")
19    .attr("stroke", function(d) { return d; })
20    .style("mix-blend-mode", "darken")
21    .datum(function(d, i) {
22      return d3.radialLine()
23          .curve(d3.curveLinearClosed)
24          .angle(function(a) { return a; })
25          .radius(function(a) {
26            var t = d3.now() / 1000;
27            return 200 + Math.cos(a * 8 - i * 2 * Math.PI / 3 + t) * Math.pow((1 + Math.cos(a - t)) / 2, 3) * 32;
28          });
29    });
30
31d3.timer(function() {
32  path.attr("d", function(d) {
33    return d(angles);
34  });
35});
36
37</script>
38