mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-12 16:08:50 -05:00
added angle constraint rendering to Matter.Render
This commit is contained in:
parent
0764c8d002
commit
baf478aaf6
1 changed files with 26 additions and 0 deletions
|
@ -560,6 +560,32 @@ var Mouse = require('../core/Mouse');
|
|||
c.closePath();
|
||||
c.fill();
|
||||
}
|
||||
|
||||
if (constraint.render.angles && constraint.angleAStiffness) {
|
||||
var relativeAngle = (constraint.length > 0 && constraint.bodyA ? constraint.bodyA.angle : 0) + constraint.angleA;
|
||||
c.beginPath();
|
||||
c.moveTo(start.x, start.y);
|
||||
c.arc(start.x, start.y, 12, relativeAngle + constraint.angleAMin,
|
||||
relativeAngle + constraint.angleAMax + 0.0001, constraint.angleAMin <= constraint.angleAMax);
|
||||
c.lineTo(start.x, start.y);
|
||||
c.closePath();
|
||||
c.strokeStyle = 'rgba(255,255,255,' + (0.3 + 0.3 * constraint.angleAStiffness) + ')';
|
||||
c.lineWidth = 1.2;
|
||||
c.stroke();
|
||||
}
|
||||
|
||||
if (constraint.render.angles && constraint.angleBStiffness) {
|
||||
var relativeAngle = (constraint.length > 0 && constraint.bodyB ? constraint.bodyB.angle : 0) + constraint.angleB;
|
||||
c.beginPath();
|
||||
c.moveTo(end.x, end.y);
|
||||
c.arc(end.x, end.y, 12, relativeAngle + constraint.angleBMin,
|
||||
relativeAngle + constraint.angleBMax + 0.0001, constraint.angleBMin <= constraint.angleBMax);
|
||||
c.lineTo(end.x, end.y);
|
||||
c.closePath();
|
||||
c.strokeStyle = 'rgba(255,255,255,' + (0.3 + 0.3 * constraint.angleBStiffness) + ')';
|
||||
c.lineWidth = 1.2;
|
||||
c.stroke();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue