Permalink
Browse files

Optimize thin links.

  • Loading branch information...
1 parent 8ea4173 commit 1196f55b4327e8f655c1388ecf50b4d646f22a26 @mbostock mbostock committed Mar 18, 2012
Showing with 8 additions and 2 deletions.
  1. +1 −0 examples/hive/hive.html
  2. +7 −2 examples/hive/link.js
View
1 examples/hive/hive.html
@@ -3,6 +3,7 @@
<style>
.link {
+ fill: none;
stroke-width: 1.5px;
}
View
9 examples/hive/link.js
@@ -14,15 +14,20 @@ function link() {
if (t.a - s.a > Math.PI) s.a += 2 * Math.PI;
var a1 = s.a + (t.a - s.a) / 3,
a2 = t.a - (t.a - s.a) / 3;
- return "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
+ return s.r0 - s.r1 || t.r0 - t.r1
+ ? "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
+ "L" + Math.cos(s.a) * s.r1 + "," + Math.sin(s.a) * s.r1
+ "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1
+ " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1
+ " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1
+ "L" + Math.cos(t.a) * t.r0 + "," + Math.sin(t.a) * t.r0
+ "C" + Math.cos(a2) * t.r0 + "," + Math.sin(a2) * t.r0
+ " " + Math.cos(a1) * s.r0 + "," + Math.sin(a1) * s.r0
- + " " + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0;
+ + " " + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
+ : "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
+ + "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1
+ + " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1
+ + " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1;
}
function node(method, thiz, d, i) {

0 comments on commit 1196f55

Please sign in to comment.