mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
fixes to body opacity rendering
This commit is contained in:
parent
adcb610f05
commit
8ac06b227a
1 changed files with 10 additions and 19 deletions
|
@ -437,18 +437,17 @@ var Vector = require('../geometry/Vector');
|
||||||
if (!part.render.visible)
|
if (!part.render.visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (options.showSleeping && body.isSleeping) {
|
||||||
|
c.globalAlpha = 0.5 * part.render.opacity;
|
||||||
|
} else if (part.render.opacity !== 1) {
|
||||||
|
c.globalAlpha = part.render.opacity;
|
||||||
|
}
|
||||||
|
|
||||||
if (part.render.sprite && part.render.sprite.texture && !options.wireframes) {
|
if (part.render.sprite && part.render.sprite.texture && !options.wireframes) {
|
||||||
// part sprite
|
// part sprite
|
||||||
var sprite = part.render.sprite,
|
var sprite = part.render.sprite,
|
||||||
texture = _getTexture(render, sprite.texture);
|
texture = _getTexture(render, sprite.texture);
|
||||||
|
|
||||||
if (options.showSleeping && body.isSleeping)
|
|
||||||
c.globalAlpha = 0.5;
|
|
||||||
|
|
||||||
if (part.render.opacity !== 1)
|
|
||||||
c.globalAlpha = part.render.opacity;
|
|
||||||
|
|
||||||
|
|
||||||
c.translate(part.position.x, part.position.y);
|
c.translate(part.position.x, part.position.y);
|
||||||
c.rotate(part.angle);
|
c.rotate(part.angle);
|
||||||
|
|
||||||
|
@ -463,9 +462,6 @@ var Vector = require('../geometry/Vector');
|
||||||
// revert translation, hopefully faster than save / restore
|
// revert translation, hopefully faster than save / restore
|
||||||
c.rotate(-part.angle);
|
c.rotate(-part.angle);
|
||||||
c.translate(-part.position.x, -part.position.y);
|
c.translate(-part.position.x, -part.position.y);
|
||||||
|
|
||||||
if ((options.showSleeping && body.isSleeping) || part.render.opacity !== 1)
|
|
||||||
c.globalAlpha = 1;
|
|
||||||
} else {
|
} else {
|
||||||
// part polygon
|
// part polygon
|
||||||
if (part.circleRadius) {
|
if (part.circleRadius) {
|
||||||
|
@ -481,24 +477,19 @@ var Vector = require('../geometry/Vector');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.wireframes) {
|
if (!options.wireframes) {
|
||||||
if (options.showSleeping && body.isSleeping) {
|
|
||||||
c.fillStyle = Common.shadeColor(part.render.fillStyle, 50);
|
|
||||||
} else {
|
|
||||||
c.fillStyle = part.render.fillStyle;
|
c.fillStyle = part.render.fillStyle;
|
||||||
}
|
|
||||||
|
|
||||||
c.lineWidth = part.render.lineWidth;
|
c.lineWidth = part.render.lineWidth;
|
||||||
c.strokeStyle = part.render.strokeStyle;
|
c.strokeStyle = part.render.strokeStyle;
|
||||||
c.fill();
|
c.fill();
|
||||||
c.stroke();
|
|
||||||
} else {
|
} else {
|
||||||
c.lineWidth = 1;
|
c.lineWidth = 1;
|
||||||
c.strokeStyle = '#bbb';
|
c.strokeStyle = '#bbb';
|
||||||
if (options.showSleeping && body.isSleeping)
|
|
||||||
c.strokeStyle = 'rgba(255,255,255,0.2)';
|
|
||||||
c.stroke();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue