#

API Docs for: 1.4.3
Show: Inherited Protected Private Deprecated

# File: src/pixi/filters/CrossHatchFilter.js

    /**
     * @author Mat Groves http://matgroves.com/ @Doormat23
     */

    PIXI.CrossHatchFilter = function()
    {
        PIXI.AbstractFilter.call( this );

        this.passes = [this];

        // set the uniforms
        this.uniforms = {
            blur: {type: '1f', value: 1 / 512},
        };

        this.fragmentSrc = [
            'precision mediump float;',
            'varying vec2 vTextureCoord;',
            'varying vec4 vColor;',
            'uniform float blur;',
            'uniform sampler2D uSampler;',

            'void main(void) {',
            '    float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);',

            '    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);',

            '    if (lum < 1.00) {',
            '        if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {',
            '            gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);',
            '        }',
            '    }',

            '    if (lum < 0.75) {',
            '        if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {',
            '            gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);',
            '        }',
            '    }',

            '    if (lum < 0.50) {',
            '        if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {',
            '            gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);',
            '        }',
            '    }',

            '    if (lum < 0.3) {',
            '        if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {',
            '            gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);',
            '        }',
            '    }',
            '}'
        ];
    };

    PIXI.CrossHatchFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
    PIXI.CrossHatchFilter.prototype.constructor = PIXI.BlurYFilter;

    Object.defineProperty(PIXI.CrossHatchFilter.prototype, 'blur', {
        get: function() {
            return this.uniforms.blur.value / (1/7000);
        },
        set: function(value) {
            //this.padding = value;
            this.uniforms.blur.value = (1/7000) * value;
        }
    });