0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-01-31 18:14:55 -05:00

support img style filter

This commit is contained in:
yao 2022-10-10 09:56:31 +08:00
parent 8ca9cb4fa4
commit 0f98f14d05

View file

@ -742,6 +742,9 @@ var Mouse = require('../core/Mouse');
c.translate(part.position.x, part.position.y);
c.rotate(part.angle);
// support img style filter
if (texture.style && texture.style.filter)
context.filter = texture.style.filter;
c.drawImage(
texture,
texture.width * -sprite.xOffset * sprite.xScale,
@ -749,6 +752,10 @@ var Mouse = require('../core/Mouse');
texture.width * sprite.xScale,
texture.height * sprite.yScale
);
// should reset context.filter after draw
if (texture.style && texture.style.filter)
context.filter = "none";
// revert translation, hopefully faster than save / restore
c.rotate(-part.angle);