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

Make beforeRender can draw something to canvas

```js
Events.on(_render, 'beforeRender', function(event) { 
    // draw somethings to canvas has lower z-index...
});
```
This commit is contained in:
Mofasa 2019-06-09 14:33:17 +08:00 committed by GitHub
parent 2ec247b7af
commit 13c457fa15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -306,8 +306,6 @@ var Mouse = require('../core/Mouse');
timestamp: engine.timing.timestamp
};
Events.trigger(render, 'beforeRender', event);
// apply background if it has changed
if (render.currentBackground !== background)
_applyBackground(render, background);
@ -318,6 +316,8 @@ var Mouse = require('../core/Mouse');
context.fillRect(0, 0, canvas.width, canvas.height);
context.globalCompositeOperation = 'source-over';
Events.trigger(render, 'beforeRender', event);
// handle bounds
if (options.hasBounds) {
// filter out bodies that are not in view