Skip to content

Commit

Permalink
Optimize thin links.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 18, 2012
1 parent 8ea4173 commit 1196f55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/hive/hive.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<style>

.link {
fill: none;
stroke-width: 1.5px;
}

Expand Down
9 changes: 7 additions & 2 deletions examples/hive/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1196f55

Please sign in to comment.