Skip to content

Commit

Permalink
fix angle indicators for compound bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Apr 21, 2015
1 parent 13fcb4b commit 8031090
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/render/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ var Render = {};
var c = context,
render = engine.render,
options = render.options,
part,
i,
j,
k;
Expand All @@ -639,19 +640,22 @@ var Render = {};
if (options.showAxes) {
// render all axes
for (j = parts.length > 1 ? 1 : 0; j < parts.length; j++) {
var part = parts[j];
part = parts[j];
for (k = 0; k < part.axes.length; k++) {
var axis = part.axes[k];
c.moveTo(part.position.x, part.position.y);
c.lineTo(part.position.x + axis.x * 20, part.position.y + axis.y * 20);
}
}
} else {
if (body.parts.length === 1) {
// render a single axis indicator
c.moveTo(body.position.x, body.position.y);
c.lineTo((body.vertices[0].x + body.vertices[body.vertices.length-1].x) / 2,
(body.vertices[0].y + body.vertices[body.vertices.length-1].y) / 2);
for (j = parts.length > 1 ? 1 : 0; j < parts.length; j++) {
part = parts[j];
for (k = 0; k < part.axes.length; k++) {
// render a single axis indicator
c.moveTo(part.position.x, part.position.y);
c.lineTo((part.vertices[0].x + part.vertices[part.vertices.length-1].x) / 2,
(part.vertices[0].y + part.vertices[part.vertices.length-1].y) / 2);
}
}
}
}
Expand Down

0 comments on commit 8031090

Please sign in to comment.