diff --git a/src/pixi/filters/ColorStepFilter.js b/src/pixi/filters/ColorStepFilter.js index ebf040b..d891db8 100644 --- a/src/pixi/filters/ColorStepFilter.js +++ b/src/pixi/filters/ColorStepFilter.js @@ -6,7 +6,7 @@ /** * * This turns your displayObjects to black and white. - * @class GreyFilter + * @class ColorStepFilter * @contructor */ PIXI.ColorStepFilter = function() diff --git a/src/pixi/filters/ColorStepFilter.js b/src/pixi/filters/ColorStepFilter.js index ebf040b..d891db8 100644 --- a/src/pixi/filters/ColorStepFilter.js +++ b/src/pixi/filters/ColorStepFilter.js @@ -6,7 +6,7 @@ /** * * This turns your displayObjects to black and white. - * @class GreyFilter + * @class ColorStepFilter * @contructor */ PIXI.ColorStepFilter = function() diff --git a/src/pixi/filters/GrayFilter.js b/src/pixi/filters/GrayFilter.js new file mode 100644 index 0000000..a39888f --- /dev/null +++ b/src/pixi/filters/GrayFilter.js @@ -0,0 +1,51 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + +/** + * + * This turns your displayObjects to black and white. + * @class GrayFilter + * @contructor + */ +PIXI.GrayFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + this.uniforms = { + gray: {type: 'f', value: 1}, + }; + + this.fragmentSrc = [ + "precision mediump float;", + "varying vec2 vTextureCoord;", + "varying float vColor;", + "uniform sampler2D uSampler;", + "uniform float gray;", + "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), gray);", + "gl_FragColor = gl_FragColor * vColor;", + "}" + ]; +} + +PIXI.GrayFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.GrayFilter.prototype.constructor = PIXI.GrayFilter; + +/** +The strength of the gray. 1 will make the object black and white, 0 will make the object its normal color +@property gray +*/ +Object.defineProperty(PIXI.GrayFilter.prototype, 'gray', { + get: function() { + return this.uniforms.gray.value; + }, + set: function(value) { + this.uniforms.gray.value = value; + } +}); diff --git a/src/pixi/filters/ColorStepFilter.js b/src/pixi/filters/ColorStepFilter.js index ebf040b..d891db8 100644 --- a/src/pixi/filters/ColorStepFilter.js +++ b/src/pixi/filters/ColorStepFilter.js @@ -6,7 +6,7 @@ /** * * This turns your displayObjects to black and white. - * @class GreyFilter + * @class ColorStepFilter * @contructor */ PIXI.ColorStepFilter = function() diff --git a/src/pixi/filters/GrayFilter.js b/src/pixi/filters/GrayFilter.js new file mode 100644 index 0000000..a39888f --- /dev/null +++ b/src/pixi/filters/GrayFilter.js @@ -0,0 +1,51 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + +/** + * + * This turns your displayObjects to black and white. + * @class GrayFilter + * @contructor + */ +PIXI.GrayFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + this.uniforms = { + gray: {type: 'f', value: 1}, + }; + + this.fragmentSrc = [ + "precision mediump float;", + "varying vec2 vTextureCoord;", + "varying float vColor;", + "uniform sampler2D uSampler;", + "uniform float gray;", + "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), gray);", + "gl_FragColor = gl_FragColor * vColor;", + "}" + ]; +} + +PIXI.GrayFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.GrayFilter.prototype.constructor = PIXI.GrayFilter; + +/** +The strength of the gray. 1 will make the object black and white, 0 will make the object its normal color +@property gray +*/ +Object.defineProperty(PIXI.GrayFilter.prototype, 'gray', { + get: function() { + return this.uniforms.gray.value; + }, + set: function(value) { + this.uniforms.gray.value = value; + } +}); diff --git a/src/pixi/filters/GreyFilter.js b/src/pixi/filters/GreyFilter.js deleted file mode 100644 index d182975..0000000 --- a/src/pixi/filters/GreyFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - */ - - -/** - * - * 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; - } -});