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:
parent
8ca9cb4fa4
commit
0f98f14d05
1 changed files with 7 additions and 0 deletions
|
@ -742,6 +742,9 @@ var Mouse = require('../core/Mouse');
|
||||||
c.translate(part.position.x, part.position.y);
|
c.translate(part.position.x, part.position.y);
|
||||||
c.rotate(part.angle);
|
c.rotate(part.angle);
|
||||||
|
|
||||||
|
// support img style filter
|
||||||
|
if (texture.style && texture.style.filter)
|
||||||
|
context.filter = texture.style.filter;
|
||||||
c.drawImage(
|
c.drawImage(
|
||||||
texture,
|
texture,
|
||||||
texture.width * -sprite.xOffset * sprite.xScale,
|
texture.width * -sprite.xOffset * sprite.xScale,
|
||||||
|
@ -749,6 +752,10 @@ var Mouse = require('../core/Mouse');
|
||||||
texture.width * sprite.xScale,
|
texture.width * sprite.xScale,
|
||||||
texture.height * sprite.yScale
|
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
|
// revert translation, hopefully faster than save / restore
|
||||||
c.rotate(-part.angle);
|
c.rotate(-part.angle);
|
||||||
|
|
Loading…
Add table
Reference in a new issue