diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/src/core/ticker/index.js b/src/core/ticker/index.js index c16ed7c..c7b45db 100644 --- a/src/core/ticker/index.js +++ b/src/core/ticker/index.js @@ -1,9 +1,3 @@ -/** - * @file Main export of the PIXI extras library - * @author Mat Groves - * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} - */ var Ticker = require('./Ticker'); /** @@ -14,36 +8,36 @@ * how to opt-out of auto-starting the shared ticker. * * @example - * var ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); + * var ticker = PIXI.ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); * * @example - * // You may use the shared ticker to render... - * var renderer = PIXI.autoDetectRenderer(800, 600); - * var stage = new PIXI.Container(); - * var interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); + * // You may use the shared ticker to render... + * var renderer = PIXI.autoDetectRenderer(800, 600); + * var stage = new PIXI.Container(); + * var interactionManager = PIXI.interaction.InteractionManager(renderer); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); * * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); * * @type {PIXI.ticker.Ticker} * @memberof PIXI.ticker diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/src/core/ticker/index.js b/src/core/ticker/index.js index c16ed7c..c7b45db 100644 --- a/src/core/ticker/index.js +++ b/src/core/ticker/index.js @@ -1,9 +1,3 @@ -/** - * @file Main export of the PIXI extras library - * @author Mat Groves - * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} - */ var Ticker = require('./Ticker'); /** @@ -14,36 +8,36 @@ * how to opt-out of auto-starting the shared ticker. * * @example - * var ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); + * var ticker = PIXI.ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); * * @example - * // You may use the shared ticker to render... - * var renderer = PIXI.autoDetectRenderer(800, 600); - * var stage = new PIXI.Container(); - * var interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); + * // You may use the shared ticker to render... + * var renderer = PIXI.autoDetectRenderer(800, 600); + * var stage = new PIXI.Container(); + * var interactionManager = PIXI.interaction.InteractionManager(renderer); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); * * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); * * @type {PIXI.ticker.Ticker} * @memberof PIXI.ticker diff --git a/src/core/utils/index.js b/src/core/utils/index.js index e6853d8..49ecd64 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -25,6 +25,7 @@ * Converts a hex color number to an [R, G, B] array * * @param hex {number} + * @param {number[]} [out=[]] * @return {number[]} An array representing the [R, G, B] of the color. */ hex2rgb: function (hex, out) @@ -142,7 +143,7 @@ * used by spritesheets and image urls * * @param url {string} the image path - * @return {boolean} + * @return {number} */ getResolutionOfUrl: function (url) { @@ -185,7 +186,7 @@ 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', - 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;' ]; window.console.log.apply(console, args); //jshint ignore:line @@ -225,7 +226,7 @@ }, /** - * Retunrs sign of number + * Returns sign of number * * @param n {number} * @returns {number} 0 if n is 0, -1 if n is negative, 1 if n i positive diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/src/core/ticker/index.js b/src/core/ticker/index.js index c16ed7c..c7b45db 100644 --- a/src/core/ticker/index.js +++ b/src/core/ticker/index.js @@ -1,9 +1,3 @@ -/** - * @file Main export of the PIXI extras library - * @author Mat Groves - * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} - */ var Ticker = require('./Ticker'); /** @@ -14,36 +8,36 @@ * how to opt-out of auto-starting the shared ticker. * * @example - * var ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); + * var ticker = PIXI.ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); * * @example - * // You may use the shared ticker to render... - * var renderer = PIXI.autoDetectRenderer(800, 600); - * var stage = new PIXI.Container(); - * var interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); + * // You may use the shared ticker to render... + * var renderer = PIXI.autoDetectRenderer(800, 600); + * var stage = new PIXI.Container(); + * var interactionManager = PIXI.interaction.InteractionManager(renderer); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); * * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); * * @type {PIXI.ticker.Ticker} * @memberof PIXI.ticker diff --git a/src/core/utils/index.js b/src/core/utils/index.js index e6853d8..49ecd64 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -25,6 +25,7 @@ * Converts a hex color number to an [R, G, B] array * * @param hex {number} + * @param {number[]} [out=[]] * @return {number[]} An array representing the [R, G, B] of the color. */ hex2rgb: function (hex, out) @@ -142,7 +143,7 @@ * used by spritesheets and image urls * * @param url {string} the image path - * @return {boolean} + * @return {number} */ getResolutionOfUrl: function (url) { @@ -185,7 +186,7 @@ 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', - 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;' ]; window.console.log.apply(console, args); //jshint ignore:line @@ -225,7 +226,7 @@ }, /** - * Retunrs sign of number + * Returns sign of number * * @param n {number} * @returns {number} 0 if n is 0, -1 if n is negative, 1 if n i positive diff --git a/src/extras/index.js b/src/extras/index.js index 184d586..07ed8bc 100644 --- a/src/extras/index.js +++ b/src/extras/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ require('./cacheAsBitmap'); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/src/core/ticker/index.js b/src/core/ticker/index.js index c16ed7c..c7b45db 100644 --- a/src/core/ticker/index.js +++ b/src/core/ticker/index.js @@ -1,9 +1,3 @@ -/** - * @file Main export of the PIXI extras library - * @author Mat Groves - * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} - */ var Ticker = require('./Ticker'); /** @@ -14,36 +8,36 @@ * how to opt-out of auto-starting the shared ticker. * * @example - * var ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); + * var ticker = PIXI.ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); * * @example - * // You may use the shared ticker to render... - * var renderer = PIXI.autoDetectRenderer(800, 600); - * var stage = new PIXI.Container(); - * var interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); + * // You may use the shared ticker to render... + * var renderer = PIXI.autoDetectRenderer(800, 600); + * var stage = new PIXI.Container(); + * var interactionManager = PIXI.interaction.InteractionManager(renderer); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); * * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); * * @type {PIXI.ticker.Ticker} * @memberof PIXI.ticker diff --git a/src/core/utils/index.js b/src/core/utils/index.js index e6853d8..49ecd64 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -25,6 +25,7 @@ * Converts a hex color number to an [R, G, B] array * * @param hex {number} + * @param {number[]} [out=[]] * @return {number[]} An array representing the [R, G, B] of the color. */ hex2rgb: function (hex, out) @@ -142,7 +143,7 @@ * used by spritesheets and image urls * * @param url {string} the image path - * @return {boolean} + * @return {number} */ getResolutionOfUrl: function (url) { @@ -185,7 +186,7 @@ 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', - 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;' ]; window.console.log.apply(console, args); //jshint ignore:line @@ -225,7 +226,7 @@ }, /** - * Retunrs sign of number + * Returns sign of number * * @param n {number} * @returns {number} 0 if n is 0, -1 if n is negative, 1 if n i positive diff --git a/src/extras/index.js b/src/extras/index.js index 184d586..07ed8bc 100644 --- a/src/extras/index.js +++ b/src/extras/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ require('./cacheAsBitmap'); diff --git a/src/filters/index.js b/src/filters/index.js index 08e532c..3a57129 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI filters library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/src/core/ticker/index.js b/src/core/ticker/index.js index c16ed7c..c7b45db 100644 --- a/src/core/ticker/index.js +++ b/src/core/ticker/index.js @@ -1,9 +1,3 @@ -/** - * @file Main export of the PIXI extras library - * @author Mat Groves - * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} - */ var Ticker = require('./Ticker'); /** @@ -14,36 +8,36 @@ * how to opt-out of auto-starting the shared ticker. * * @example - * var ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); + * var ticker = PIXI.ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); * * @example - * // You may use the shared ticker to render... - * var renderer = PIXI.autoDetectRenderer(800, 600); - * var stage = new PIXI.Container(); - * var interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); + * // You may use the shared ticker to render... + * var renderer = PIXI.autoDetectRenderer(800, 600); + * var stage = new PIXI.Container(); + * var interactionManager = PIXI.interaction.InteractionManager(renderer); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); * * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); * * @type {PIXI.ticker.Ticker} * @memberof PIXI.ticker diff --git a/src/core/utils/index.js b/src/core/utils/index.js index e6853d8..49ecd64 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -25,6 +25,7 @@ * Converts a hex color number to an [R, G, B] array * * @param hex {number} + * @param {number[]} [out=[]] * @return {number[]} An array representing the [R, G, B] of the color. */ hex2rgb: function (hex, out) @@ -142,7 +143,7 @@ * used by spritesheets and image urls * * @param url {string} the image path - * @return {boolean} + * @return {number} */ getResolutionOfUrl: function (url) { @@ -185,7 +186,7 @@ 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', - 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;' ]; window.console.log.apply(console, args); //jshint ignore:line @@ -225,7 +226,7 @@ }, /** - * Retunrs sign of number + * Returns sign of number * * @param n {number} * @returns {number} 0 if n is 0, -1 if n is negative, 1 if n i positive diff --git a/src/extras/index.js b/src/extras/index.js index 184d586..07ed8bc 100644 --- a/src/extras/index.js +++ b/src/extras/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ require('./cacheAsBitmap'); diff --git a/src/filters/index.js b/src/filters/index.js index 08e532c..3a57129 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI filters library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/interaction/InteractionManager.js b/src/interaction/InteractionManager.js index b7b607a..6314090 100644 --- a/src/interaction/InteractionManager.js +++ b/src/interaction/InteractionManager.js @@ -747,7 +747,7 @@ this.eventData.data = touchData; this.eventData.stopped = false; - this.processInteractive( touchData.global, this.renderer._lastObjectRendered, this.processTouchMove, false ); + this.processInteractive( touchData.global, this.renderer._lastObjectRendered, this.processTouchMove, true ); this.returnTouchData( touchData ); } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/src/core/ticker/index.js b/src/core/ticker/index.js index c16ed7c..c7b45db 100644 --- a/src/core/ticker/index.js +++ b/src/core/ticker/index.js @@ -1,9 +1,3 @@ -/** - * @file Main export of the PIXI extras library - * @author Mat Groves - * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} - */ var Ticker = require('./Ticker'); /** @@ -14,36 +8,36 @@ * how to opt-out of auto-starting the shared ticker. * * @example - * var ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); + * var ticker = PIXI.ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); * * @example - * // You may use the shared ticker to render... - * var renderer = PIXI.autoDetectRenderer(800, 600); - * var stage = new PIXI.Container(); - * var interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); + * // You may use the shared ticker to render... + * var renderer = PIXI.autoDetectRenderer(800, 600); + * var stage = new PIXI.Container(); + * var interactionManager = PIXI.interaction.InteractionManager(renderer); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); * * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); * * @type {PIXI.ticker.Ticker} * @memberof PIXI.ticker diff --git a/src/core/utils/index.js b/src/core/utils/index.js index e6853d8..49ecd64 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -25,6 +25,7 @@ * Converts a hex color number to an [R, G, B] array * * @param hex {number} + * @param {number[]} [out=[]] * @return {number[]} An array representing the [R, G, B] of the color. */ hex2rgb: function (hex, out) @@ -142,7 +143,7 @@ * used by spritesheets and image urls * * @param url {string} the image path - * @return {boolean} + * @return {number} */ getResolutionOfUrl: function (url) { @@ -185,7 +186,7 @@ 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', - 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;' ]; window.console.log.apply(console, args); //jshint ignore:line @@ -225,7 +226,7 @@ }, /** - * Retunrs sign of number + * Returns sign of number * * @param n {number} * @returns {number} 0 if n is 0, -1 if n is negative, 1 if n i positive diff --git a/src/extras/index.js b/src/extras/index.js index 184d586..07ed8bc 100644 --- a/src/extras/index.js +++ b/src/extras/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ require('./cacheAsBitmap'); diff --git a/src/filters/index.js b/src/filters/index.js index 08e532c..3a57129 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI filters library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/interaction/InteractionManager.js b/src/interaction/InteractionManager.js index b7b607a..6314090 100644 --- a/src/interaction/InteractionManager.js +++ b/src/interaction/InteractionManager.js @@ -747,7 +747,7 @@ this.eventData.data = touchData; this.eventData.stopped = false; - this.processInteractive( touchData.global, this.renderer._lastObjectRendered, this.processTouchMove, false ); + this.processInteractive( touchData.global, this.renderer._lastObjectRendered, this.processTouchMove, true ); this.returnTouchData( touchData ); } diff --git a/src/interaction/index.js b/src/interaction/index.js index 47db327..df2b6ab 100644 --- a/src/interaction/index.js +++ b/src/interaction/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI interactions library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/src/core/ticker/index.js b/src/core/ticker/index.js index c16ed7c..c7b45db 100644 --- a/src/core/ticker/index.js +++ b/src/core/ticker/index.js @@ -1,9 +1,3 @@ -/** - * @file Main export of the PIXI extras library - * @author Mat Groves - * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} - */ var Ticker = require('./Ticker'); /** @@ -14,36 +8,36 @@ * how to opt-out of auto-starting the shared ticker. * * @example - * var ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); + * var ticker = PIXI.ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); * * @example - * // You may use the shared ticker to render... - * var renderer = PIXI.autoDetectRenderer(800, 600); - * var stage = new PIXI.Container(); - * var interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); + * // You may use the shared ticker to render... + * var renderer = PIXI.autoDetectRenderer(800, 600); + * var stage = new PIXI.Container(); + * var interactionManager = PIXI.interaction.InteractionManager(renderer); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); * * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); * * @type {PIXI.ticker.Ticker} * @memberof PIXI.ticker diff --git a/src/core/utils/index.js b/src/core/utils/index.js index e6853d8..49ecd64 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -25,6 +25,7 @@ * Converts a hex color number to an [R, G, B] array * * @param hex {number} + * @param {number[]} [out=[]] * @return {number[]} An array representing the [R, G, B] of the color. */ hex2rgb: function (hex, out) @@ -142,7 +143,7 @@ * used by spritesheets and image urls * * @param url {string} the image path - * @return {boolean} + * @return {number} */ getResolutionOfUrl: function (url) { @@ -185,7 +186,7 @@ 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', - 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;' ]; window.console.log.apply(console, args); //jshint ignore:line @@ -225,7 +226,7 @@ }, /** - * Retunrs sign of number + * Returns sign of number * * @param n {number} * @returns {number} 0 if n is 0, -1 if n is negative, 1 if n i positive diff --git a/src/extras/index.js b/src/extras/index.js index 184d586..07ed8bc 100644 --- a/src/extras/index.js +++ b/src/extras/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ require('./cacheAsBitmap'); diff --git a/src/filters/index.js b/src/filters/index.js index 08e532c..3a57129 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI filters library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/interaction/InteractionManager.js b/src/interaction/InteractionManager.js index b7b607a..6314090 100644 --- a/src/interaction/InteractionManager.js +++ b/src/interaction/InteractionManager.js @@ -747,7 +747,7 @@ this.eventData.data = touchData; this.eventData.stopped = false; - this.processInteractive( touchData.global, this.renderer._lastObjectRendered, this.processTouchMove, false ); + this.processInteractive( touchData.global, this.renderer._lastObjectRendered, this.processTouchMove, true ); this.returnTouchData( touchData ); } diff --git a/src/interaction/index.js b/src/interaction/index.js index 47db327..df2b6ab 100644 --- a/src/interaction/index.js +++ b/src/interaction/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI interactions library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/loaders/index.js b/src/loaders/index.js index e9d1ff8..eb42cde 100644 --- a/src/loaders/index.js +++ b/src/loaders/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI loaders library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e517065..3c2315a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ - Follow conventions already in the code, and listen to jshint. -[0]: https://github.com/GoodBoyDigital/pixi.js/issues +[0]: https://github.com/pixijs/pixi.js/issues [1]: http://jsfiddle.net [2]: http://jsbin.com/ [3]: http://nodejs.org diff --git a/README.md b/README.md index 468cc6d..4a6841a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Pixi.js ## [![Inline docs](http://inch-ci.org/github/GoodBoyDigital/pixi.js.svg?branch=dev)](http://inch-ci.org/github/GoodBoyDigital/pixi.js) -[![Build Status](https://travis-ci.org/GoodBoyDigital/pixi.js.svg?branch=dev)](https://travis-ci.org/GoodBoyDigital/pixi.js) +[![Build Status](https://travis-ci.org/pixijs/pixi.js.svg?branch=dev)](https://travis-ci.org/pixijs/pixi.js) The aim of this project is to provide a fast lightweight 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of @@ -43,7 +43,7 @@ - API Documentation is [here](http://pixijs.github.io/docs). - Feature Examples are [here](https://pixijs.github.io/examples). - The Pixi.js Forum is [here](http://www.html5gamedevs.com/forum/15-pixijs). -- Other misc tutorials and resources are [on the Wiki](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources). +- Other misc tutorials and resources are [on the Wiki](https://github.com/pixijs/pixi.js/wiki/Resources). ### Contribute ### @@ -51,7 +51,7 @@ together :) Whether you find a bug, have a great feature request or you fancy owning a task from the road map above feel free to get in touch. -Make sure to read the [Contributing Guide](https://github.com/GoodBoyDigital/pixi.js/blob/master/CONTRIBUTING.md) +Make sure to read the [Contributing Guide](https://github.com/pixijs/pixi.js/blob/master/CONTRIBUTING.md) before submitting changes. ### Current features ### @@ -71,7 +71,7 @@ - Primitive Drawing - Masking - Filters -- [User Plugins](https://github.com/GoodBoyDigital/pixi.js/wiki/Pixi-v3-Plugins) +- [User Plugins](https://github.com/pixijs/pixi.js/wiki/Pixi-v3-Plugins) ### Basic Usage Example ### @@ -120,7 +120,7 @@ ### How to build ### Note that for most users you don't need to build this project. If all you want is to use pixi, then -just download one of our [prebuilt releases](https://github.com/GoodBoyDigital/pixi.js/releases). Really +just download one of our [prebuilt releases](https://github.com/pixijs/pixi.js/releases). Really the only time you should need to build pixi.js is if you are developing it. If you don't already have Node.js and NPM, go install them. Once you do, you can then install the gulp @@ -172,7 +172,7 @@ ``` The documentation uses [Jaguar.js](https://github.com/davidshimjs/jaguarjs-jsdoc) and the jsdoc format, the configuration -file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/GoodBoyDigital/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) +file can be found at [gulp/utils/jsdoc.conf.json](https://github.com/pixijs/pixi.js/blob/dev/gulp/util/jsdoc.conf.json) ### License ### diff --git a/package.json b/package.json index feb0d69..5e7759c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ ], "main": "./src/index.js", "homepage": "http://goodboydigital.com/", - "bugs": "https://github.com/GoodBoyDigital/pixi.js/issues", + "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/GoodBoyDigital/pixi.js.git" + "url": "https://github.com/pixijs/pixi.js.git" }, "scripts": { "start": "gulp && gulp watch", diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d9ceae8..4c3c3c0 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -217,7 +217,9 @@ if (this.currentPath.shape.points.length) { // halfway through a line? start a new one! - this.drawShape( new math.Polygon( this.currentPath.shape.points.slice(-2) )); + var shape = new math.Polygon(this.currentPath.shape.points.slice(-2)); + shape.closed = false; + this.drawShape(shape); } else { @@ -240,7 +242,9 @@ */ Graphics.prototype.moveTo = function (x, y) { - this.drawShape(new math.Polygon([x,y])); + var shape = new math.Polygon([x,y]); + shape.closed = false; + this.drawShape(shape); return this; }; @@ -483,26 +487,11 @@ if (this.currentPath) { - if (anticlockwise && this.filling) - { - this.currentPath.shape.points.push(cx, cy); - } - else - { - this.currentPath.shape.points.push(startX, startY); - } + this.currentPath.shape.points.push(startX, startY); } else { - if (anticlockwise && this.filling) - { - - this.moveTo(cx, cy); - } - else - { - this.moveTo(startX, startY); - } + this.moveTo(startX, startY); } var points = this.currentPath.shape.points; @@ -650,6 +639,14 @@ // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments var points = path; + var closed = true; + + if (points instanceof math.Polygon) + { + closed = points.closed; + points = points.points; + } + if (!Array.isArray(points)) { // prevents an argument leak deopt @@ -662,7 +659,10 @@ } } - this.drawShape(new math.Polygon(points)); + var shape = new math.Polygon(points); + shape.closed = closed; + + this.drawShape(shape); return this; }; @@ -775,7 +775,6 @@ // if the tint has changed, set the graphics object to dirty. if (this._prevTint !== this.tint) { this.dirty = true; - this._prevTint = this.tint; } // this code may still be needed so leaving for now.. diff --git a/src/core/graphics/webgl/GraphicsRenderer.js b/src/core/graphics/webgl/GraphicsRenderer.js index 4012d97..93d2642 100644 --- a/src/core/graphics/webgl/GraphicsRenderer.js +++ b/src/core/graphics/webgl/GraphicsRenderer.js @@ -77,7 +77,7 @@ if (graphics.dirty) { - this.updateGraphics(graphics, gl); + this.updateGraphics(graphics); } var webGL = graphics._webGL[gl.id]; @@ -90,24 +90,24 @@ // var matrix = renderer.currentRenderTarget.projectionMatrix.clone(); // matrix.append(graphics.worldTransform); - for (var i = 0; i < webGL.data.length; i++) + for (var i = 0, n = webGL.data.length; i < n; i++) { + webGLData = webGL.data[i]; + if (webGL.data[i].mode === 1) { - webGLData = webGL.data[i]; - renderer.stencilManager.pushStencil(graphics, webGLData, renderer); + renderer.stencilManager.pushStencil(graphics, webGLData); gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location, graphics.worldAlpha * webGLData.alpha); // render quad.. gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 ); - renderer.stencilManager.popStencil(graphics, webGLData, renderer); + renderer.stencilManager.popStencil(graphics, webGLData); } else { - webGLData = webGL.data[i]; shader = renderer.shaderManager.primitiveShader; @@ -140,7 +140,7 @@ * Updates the graphics object * * @private - * @param graphicsData {PIXI.Graphics} The graphics object to update + * @param graphics {PIXI.Graphics} The graphics object to update */ GraphicsRenderer.prototype.updateGraphics = function(graphics) { @@ -585,15 +585,15 @@ { return; } - // if the line width is an odd number add 0.5 to align to a whole pixel - if (graphicsData.lineWidth%2) - { - for (i = 0; i < points.length; i++) - { - points[i] += 0.5; - } - } + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } // get first and last point.. figure out the middle! var firstPoint = new math.Point(points[0], points[1]); diff --git a/src/core/index.js b/src/core/index.js index 61f003f..1cc4552 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 282e1f0..30b7685 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -197,6 +197,12 @@ this.context = tempContext; }; +/** + * @extends PIXI.SystemRenderer#resize + * + * @param {number} w + * @param {number} h + */ CanvasRenderer.prototype.resize = function (w, h) { SystemRenderer.prototype.resize.call(this, w, h); diff --git a/src/core/renderers/canvas/utils/CanvasGraphics.js b/src/core/renderers/canvas/utils/CanvasGraphics.js index ad66340..b2d5b91 100644 --- a/src/core/renderers/canvas/utils/CanvasGraphics.js +++ b/src/core/renderers/canvas/utils/CanvasGraphics.js @@ -304,10 +304,11 @@ */ CanvasGraphics.updateGraphicsTint = function (graphics) { - if (graphics.tint === 0xFFFFFF) + if (graphics.tint === 0xFFFFFF && graphics._prevTint === graphics.tint) { return; } + graphics._prevTint = graphics.tint; var tintR = (graphics.tint >> 16 & 0xFF) / 255; var tintG = (graphics.tint >> 8 & 0xFF) / 255; diff --git a/src/core/renderers/canvas/utils/CanvasTinter.js b/src/core/renderers/canvas/utils/CanvasTinter.js index c4447e8..eedf175 100644 --- a/src/core/renderers/canvas/utils/CanvasTinter.js +++ b/src/core/renderers/canvas/utils/CanvasTinter.js @@ -66,7 +66,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -115,7 +121,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; @@ -151,7 +163,13 @@ { var context = canvas.getContext( '2d' ); - var crop = texture.crop; + var resolution = texture.baseTexture.resolution; + + var crop = texture.crop.clone(); + crop.x *= resolution; + crop.y *= resolution; + crop.width *= resolution; + crop.height *= resolution; canvas.width = crop.width; canvas.height = crop.height; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index bede5eb..d5e09a2 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -26,7 +26,7 @@ * @param [options.transparent=false] {boolean} If the render view is transparent, default false * @param [options.autoResize=false] {boolean} If the render view is automatically resized, default false * @param [options.antialias=false] {boolean} sets antialias. If not available natively then FXAA antialiasing is used - * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always lok as great + * @param [options.forceFXAA=false] {boolean} forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great * @param [options.resolution=1] {number} the resolution of the renderer retina would be 2 * @param [options.clearBeforeRender=true] {boolean} This sets if the CanvasRenderer will clear the canvas or * not before the new render pass. If you wish to set this to false, you *must* set preserveDrawingBuffer to `true`. diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index ab4a2e2..a245544 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -433,6 +433,8 @@ */ FilterManager.prototype.destroy = function () { + this.quad.destroy(); + WebGLManager.prototype.destroy.call(this); this.filterStack = null; diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index c37fb84..3655c5f 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -155,6 +155,8 @@ */ ShaderManager.prototype.destroy = function () { + this.primitiveShader.destroy(); + this.complexPrimitiveShader.destroy(); WebGLManager.prototype.destroy.call(this); this.destroyPlugins(); diff --git a/src/core/renderers/webgl/managers/StencilManager.js b/src/core/renderers/webgl/managers/StencilManager.js index 8ee11fa..e58804e 100644 --- a/src/core/renderers/webgl/managers/StencilManager.js +++ b/src/core/renderers/webgl/managers/StencilManager.js @@ -50,7 +50,7 @@ var gl = this.renderer.gl, sms = this.stencilMaskStack; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); if (sms.stencilStack.length === 0) { @@ -140,8 +140,6 @@ WebGLMaskManager.prototype.bindGraphics = function (graphics, webGLData) { //if (this._currentGraphics === graphics)return; - this._currentGraphics = graphics; - var gl = this.renderer.gl; // bind the graphics object.. @@ -177,7 +175,7 @@ //this.renderer.shaderManager.activatePrimitiveShader(); shader = this.renderer.shaderManager.primitiveShader; - this.renderer.shaderManager.setShader( shader ); + this.renderer.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); @@ -222,7 +220,7 @@ var level = sms.count; - this.bindGraphics(graphics, webGLData, this.renderer); + this.bindGraphics(graphics, webGLData); gl.colorMask(false, false, false, false); @@ -329,7 +327,7 @@ return; } - this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.pushStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; /** @@ -341,6 +339,6 @@ { this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0], this.renderer); + this.popStencil(maskData, maskData._webGL[this.renderer.gl.id].data[0]); }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 6566bdd..b82d2d2 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -85,7 +85,7 @@ Shader.prototype.constructor = Shader; module.exports = Shader; -/* +/** * Creates the shader and uses it * */ @@ -99,9 +99,9 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; -/* +/** * Caches the locations of the uniform for reuse. - + * * @param keys {string} the uniforms to cache */ Shader.prototype.cacheUniformLocations = function (keys) @@ -112,9 +112,9 @@ } }; -/* +/** * Caches the locations of the attribute for reuse. - + * * @param keys {string} the attributes to cache */ Shader.prototype.cacheAttributeLocations = function (keys) @@ -139,9 +139,9 @@ // End worst hack eva // }; -/* +/** * Attaches the shaders and creates the program. - + * * @return {WebGLProgram} */ Shader.prototype.compile = function () diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index 5ed8440..ccb0962 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -140,6 +140,14 @@ gl.bufferSubData(gl.ARRAY_BUFFER, (8 + 8) * 4, this.colors); }; +Quad.prototype.destroy = function() +{ + var gl = this.gl; + + gl.deleteBuffer(this.vertexBuffer); + gl.deleteBuffer(this.indexBuffer); +}; + module.exports = Quad; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 382e4e1..f664c07 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -311,6 +311,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; + gl.deleteRenderBuffer( this.stencilBuffer ); gl.deleteFramebuffer( this.frameBuffer ); gl.deleteTexture( this.texture ); diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index 3bb8737..bde2e86 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -2,7 +2,6 @@ * Generic Mask Stack data structure * @class * @memberof PIXI - * @param renderer {PIXI.WebGLRenderer} The renderer this manager works for. */ function StencilMaskStack() { diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 684a069..425a22c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -189,7 +189,7 @@ style.font = style.font || 'bold 20pt Arial'; style.fill = style.fill || 'black'; style.align = style.align || 'left'; - style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136 + style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/pixijs/pixi.js/issues/136 style.strokeThickness = style.strokeThickness || 0; style.wordWrap = style.wordWrap || false; style.wordWrapWidth = style.wordWrapWidth || 100; diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index c5e95a1..ee47963 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -17,6 +17,7 @@ * and rotation of the given Display Objects is ignored. For example: * * ```js + * var renderer = PIXI.autoDetectRenderer(1024, 1024, { view: canvas, ratio: 1 }); * var renderTexture = new PIXI.RenderTexture(renderer, 800, 600); * var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); * @@ -291,7 +292,6 @@ } updateTransform = !!updateTransform; - var cachedWt = displayObject.worldTransform; var wt = tempMatrix; @@ -303,6 +303,7 @@ } displayObject.worldTransform = wt; + var cachedWt = displayObject.worldTransform; // setWorld Alpha to ensure that the object is renderer at full opacity displayObject.worldAlpha = 1; diff --git a/src/core/ticker/Ticker.js b/src/core/ticker/Ticker.js index 7d1436e..970c82e 100644 --- a/src/core/ticker/Ticker.js +++ b/src/core/ticker/Ticker.js @@ -110,9 +110,9 @@ /** * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; * * @member {number} * @default 1 diff --git a/src/core/ticker/index.js b/src/core/ticker/index.js index c16ed7c..c7b45db 100644 --- a/src/core/ticker/index.js +++ b/src/core/ticker/index.js @@ -1,9 +1,3 @@ -/** - * @file Main export of the PIXI extras library - * @author Mat Groves - * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} - */ var Ticker = require('./Ticker'); /** @@ -14,36 +8,36 @@ * how to opt-out of auto-starting the shared ticker. * * @example - * var ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); + * var ticker = PIXI.ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); * * @example - * // You may use the shared ticker to render... - * var renderer = PIXI.autoDetectRenderer(800, 600); - * var stage = new PIXI.Container(); - * var interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); + * // You may use the shared ticker to render... + * var renderer = PIXI.autoDetectRenderer(800, 600); + * var stage = new PIXI.Container(); + * var interactionManager = PIXI.interaction.InteractionManager(renderer); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); * * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); * * @type {PIXI.ticker.Ticker} * @memberof PIXI.ticker diff --git a/src/core/utils/index.js b/src/core/utils/index.js index e6853d8..49ecd64 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -25,6 +25,7 @@ * Converts a hex color number to an [R, G, B] array * * @param hex {number} + * @param {number[]} [out=[]] * @return {number[]} An array representing the [R, G, B] of the color. */ hex2rgb: function (hex, out) @@ -142,7 +143,7 @@ * used by spritesheets and image urls * * @param url {string} the image path - * @return {boolean} + * @return {number} */ getResolutionOfUrl: function (url) { @@ -185,7 +186,7 @@ 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', - 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;' ]; window.console.log.apply(console, args); //jshint ignore:line @@ -225,7 +226,7 @@ }, /** - * Retunrs sign of number + * Returns sign of number * * @param n {number} * @returns {number} 0 if n is 0, -1 if n is negative, 1 if n i positive diff --git a/src/extras/index.js b/src/extras/index.js index 184d586..07ed8bc 100644 --- a/src/extras/index.js +++ b/src/extras/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ require('./cacheAsBitmap'); diff --git a/src/filters/index.js b/src/filters/index.js index 08e532c..3a57129 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI filters library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/interaction/InteractionManager.js b/src/interaction/InteractionManager.js index b7b607a..6314090 100644 --- a/src/interaction/InteractionManager.js +++ b/src/interaction/InteractionManager.js @@ -747,7 +747,7 @@ this.eventData.data = touchData; this.eventData.stopped = false; - this.processInteractive( touchData.global, this.renderer._lastObjectRendered, this.processTouchMove, false ); + this.processInteractive( touchData.global, this.renderer._lastObjectRendered, this.processTouchMove, true ); this.returnTouchData( touchData ); } diff --git a/src/interaction/index.js b/src/interaction/index.js index 47db327..df2b6ab 100644 --- a/src/interaction/index.js +++ b/src/interaction/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI interactions library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/loaders/index.js b/src/loaders/index.js index e9d1ff8..eb42cde 100644 --- a/src/loaders/index.js +++ b/src/loaders/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI loaders library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /** diff --git a/src/mesh/index.js b/src/mesh/index.js index b18a528..819c45b 100644 --- a/src/mesh/index.js +++ b/src/mesh/index.js @@ -2,7 +2,7 @@ * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital - * @license {@link https://github.com/GoodBoyDigital/pixi.js/blob/master/LICENSE|MIT License} + * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ /**