Tweaking filters

Doc update
This commit is contained in:
Mat Groves 2013-12-03 10:48:01 +00:00
parent d7ce761608
commit b5a2216788
23 changed files with 77 additions and 72 deletions

View file

@ -805,6 +805,8 @@ PIXI.DisplayObject = function()
*/ */
this._interactive = false; this._interactive = false;
this.defaultCursor = "pointer";
/** /**
* [read-only] Current transform of the object based on world (parent) factors * [read-only] Current transform of the object based on world (parent) factors
* *
@ -2673,7 +2675,7 @@ PIXI.InteractionManager.prototype.update = function()
// loks like there was a hit! // loks like there was a hit!
if(item.__hit) if(item.__hit)
{ {
if(item.buttonMode) this.interactionDOMElement.style.cursor = "pointer"; if(item.buttonMode) this.interactionDOMElement.style.cursor = item.defaultCursor;
if(!item.__isOver) if(!item.__isOver)
{ {
@ -3865,6 +3867,11 @@ PIXI.PixiShader.prototype.syncUniforms = function()
// console.log(this.program[key]) // console.log(this.program[key])
gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y); gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y);
} }
if(type == "f3")
{
// console.log(this.program[key])
gl.uniform3fv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if(type == "f4") else if(type == "f4")
{ {
// console.log(this.uniforms[key].value) // console.log(this.uniforms[key].value)
@ -6586,7 +6593,14 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
var texture = this.texturePool.pop(); var texture = this.texturePool.pop();
if(!texture)texture = new PIXI.FilterTexture(this.width, this.height); if(!texture)
{
texture = new PIXI.FilterTexture(this.width, this.height);
}
else
{
texture.resize(this.width, this.height);
}
gl.bindTexture(gl.TEXTURE_2D, texture.texture); gl.bindTexture(gl.TEXTURE_2D, texture.texture);
@ -6604,9 +6618,9 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
filterArea.height += padidng * 2; filterArea.height += padidng * 2;
// cap filter to screen size.. // cap filter to screen size..
if(filterArea.x < 0)filterArea.x = 0; //if(filterArea.x < 0)filterArea.x = 0;
if(filterArea.width > this.width)filterArea.width = this.width; if(filterArea.width > this.width)filterArea.width = this.width;
if(filterArea.y < 0)filterArea.y = 0; //if(filterArea.y < 0)filterArea.y = 0;
if(filterArea.height > this.height)filterArea.height = this.height; if(filterArea.height > this.height)filterArea.height = this.height;
@ -7049,6 +7063,8 @@ PIXI.FilterTexture = function(width, height)
PIXI.FilterTexture.prototype.resize = function(width, height) PIXI.FilterTexture.prototype.resize = function(width, height)
{ {
if(this.width == width && this.height == height)return;
this.width = width; this.width = width;
this.height = height; this.height = height;
@ -9980,6 +9996,19 @@ PIXI.BaseTexture.prototype.destroy = function()
PIXI.texturesToDestroy.push(this); PIXI.texturesToDestroy.push(this);
} }
/**
*
*
* @method destroy
*/
PIXI.BaseTexture.prototype.updateSourceImage = function(newSrc)
{
this.hasLoaded = false;
this.source.src = null;
this.source.src = newSrc;
}
/** /**
* Helper function that returns a base texture based on an image url * Helper function that returns a base texture based on an image url
* If the image is not in the base texture cache it will be created and loaded * If the image is not in the base texture cache it will be created and loaded
@ -10558,7 +10587,7 @@ PIXI.AssetLoader.prototype.load = function()
for (var i=0; i < this.assetURLs.length; i++) for (var i=0; i < this.assetURLs.length; i++)
{ {
var fileName = this.assetURLs[i]; var fileName = this.assetURLs[i];
var fileType = fileName.split(".").pop().toLowerCase(); var fileType = fileName.split("?").shift().split(".").pop().toLowerCase();
var loaderClass = this.loadersByType[fileType]; var loaderClass = this.loadersByType[fileType];
if(!loaderClass) if(!loaderClass)
@ -11374,58 +11403,6 @@ Object.defineProperty(PIXI.ColorMatrixFilter.prototype, 'matrix', {
*/ */
/**
*
* This turns your displayObjects to black and white.
* @class GreyFilter
* @contructor
*/
PIXI.GreyFilter = function()
{
PIXI.AbstractFilter.call( this );
this.passes = [this];
// set the uniforms
this.uniforms = {
grey: {type: 'f', value: 1},
};
this.fragmentSrc = [
"precision mediump float;",
"varying vec2 vTextureCoord;",
"varying float vColor;",
"uniform sampler2D uSampler;",
"uniform float grey;",
"void main(void) {",
"gl_FragColor = texture2D(uSampler, vTextureCoord);",
"gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), grey);",
"gl_FragColor = gl_FragColor * vColor;",
"}"
];
}
PIXI.GreyFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
PIXI.GreyFilter.prototype.constructor = PIXI.GreyFilter;
/**
The strength of the grey. 1 will make the object black and white, 0 will make the object its normal color
@property grey
*/
Object.defineProperty(PIXI.GreyFilter.prototype, 'grey', {
get: function() {
return this.uniforms.grey.value;
},
set: function(value) {
this.uniforms.grey.value = value;
}
});
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
/** /**
* *
* The DisplacementFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. * The DisplacementFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object.
@ -12020,7 +11997,7 @@ Object.defineProperty(PIXI.TwistFilter.prototype, 'angle', {
/** /**
* *
* This turns your displayObjects to black and white. * This turns your displayObjects to black and white.
* @class GreyFilter * @class ColorStepFilter
* @contructor * @contructor
*/ */
PIXI.ColorStepFilter = function() PIXI.ColorStepFilter = function()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

