Skip to content

Commit

Permalink
Fixed height detection for mouseDragged on use cases, and added calcu…
Browse files Browse the repository at this point in the history
…lation for actor movement
  • Loading branch information
predominant committed Apr 3, 2011
1 parent 4207647 commit 9587f10
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions jsdiagram.pjs
Expand Up @@ -25,14 +25,14 @@ void draw() {
}

void mouseDragged() {
for (var i = 0; i < items.size(); i++) {
for (var i = items.size() - 1; i >= 0; i--) {
UMLItem item = (UMLItem)items.get(i);
if (item.inBounds(mouseX, mouseY)) {
item.move(mouseX, mouseY);
redraw();
break;
}
}
redraw();
}


Expand Down Expand Up @@ -91,7 +91,7 @@ class Case extends UMLItem {
}

boolean inBounds(xPos, yPos) {
return xPos >= x - round(size / 2) && xPos <= x + round(size / 2) && yPos >= y - round(size / 3) && yPos <= y + round(size / 3);
return xPos >= x - round(size / 2) && xPos <= x + round(size / 2) && yPos >= y - round(size / 3 / 2) && yPos <= y + round(size / 3 / 2);
}
}

Expand All @@ -113,4 +113,8 @@ class Actor extends UMLItem {
line(x, y + sixth, x - sixth, y + third + sixth);
line(x, y + sixth, x + sixth, y + third + sixth);
}

boolean inBounds(xPos, yPos) {
return xPos >= x - sixth && xPos <= xPos + sixth && yPos >= y - sixth - third && yPos <= y + sixth + third;
}
}

0 comments on commit 9587f10

Please sign in to comment.