Compare commits

..

3 commits

Author SHA1 Message Date
Chad Engler
9d9b36329c Merge branch 'master' into palette-swap-filter 2014-02-10 11:59:34 -08:00
Chad Engler
f7f35f2060 Merge branch 'dev' into palette-swap-filter 2014-02-10 11:59:23 -08:00
Chad Engler
43806c63f2 Add Palette filter 2014-01-27 20:04:53 -08:00
19 changed files with 105 additions and 94 deletions

View file

@ -80,6 +80,7 @@ module.exports = function(grunt) {
'<%= dirs.src %>/filters/DotScreenFilter.js',
'<%= dirs.src %>/filters/CrossHatchFilter.js',
'<%= dirs.src %>/filters/RGBSplitFilter.js',
'<%= dirs.src %>/filters/PaletteFilter.js',
'<%= dirs.src %>/Outro.js'
],
banner = [

View file

@ -1,7 +1,7 @@
Pixi Renderer
=============
![pixi.js logo](http://www.goodboydigital.com/pixijs/logo_small.png)
![pixi.js logo](http://www.goodboydigital.com/pixijs/logo_small.png)
[<img src="http://www.pixijs.com/wp-content/uploads/2013/05/headerPanel_projects-898x342.jpg">](http://www.pixijs.com/projects)
#### JavaScript 2D Renderer ####
@ -15,8 +15,6 @@ If youre interested in pixi.js then feel free to follow me on twitter
of course check back on [our site](<http://www.goodboydigital.com/blog/>) as
any breakthroughs will be posted up there too!
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/GoodBoyDigital/pixi.js/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
### Demos ###
- [WebGL Filters!](<http://www.goodboydigital.com/pixijs/examples/15/indexAll.html>)

View file

@ -1,10 +1,10 @@
/**
* @license
* pixi.js - v1.5.1
* pixi.js - v1.5.0
* Copyright (c) 2012-2014, Mat Groves
* http://goodboydigital.com/
*
* Compiled: 2014-02-13
* Compiled: 2014-02-10
*
* pixi.js is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license.php
@ -35,7 +35,7 @@ PIXI.WEBGL_RENDERER = 0;
PIXI.CANVAS_RENDERER = 1;
// useful for testing against if your lib is using pixi.
PIXI.VERSION = "v1.5.1";
PIXI.VERSION = "v1.4.4";
// the various blend modes supported by pixi
PIXI.blendModes = {
@ -954,8 +954,8 @@ PIXI.DisplayObject.prototype.updateTransform = function()
a01 = -this._sr * this.scale.y,
a10 = this._sr * this.scale.x,
a11 = this._cr * this.scale.y,
a02 = this.position.x - a00 * px - py * a01,
a12 = this.position.y - a11 * py - px * a10,
a02 = this.position.x + a00 * px - py * a01,
a12 = this.position.y + a11 * py - px * a10,
b00 = parentTransform.a, b01 = parentTransform.b,
b10 = parentTransform.c, b11 = parentTransform.d;
@ -1946,9 +1946,9 @@ PIXI.Sprite.fromFrame = function(frameId)
* @param imageId {String} The image url of the texture
* @return {Sprite} A new Sprite using a texture from the texture cache matching the image id
*/
PIXI.Sprite.fromImage = function(imageId, crossorigin, scaleMode)
PIXI.Sprite.fromImage = function(imageId)
{
var texture = PIXI.Texture.fromImage(imageId, crossorigin, scaleMode);
var texture = PIXI.Texture.fromImage(imageId);
return new PIXI.Sprite(texture);
};
@ -3945,7 +3945,7 @@ PIXI.getNextPowerOfTwo = function(number)
* Adds event emitter functionality to a class
*
* @class EventTarget
* @example
*
* function MyEmitter() {
* PIXI.EventTarget.call(this); //mixes in event target stuff
* }
@ -4053,11 +4053,11 @@ PIXI.EventTarget = function () {
* @param width=800 {Number} the width of the renderers view
* @param height=600 {Number} the height of the renderers view
* @param [view] {Canvas} the canvas to use as a view, optional
* @param [transparent=false] {Boolean} the transparency of the render view, default false
* @param [antialias=false] {Boolean} sets antialias (only applicable in webGL chrome at the moment)
* @param [transparent=false] {Boolean} the transparency of the render view, default false
*
*/
PIXI.autoDetectRenderer = function(width, height, view, transparent, antialias)
PIXI.autoDetectRenderer = function(width, height, view,antialias,transparent)
{
if(!width)width = 800;
if(!height)height = 600;
@ -6619,7 +6619,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
// set the textures uvs temporarily
// TODO create a separate texture so that we can tile part of a texture
if(!tilingSprite._uvs)tilingSprite._uvs = new PIXI.TextureUvs();
if(!tilingSprite._uvs)tilingSprite._uvs = new Float32Array(8);
var uvs = tilingSprite._uvs;
@ -6644,6 +6644,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
uvs.x3 = 0 - offsetX;
uvs.y3 = (1 *scaleY) - offsetY;
// get the tilingSprites current alpha
var alpha = tilingSprite.worldAlpha;
var tint = tilingSprite.tint;
@ -8813,8 +8814,6 @@ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha)
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY};
this.graphicsData.push(this.currentPath);
return this;
};
/**
@ -8834,8 +8833,6 @@ PIXI.Graphics.prototype.moveTo = function(x, y)
this.currentPath.points.push(x, y);
this.graphicsData.push(this.currentPath);
return this;
};
/**
@ -8850,8 +8847,6 @@ PIXI.Graphics.prototype.lineTo = function(x, y)
{
this.currentPath.points.push(x, y);
this.dirty = true;
return this;
};
/**
@ -8868,8 +8863,6 @@ PIXI.Graphics.prototype.beginFill = function(color, alpha)
this.filling = true;
this.fillColor = color || 0;
this.fillAlpha = (arguments.length < 2) ? 1 : alpha;
return this;
};
/**
@ -8882,8 +8875,6 @@ PIXI.Graphics.prototype.endFill = function()
this.filling = false;
this.fillColor = null;
this.fillAlpha = 1;
return this;
};
/**
@ -8904,8 +8895,6 @@ PIXI.Graphics.prototype.drawRect = function( x, y, width, height )
this.graphicsData.push(this.currentPath);
this.dirty = true;
return this;
};
/**
@ -8927,8 +8916,6 @@ PIXI.Graphics.prototype.drawCircle = function( x, y, radius)
this.graphicsData.push(this.currentPath);
this.dirty = true;
return this;
};
/**
@ -8951,8 +8938,6 @@ PIXI.Graphics.prototype.drawEllipse = function( x, y, width, height)
this.graphicsData.push(this.currentPath);
this.dirty = true;
return this;
};
/**
@ -8970,8 +8955,6 @@ PIXI.Graphics.prototype.clear = function()
this.graphicsData = [];
this.bounds = null; //new PIXI.Rectangle();
return this;
};
/**

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "pixi.js",
"version": "1.5.1",
"version": "1.5.0",
"main": "bin/pixi.js",

View file

@ -25,7 +25,8 @@
var sprite= PIXI.Sprite.fromImage("spinObj_02.png");
//stage.addChild(sprite);
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(620, 380, null, false /* transparent */, true /* antialias */);
// the 5the parameter is the anti aliasing
var renderer = PIXI.autoDetectRenderer(620, 380, null, false, true);
// set the canvas width and height to fill the screen
//renderer.view.style.width = window.innerWidth + "px";

View file

@ -32,8 +32,7 @@
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(400, 300, null, true, true);
var renderer = PIXI.autoDetectRenderer(400, 300,false,true);
// add the renderer view element to the DOM
document.body.appendChild(renderer.view);

View file

@ -1,6 +1,6 @@
{
"name": "pixi.js",
"version": "1.5.1",
"version": "1.5.0",
"description": "Pixi.js is a fast lightweight 2D library that works across all devices.",
"author": "Mat Groves",

View file

@ -16,7 +16,7 @@ PIXI.WEBGL_RENDERER = 0;
PIXI.CANVAS_RENDERER = 1;
// useful for testing against if your lib is using pixi.
PIXI.VERSION = "v1.5.1";
PIXI.VERSION = "v1.4.4";
// the various blend modes supported by pixi
PIXI.blendModes = {

View file

@ -406,8 +406,8 @@ PIXI.DisplayObject.prototype.updateTransform = function()
a01 = -this._sr * this.scale.y,
a10 = this._sr * this.scale.x,
a11 = this._cr * this.scale.y,
a02 = this.position.x - a00 * px - py * a01,
a12 = this.position.y - a11 * py - px * a10,
a02 = this.position.x + a00 * px - py * a01,
a12 = this.position.y + a11 * py - px * a10,
b00 = parentTransform.a, b01 = parentTransform.b,
b10 = parentTransform.c, b11 = parentTransform.d;

View file

@ -466,8 +466,8 @@ PIXI.Sprite.fromFrame = function(frameId)
* @param imageId {String} The image url of the texture
* @return {Sprite} A new Sprite using a texture from the texture cache matching the image id
*/
PIXI.Sprite.fromImage = function(imageId, crossorigin, scaleMode)
PIXI.Sprite.fromImage = function(imageId)
{
var texture = PIXI.Texture.fromImage(imageId, crossorigin, scaleMode);
var texture = PIXI.Texture.fromImage(imageId);
return new PIXI.Sprite(texture);
};

View file

@ -0,0 +1,58 @@
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
PIXI.PaletteFilter = function(paletteTexture, paletteWidth)
{
PIXI.AbstractFilter.call(this);
this.passes = [this];
// set the uniforms
this.uniforms = {
palette: { type: 'sampler2D', value: paletteTexture },
width: { type: '1f', value: paletteWidth },
widthInv: { type: '1f', value: 1 / paletteWidth }
};
this.fragmentSrc = [
'precision mediump float;',
'varying vec2 vTextureCoord;',
'varying vec4 vColor;',
'uniform sampler2D uSampler;',
'uniform sampler2D palette;',
'uniform float width;',
'uniform float widthInv;',
'void main() {',
' float index = texture2D(uSampler, vTextureCoord).r * 255.0;', //Red holds index into palette
' vec2 coord = vec2(', //convert index into coords in palette texture
' mod(index, width) * widthInv,',
' (index / width) * widthInv',
' );',
' gl_FragColor = texture2D(palette, coord);', //Read color from palette and output
'}'
];
};
PIXI.PaletteFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
PIXI.PaletteFilter.prototype.constructor = PIXI.PaletteFilter;
Object.defineProperty(PIXI.PaletteFilter.prototype, 'palette', {
get: function() {
return this.uniforms.palette.value;
},
set: function(value) {
this.uniforms.palette.value = value;
}
});
Object.defineProperty(PIXI.PaletteFilter.prototype, 'width', {
get: function() {
return this.uniforms.width.value;
},
set: function(value) {
this.uniforms.width.value = value;
this.uniforms.widthInv.value = 1 / value;
}
});

View file

@ -169,8 +169,6 @@ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha)
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY};
this.graphicsData.push(this.currentPath);
return this;
};
/**
@ -190,8 +188,6 @@ PIXI.Graphics.prototype.moveTo = function(x, y)
this.currentPath.points.push(x, y);
this.graphicsData.push(this.currentPath);
return this;
};
/**
@ -206,8 +202,6 @@ PIXI.Graphics.prototype.lineTo = function(x, y)
{
this.currentPath.points.push(x, y);
this.dirty = true;
return this;
};
/**
@ -224,8 +218,6 @@ PIXI.Graphics.prototype.beginFill = function(color, alpha)
this.filling = true;
this.fillColor = color || 0;
this.fillAlpha = (arguments.length < 2) ? 1 : alpha;
return this;
};
/**
@ -238,8 +230,6 @@ PIXI.Graphics.prototype.endFill = function()
this.filling = false;
this.fillColor = null;
this.fillAlpha = 1;
return this;
};
/**
@ -260,8 +250,6 @@ PIXI.Graphics.prototype.drawRect = function( x, y, width, height )
this.graphicsData.push(this.currentPath);
this.dirty = true;
return this;
};
/**
@ -283,8 +271,6 @@ PIXI.Graphics.prototype.drawCircle = function( x, y, radius)
this.graphicsData.push(this.currentPath);
this.dirty = true;
return this;
};
/**
@ -307,8 +293,6 @@ PIXI.Graphics.prototype.drawEllipse = function( x, y, width, height)
this.graphicsData.push(this.currentPath);
this.dirty = true;
return this;
};
/**
@ -326,8 +310,6 @@ PIXI.Graphics.prototype.clear = function()
this.graphicsData = [];
this.bounds = null; //new PIXI.Rectangle();
return this;
};
/**

View file

@ -273,7 +273,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
// set the textures uvs temporarily
// TODO create a separate texture so that we can tile part of a texture
if(!tilingSprite._uvs)tilingSprite._uvs = new PIXI.TextureUvs();
if(!tilingSprite._uvs)tilingSprite._uvs = new Float32Array(8);
var uvs = tilingSprite._uvs;
@ -298,6 +298,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
uvs.x3 = 0 - offsetX;
uvs.y3 = (1 *scaleY) - offsetY;
// get the tilingSprites current alpha
var alpha = tilingSprite.worldAlpha;
var tint = tilingSprite.tint;

View file

@ -167,16 +167,6 @@ PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
return baseTexture;
};
/**
* Helper function that returns a base texture based on a canvas element
* If the image is not in the base texture cache it will be created and loaded
*
* @static
* @method fromCanvas
* @param canvas {Canvas} The canvas element source of the texture
* @param scaleMode {Number} Should be one of the PIXI.scaleMode consts
* @return BaseTexture
*/
PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode)
{
if(!canvas._pixiId)

View file

@ -155,7 +155,6 @@ PIXI.Texture.prototype._updateWebGLuvs = function()
* @method fromImage
* @param imageUrl {String} The image url of the texture
* @param crossorigin {Boolean} Whether requests should be treated as crossorigin
* @param scaleMode {Number} Should be one of the PIXI.scaleMode consts
* @return Texture
*/
PIXI.Texture.fromImage = function(imageUrl, crossorigin, scaleMode)
@ -194,7 +193,6 @@ PIXI.Texture.fromFrame = function(frameId)
* @static
* @method fromCanvas
* @param canvas {Canvas} The canvas element source of the texture
* @param scaleMode {Number} Should be one of the PIXI.scaleMode consts
* @return Texture
*/
PIXI.Texture.fromCanvas = function(canvas, scaleMode)

View file

@ -11,11 +11,11 @@
* @param width=800 {Number} the width of the renderers view
* @param height=600 {Number} the height of the renderers view
* @param [view] {Canvas} the canvas to use as a view, optional
* @param [transparent=false] {Boolean} the transparency of the render view, default false
* @param [antialias=false] {Boolean} sets antialias (only applicable in webGL chrome at the moment)
* @param [transparent=false] {Boolean} the transparency of the render view, default false
*
*/
PIXI.autoDetectRenderer = function(width, height, view, transparent, antialias)
PIXI.autoDetectRenderer = function(width, height, view,antialias,transparent)
{
if(!width)width = 800;
if(!height)height = 600;

View file

@ -11,7 +11,7 @@
* Adds event emitter functionality to a class
*
* @class EventTarget
* @example
*
* function MyEmitter() {
* PIXI.EventTarget.call(this); //mixes in event target stuff
* }

View file

@ -57,8 +57,8 @@ module.exports = function(config) {
browsers : ['Firefox'],
// If browser does not capture in given timeout [ms], kill it
// CLI --capture-timeout 60000
captureTimeout : 60000,
// CLI --capture-timeout 5000
captureTimeout : 5000,
// Auto run tests on start (when browsers are captured) and exit
// CLI --single-run --no-single-run