0
docs/assets/css/external-small.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 491 B

Before After
Before After

0
docs/assets/css/logo.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Before After
Before After

0
docs/assets/favicon.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 740 B

After

Width:  |  Height:  |  Size: 740 B

Before After
Before After

0
docs/assets/img/spinner.gif Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before After
Before After

0
docs/assets/index.html Normal file → Executable file
View file

0
docs/assets/js/api-filter.js Normal file → Executable file
View file

0
docs/assets/js/api-list.js Normal file → Executable file
View file

0
docs/assets/js/api-search.js Normal file → Executable file
View file

0
docs/assets/js/apidocs.js Normal file → Executable file
View file

0
docs/assets/js/yui-prettify.js vendored Normal file → Executable file
View file

0
docs/assets/vendor/prettify/CHANGES.html vendored Normal file → Executable file
View file

0
docs/assets/vendor/prettify/COPYING vendored Normal file → Executable file
View file

0
docs/assets/vendor/prettify/README.html vendored Normal file → Executable file
View file

0
docs/assets/vendor/prettify/prettify-min.css vendored Normal file → Executable file
View file

0
docs/assets/vendor/prettify/prettify-min.js vendored Normal file → Executable file
View file

View file

@ -246,7 +246,7 @@ PIXI.InteractionManager.prototype.update = function()
// loks like there was a hit! // loks like there was a hit!
if(item.__hit) if(item.__hit)
{ {
if(item.buttonMode) this.interactionDOMElement.style.cursor = "pointer"; if(item.buttonMode) this.interactionDOMElement.style.cursor = item.defaultCursor;
if(!item.__isOver) if(!item.__isOver)
{ {

View file

@ -122,6 +122,8 @@ PIXI.DisplayObject = function()
*/ */
this._interactive = false; this._interactive = false;
this.defaultCursor = "pointer";
/** /**
* [read-only] Current transform of the object based on world (parent) factors * [read-only] Current transform of the object based on world (parent) factors
* *

View file

@ -72,6 +72,11 @@ PIXI.PixiShader.prototype.syncUniforms = function()
// console.log(this.program[key]) // console.log(this.program[key])
gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y); gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y);
} }
if(type == "f3")
{
// console.log(this.program[key])
gl.uniform3fv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if(type == "f4") else if(type == "f4")
{ {
// console.log(this.uniforms[key].value) // console.log(this.uniforms[key].value)

View file

@ -45,7 +45,14 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
var texture = this.texturePool.pop(); var texture = this.texturePool.pop();
if(!texture)texture = new PIXI.FilterTexture(this.width, this.height); if(!texture)
{
texture = new PIXI.FilterTexture(this.width, this.height);
}
else
{
texture.resize(this.width, this.height);
}
gl.bindTexture(gl.TEXTURE_2D, texture.texture); gl.bindTexture(gl.TEXTURE_2D, texture.texture);
@ -63,9 +70,9 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
filterArea.height += padidng * 2; filterArea.height += padidng * 2;
// cap filter to screen size.. // cap filter to screen size..
if(filterArea.x < 0)filterArea.x = 0; //if(filterArea.x < 0)filterArea.x = 0;
if(filterArea.width > this.width)filterArea.width = this.width; if(filterArea.width > this.width)filterArea.width = this.width;
if(filterArea.y < 0)filterArea.y = 0; //if(filterArea.y < 0)filterArea.y = 0;
if(filterArea.height > this.height)filterArea.height = this.height; if(filterArea.height > this.height)filterArea.height = this.height;
@ -508,6 +515,8 @@ PIXI.FilterTexture = function(width, height)
PIXI.FilterTexture.prototype.resize = function(width, height) PIXI.FilterTexture.prototype.resize = function(width, height)
{ {
if(this.width == width && this.height == height)return;
this.width = width; this.width = width;
this.height = height; this.height = height;

View file

@ -111,6 +111,19 @@ PIXI.BaseTexture.prototype.destroy = function()
PIXI.texturesToDestroy.push(this); PIXI.texturesToDestroy.push(this);
} }
/**
*
*
* @method destroy
*/
PIXI.BaseTexture.prototype.updateSourceImage = function(newSrc)
{
this.hasLoaded = false;
this.source.src = null;
this.source.src = newSrc;
}
/** /**
* Helper function that returns a base texture based on an image url * Helper function that returns a base texture based on an image url
* If the image is not in the base texture cache it will be created and loaded * If the image is not in the base texture cache it will be created and loaded