source: Dev/trunk/d3/examples/moire/moire.html @ 76

Last change on this file since 76 was 76, checked in by fpvanagthoven, 14 years ago

d3

File size: 1.2 KB
Line 
1<!DOCTYPE html>
2<html>
3  <head>
4    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
5    <title>Moiré Patterns</title>
6    <script type="text/javascript" src="../../d3.js"></script>
7    <style type="text/css">
8
9circle {
10  fill: none;
11  stroke: #000;
12}
13
14    </style>
15  </head>
16  <body>
17    <script type="text/javascript">
18
19var w = 960,
20    h = 500;
21
22var svg = d3.select("body")
23  .append("svg:svg")
24    .attr("width", w)
25    .attr("height", h)
26    .attr("pointer-events", "all");
27
28svg.append("svg:g")
29  .selectAll("circle")
30    .data(d3.range(110))
31  .enter().append("svg:circle")
32    .attr("transform", "translate(" + w / 2 + "," + h / 2 + ")")
33    .attr("r", function(d) { return d * 5; });
34
35var circle = svg.append("svg:g")
36  .selectAll("circle")
37    .data(d3.range(60))
38  .enter().append("svg:circle")
39    .attr("transform", "translate(" + w / 2 + "," + h / 2 + ")")
40    .attr("r", function(d) { return d * 3; });
41
42svg.on("mousemove", function() {
43  var mouse = d3.svg.mouse(this),
44      r = (Math.sqrt(mouse[0]) + 10) / 10;
45
46  circle
47      .attr("transform", "translate(" + mouse + ")")
48      .attr("r", function(d) { return d * r; });
49});
50
51    </script>
52  </body>
53</html>
Note: See TracBrowser for help on using the repository browser.