0
0
Fork 0
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:
liabru 2020-03-11 22:12:01 +00:00
parent 0764c8d002
commit baf478aaf6

View file

@ -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();
}
}
};