Skip to content

Commit 43f9e97

Browse files
committed
P_2_2_5_01: small changes to make some lines shorter for the book
1 parent 701d22f commit 43f9e97

File tree

2 files changed

+3484
-2919
lines changed

2 files changed

+3484
-2919
lines changed

01_P/P_2_2_5_01/sketch.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ function draw() {
6767
var intersection = false;
6868
for (var newR = maxRadius; newR >= minRadius; newR--) {
6969
for (var i = 0; i < circles.length; i++) {
70-
intersection = dist(newX, newY, circles[i].x, circles[i].y) < circles[i].r + newR;
70+
var d = dist(newX, newY, circles[i].x, circles[i].y);
71+
intersection = d < circles[i].r + newR;
7172
if (intersection) {
7273
break;
7374
}
@@ -83,7 +84,8 @@ function draw() {
8384
// Try to find an adjacent circle to the current one and draw a connecting line between the two
8485
var closestCircle;
8586
for (var j = 0; j < circles.length; j++) {
86-
if (dist(circles[i].x, circles[i].y, circles[j].x, circles[j].y) <= circles[i].r + circles[j].r + 1) {
87+
var d = dist(circles[i].x, circles[i].y, circles[j].x, circles[j].y);
88+
if (d <= circles[i].r + circles[j].r + 1) {
8789
closestCircle = circles[j];
8890
break;
8991
}

0 commit comments

Comments
 (0)