Skip to content

Commit

Permalink
improved spring and pin rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jun 27, 2017
1 parent b874f4d commit 837c43b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/constraint/Constraint.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var Common = require('../core/Common');
anchors: true
};

if (constraint.length === 0) {
if (constraint.length === 0 && constraint.stiffness > 0.1) {
render.type = 'pin';
render.anchors = false;
} else if (constraint.stiffness < 0.9) {
Expand Down
4 changes: 2 additions & 2 deletions src/render/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ var Mouse = require('../core/Mouse');

if (constraint.render.type === 'pin') {
c.beginPath();
c.arc(start.x, start.y, 4, 0, 2 * Math.PI);
c.arc(start.x, start.y, 3, 0, 2 * Math.PI);
c.closePath();
} else {
if (bodyB) {
Expand All @@ -526,7 +526,7 @@ var Mouse = require('../core/Mouse');
coils = Math.ceil(Common.clamp(constraint.length / 5, 12, 20)),
offset;

for (var j = 0; j < coils; j += 1) {
for (var j = 1; j < coils; j += 1) {
offset = j % 2 === 0 ? 1 : -1;

c.lineTo(
Expand Down

0 comments on commit 837c43b

Please sign in to comment.