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.
1 parent c05f15b commit 33655ec099d473fd712fa362959e9733afa86311
@finscn finscn authored on 16 Dec 2016
Mat Groves committed on 16 Dec 2016
Showing 1 changed file
View
src/core/graphics/Graphics.js