0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

constraints now use a render property

This commit is contained in:
liabru 2014-03-19 00:55:33 +00:00
parent 123d391d00
commit d54ccb90a6
3 changed files with 11 additions and 6 deletions

View file

@ -41,9 +41,12 @@ var Constraint = {};
constraint.length = constraint.length || length || _minLength;
// render
constraint.render = constraint.render || {};
constraint.render.lineWidth = constraint.render.lineWidth || 2;
constraint.render.strokeStyle = constraint.render.strokeStyle || '#666';
// option defaults
constraint.lineWidth = constraint.lineWidth || 2;
constraint.strokeStyle = constraint.strokeStyle || '#666';
constraint.stiffness = constraint.stiffness || 1;
constraint.angularStiffness = constraint.angularStiffness || 0;
constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA;

View file

@ -21,8 +21,10 @@ var MouseConstraint = {};
length: 0.01,
stiffness: 0.1,
angularStiffness: 1,
strokeStyle: 'lightgreen',
lineWidth: 3
render: {
strokeStyle: '#90EE90',
lineWidth: 3
}
});
return {

View file

@ -191,8 +191,8 @@ var Render = {};
c.lineTo(constraint.pointB.x, constraint.pointB.y);
}
c.lineWidth = constraint.lineWidth;
c.strokeStyle = constraint.strokeStyle;
c.lineWidth = constraint.render.lineWidth;
c.strokeStyle = constraint.render.strokeStyle;
c.stroke();
};