-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircles.html
77 lines (64 loc) · 2.34 KB
/
circles.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.2.1/d3.min.js"></script>
<script type="text/javascript" src="underscore.js"></script>
<style type="text/css">
body { background: #666; }
</style>
</head>
<body>
<script type="text/javascript">
var colors = ["132537", "006C80", "EBCAB8", "FE8315", "FA3113"];
var w = 1260,
h = 800,
circle_r = 100
step = Math.sqrt(Math.pow(circle_r, 1.70) - Math.pow((circle_r / 3.0), 1.0));
var svg = d3.select("body")
.append("svg:svg")
.attr("width", w)
.attr("height", h)
drawCircles();
function drawCircles() {
var ox = -120;
var oy = -120;
var circ = circle_r * 2;
for(var x = ox; x < w; x += 0.5*step) {
for(y = oy; y < h; y += (circle_r * 4)) {
drawCircle(x, y);
// drawLine(x, y - circle_r, x, y + circle_r); // vertical
// drawLine(x - circle_r, y, x + circle_r, y); // horiz
// drawLine(x, y, x + circle_r, y + circle_r); // top l, bottom r
// drawLine(x, y, x - circle_r, y + circle_r); // top r, bottom l
// drawLine(x - circle_r, y - circle_r, x + circle_r, y + circ);
// drawLine(x - circ, y - circ, x, y + circ);
}
oy -= circle_r;
}
}
function drawCircle(x, y) {
svg.append("svg:circle")
// .attr("fill", '#'+(Math.floor(Math.random()*16777215) + 8000).toString(16))
.attr("fill", '#'+colors[Math.floor(Math.random()*colors.length)])
.attr("opacity", Math.random() + 0.0)
.attr("stroke", "#ccc")
.attr("stroke-opacity", 0.5)
.attr("cx", x)
.attr("cy", y)
.attr("r", circle_r)
}
function drawLine(start_x, start_y, end_x, end_y) {
svg.append("svg:line")
.attr("stroke", '#fff')
.attr("x1", start_x)
.attr("y1", start_y)
.attr("x2", end_x)
.attr("y2", end_y)
.attr("opacity", Math.random() - 0.15)
}
</script>
</body>
</html>