mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-02 10:49:45 -05:00
constraints now use a render property
This commit is contained in:
parent
123d391d00
commit
d54ccb90a6
3 changed files with 11 additions and 6 deletions
|
@ -41,9 +41,12 @@ var Constraint = {};
|
||||||
|
|
||||||
constraint.length = constraint.length || length || _minLength;
|
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
|
// option defaults
|
||||||
constraint.lineWidth = constraint.lineWidth || 2;
|
|
||||||
constraint.strokeStyle = constraint.strokeStyle || '#666';
|
|
||||||
constraint.stiffness = constraint.stiffness || 1;
|
constraint.stiffness = constraint.stiffness || 1;
|
||||||
constraint.angularStiffness = constraint.angularStiffness || 0;
|
constraint.angularStiffness = constraint.angularStiffness || 0;
|
||||||
constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA;
|
constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA;
|
||||||
|
|
|
@ -21,8 +21,10 @@ var MouseConstraint = {};
|
||||||
length: 0.01,
|
length: 0.01,
|
||||||
stiffness: 0.1,
|
stiffness: 0.1,
|
||||||
angularStiffness: 1,
|
angularStiffness: 1,
|
||||||
strokeStyle: 'lightgreen',
|
render: {
|
||||||
|
strokeStyle: '#90EE90',
|
||||||
lineWidth: 3
|
lineWidth: 3
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -191,8 +191,8 @@ var Render = {};
|
||||||
c.lineTo(constraint.pointB.x, constraint.pointB.y);
|
c.lineTo(constraint.pointB.x, constraint.pointB.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
c.lineWidth = constraint.lineWidth;
|
c.lineWidth = constraint.render.lineWidth;
|
||||||
c.strokeStyle = constraint.strokeStyle;
|
c.strokeStyle = constraint.render.strokeStyle;
|
||||||
c.stroke();
|
c.stroke();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue