Update `clear` for a more thorough cleaning (#3445)
* Update `clear` for a more thorough cleaning Clear something that should be cleared. ` this.currentPath = null; this._spriteRect = null; ` if no this patch , some test cases will be failed. ##Test Case There is some common codes of test cases : ```js var renderer = new PIXI.WebGLRenderer(900, 600, { clearBeforeRender: false, backgroundColor: 0xFFFFFF }); document.body.appendChild(renderer.view); // the root container. var stage = new PIXI.Container(); ``` ### TEST 1 If no ```currentPath = null ``` , the second arc can't be rendered, and there is no error on browser's console. ```js var graphics = new PIXI.Graphics(); stage.addChild(graphics); // clear manually renderer.clear(); graphics.clear(); graphics.beginFill(0xFF0000); graphics.arc(150, 160, 100, 0, Math.PI * 2, false); graphics.endFill(); // draw the first shape renderer.render(stage); graphics.clear(); graphics.beginFill(0x0000FF); graphics.arc(150+50, 160+50, 100, 0, Math.PI * 2, false); graphics.endFill(); // draw the second shape renderer.render(stage); ``` ### TEST 2 If no ```_spriteRect = null ``` , the first rect can't be rendered, and there is no error on browser's console. ``` var graphics = new PIXI.Graphics(); stage.addChild(graphics); // clear manually renderer.clear(); graphics.clear(); graphics.beginFill(0xFF0000); graphics.drawRect(150, 160, 100, 60); graphics.endFill(); // draw the first shape graphics.updateTransform(); graphics.renderWebGL(renderer); graphics.clear(); graphics.beginFill(0x0000FF); graphics.drawRect(150+50, 160+50, 100, 60); graphics.endFill(); // draw the second shape graphics.updateTransform(); graphics.renderWebGL(renderer); // flush manually renderer.flush(); ``` ### Summary If don't call `graphics.clear();` before draw the second shape , there will be another error. If add ``` this.currentPath = null; this._spriteRect = null; ``` in `clear()` everything will be OK, and I test many other examples, this patch doesn't break anything else, it's safe. I know when we want to draw multi shapes , we could use multi graphics objects. But we shouldn't prevent users to use one shared graphics to draw multi shapes. * Remove trailing spaces.
batch-dev
bugfix/polygon-offset
dev
dev-blendmode-add-again
dev-canvas-renderer-dirty-transform
dev-graphics-fix-batches
dev-line-join
dev-offscreen-canvas
dev-renderTexture-pool
dev-replace-buble-with-babel
englercj/update-s3
feature-nine-slice-canvas-tint
fix-svg
master
multiple-pointer-down-events
upgrade
v4.x
v5.0.4
v5.0.3
v5.0.2
v5.0.1
v5.0.0-rc.3
v5.0.0-rc.2
v5.0.0-rc
v5.0.0-alpha.3
v5.0.0-alpha.2
v5.0.0-alpha
v5.0.0
v4.8.8
v4.8.7
v4.8.6
v4.8.5
v4.8.4
v4.8.3
v4.8.2
v4.8.1
v4.8.0
v4.7.3
v4.7.2
v4.7.1
v4.7.0
v4.6.2
v4.6.1
v4.6.0
v4.5.6
v4.5.5
v4.5.4
v4.5.3
v4.5.2
v4.5.1
v4.5.0
floattex
|
---|
|
src/core/graphics/Graphics.js |
---|