Skip to content

Commit

Permalink
fixed rendering of compound bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Feb 7, 2016
1 parent aaffee3 commit 99dd6c5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/render/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ var Vector = require('../geometry/Vector');
var c = context,
render = engine.render,
options = render.options,
showInternalEdges = options.showInternalEdges || !options.wireframes,
body,
part,
i,
Expand Down Expand Up @@ -470,14 +471,25 @@ var Vector = require('../geometry/Vector');
} else {
c.beginPath();
c.moveTo(part.vertices[0].x, part.vertices[0].y);
for (var j = 1; j < part.vertices.length; j++) {
c.lineTo(part.vertices[j].x, part.vertices[j].y);

for (j = 1; j < part.vertices.length; j++) {
if (!part.vertices[j - 1].isInternal || showInternalEdges) {
c.lineTo(part.vertices[j].x, part.vertices[j].y);
} else {
c.moveTo(part.vertices[j].x, part.vertices[j].y);
}

if (part.vertices[j].isInternal && !showInternalEdges) {
c.moveTo(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y);
}
}

c.lineTo(part.vertices[0].x, part.vertices[0].y);
c.closePath();
}

if (!options.wireframes) {
c.fillStyle = part.render.fillStyle;
c.fillStyle = part.render.fillStyle;
c.lineWidth = part.render.lineWidth;
c.strokeStyle = part.render.strokeStyle;
c.fill();
Expand Down

0 comments on commit 99dd6c5

Please sign in to comment.