Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/filter-blur

Package Overview
Dependencies
Maintainers
3
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/filter-blur - npm Package Compare versions

Comparing version 6.5.3 to 7.0.0-alpha

1072

dist/cjs/filter-blur.js
/*!
* @pixi/filter-blur - v6.5.3
* Compiled Fri, 09 Sep 2022 13:55:20 UTC
* @pixi/filter-blur - v7.0.0-alpha
* Compiled Fri, 09 Sep 2022 16:09:18 UTC
*

@@ -13,876 +13,232 @@ * @pixi/filter-blur is licensed under the MIT License.

var core = require('@pixi/core');
var settings = require('@pixi/settings');
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
const vertTemplate = `
attribute vec2 aVertexPosition;
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
uniform mat3 projectionMatrix;
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
uniform float strength;
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };
return extendStatics(d, b);
};
varying vec2 vBlurTexCoords[%size%];
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
uniform vec4 inputSize;
uniform vec4 outputFrame;
var vertTemplate = "\n attribute vec2 aVertexPosition;\n\n uniform mat3 projectionMatrix;\n\n uniform float strength;\n\n varying vec2 vBlurTexCoords[%size%];\n\n uniform vec4 inputSize;\n uniform vec4 outputFrame;\n\n vec4 filterVertexPosition( void )\n {\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n }\n\n vec2 filterTextureCoord( void )\n {\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n }\n\n void main(void)\n {\n gl_Position = filterVertexPosition();\n\n vec2 textureCoord = filterTextureCoord();\n %blur%\n }";
function generateBlurVertSource(kernelSize, x) {
var halfLength = Math.ceil(kernelSize / 2);
var vertSource = vertTemplate;
var blurLoop = '';
var template;
if (x) {
template = 'vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);';
vec4 filterVertexPosition( void )
{
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
}
else {
template = 'vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);';
vec2 filterTextureCoord( void )
{
return aVertexPosition * (outputFrame.zw * inputSize.zw);
}
for (var i = 0; i < kernelSize; i++) {
var blur = template.replace('%index%', i.toString());
blur = blur.replace('%sampleIndex%', i - (halfLength - 1) + ".0");
blurLoop += blur;
blurLoop += '\n';
}
vertSource = vertSource.replace('%blur%', blurLoop);
vertSource = vertSource.replace('%size%', kernelSize.toString());
return vertSource;
void main(void)
{
gl_Position = filterVertexPosition();
vec2 textureCoord = filterTextureCoord();
%blur%
}`;
function generateBlurVertSource(kernelSize, x) {
const halfLength = Math.ceil(kernelSize / 2);
let vertSource = vertTemplate;
let blurLoop = "";
let template;
if (x) {
template = "vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);";
} else {
template = "vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";
}
for (let i = 0; i < kernelSize; i++) {
let blur = template.replace("%index%", i.toString());
blur = blur.replace("%sampleIndex%", `${i - (halfLength - 1)}.0`);
blurLoop += blur;
blurLoop += "\n";
}
vertSource = vertSource.replace("%blur%", blurLoop);
vertSource = vertSource.replace("%size%", kernelSize.toString());
return vertSource;
}
var GAUSSIAN_VALUES = {
5: [0.153388, 0.221461, 0.250301],
7: [0.071303, 0.131514, 0.189879, 0.214607],
9: [0.028532, 0.067234, 0.124009, 0.179044, 0.20236],
11: [0.0093, 0.028002, 0.065984, 0.121703, 0.175713, 0.198596],
13: [0.002406, 0.009255, 0.027867, 0.065666, 0.121117, 0.174868, 0.197641],
15: [0.000489, 0.002403, 0.009246, 0.02784, 0.065602, 0.120999, 0.174697, 0.197448],
const GAUSSIAN_VALUES = {
5: [0.153388, 0.221461, 0.250301],
7: [0.071303, 0.131514, 0.189879, 0.214607],
9: [0.028532, 0.067234, 0.124009, 0.179044, 0.20236],
11: [93e-4, 0.028002, 0.065984, 0.121703, 0.175713, 0.198596],
13: [2406e-6, 9255e-6, 0.027867, 0.065666, 0.121117, 0.174868, 0.197641],
15: [489e-6, 2403e-6, 9246e-6, 0.02784, 0.065602, 0.120999, 0.174697, 0.197448]
};
var fragTemplate = [
'varying vec2 vBlurTexCoords[%size%];',
'uniform sampler2D uSampler;',
'void main(void)',
'{',
' gl_FragColor = vec4(0.0);',
' %blur%',
'}' ].join('\n');
const fragTemplate = [
"varying vec2 vBlurTexCoords[%size%];",
"uniform sampler2D uSampler;",
"void main(void)",
"{",
" gl_FragColor = vec4(0.0);",
" %blur%",
"}"
].join("\n");
function generateBlurFragSource(kernelSize) {
var kernel = GAUSSIAN_VALUES[kernelSize];
var halfLength = kernel.length;
var fragSource = fragTemplate;
var blurLoop = '';
var template = 'gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;';
var value;
for (var i = 0; i < kernelSize; i++) {
var blur = template.replace('%index%', i.toString());
value = i;
if (i >= halfLength) {
value = kernelSize - i - 1;
}
blur = blur.replace('%value%', kernel[value].toString());
blurLoop += blur;
blurLoop += '\n';
const kernel = GAUSSIAN_VALUES[kernelSize];
const halfLength = kernel.length;
let fragSource = fragTemplate;
let blurLoop = "";
const template = "gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";
let value;
for (let i = 0; i < kernelSize; i++) {
let blur = template.replace("%index%", i.toString());
value = i;
if (i >= halfLength) {
value = kernelSize - i - 1;
}
fragSource = fragSource.replace('%blur%', blurLoop);
fragSource = fragSource.replace('%size%', kernelSize.toString());
return fragSource;
blur = blur.replace("%value%", kernel[value].toString());
blurLoop += blur;
blurLoop += "\n";
}
fragSource = fragSource.replace("%blur%", blurLoop);
fragSource = fragSource.replace("%size%", kernelSize.toString());
return fragSource;
}
/*!
* @pixi/constants - v6.5.3
* Compiled Fri, 09 Sep 2022 13:55:20 UTC
*
* @pixi/constants is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
/**
* Different types of environments for WebGL.
* @static
* @memberof PIXI
* @name ENV
* @enum {number}
* @property {number} WEBGL_LEGACY - Used for older v1 WebGL devices. PixiJS will aim to ensure compatibility
* with older / less advanced devices. If you experience unexplained flickering prefer this environment.
* @property {number} WEBGL - Version 1 of WebGL
* @property {number} WEBGL2 - Version 2 of WebGL
*/
var ENV;
(function (ENV) {
ENV[ENV["WEBGL_LEGACY"] = 0] = "WEBGL_LEGACY";
ENV[ENV["WEBGL"] = 1] = "WEBGL";
ENV[ENV["WEBGL2"] = 2] = "WEBGL2";
})(ENV || (ENV = {}));
/**
* Constant to identify the Renderer Type.
* @static
* @memberof PIXI
* @name RENDERER_TYPE
* @enum {number}
* @property {number} UNKNOWN - Unknown render type.
* @property {number} WEBGL - WebGL render type.
* @property {number} CANVAS - Canvas render type.
*/
var RENDERER_TYPE;
(function (RENDERER_TYPE) {
RENDERER_TYPE[RENDERER_TYPE["UNKNOWN"] = 0] = "UNKNOWN";
RENDERER_TYPE[RENDERER_TYPE["WEBGL"] = 1] = "WEBGL";
RENDERER_TYPE[RENDERER_TYPE["CANVAS"] = 2] = "CANVAS";
})(RENDERER_TYPE || (RENDERER_TYPE = {}));
/**
* Bitwise OR of masks that indicate the buffers to be cleared.
* @static
* @memberof PIXI
* @name BUFFER_BITS
* @enum {number}
* @property {number} COLOR - Indicates the buffers currently enabled for color writing.
* @property {number} DEPTH - Indicates the depth buffer.
* @property {number} STENCIL - Indicates the stencil buffer.
*/
var BUFFER_BITS;
(function (BUFFER_BITS) {
BUFFER_BITS[BUFFER_BITS["COLOR"] = 16384] = "COLOR";
BUFFER_BITS[BUFFER_BITS["DEPTH"] = 256] = "DEPTH";
BUFFER_BITS[BUFFER_BITS["STENCIL"] = 1024] = "STENCIL";
})(BUFFER_BITS || (BUFFER_BITS = {}));
/**
* Various blend modes supported by PIXI.
*
* IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.
* Anything else will silently act like NORMAL.
* @memberof PIXI
* @name BLEND_MODES
* @enum {number}
* @property {number} NORMAL -
* @property {number} ADD -
* @property {number} MULTIPLY -
* @property {number} SCREEN -
* @property {number} OVERLAY -
* @property {number} DARKEN -
* @property {number} LIGHTEN -
* @property {number} COLOR_DODGE -
* @property {number} COLOR_BURN -
* @property {number} HARD_LIGHT -
* @property {number} SOFT_LIGHT -
* @property {number} DIFFERENCE -
* @property {number} EXCLUSION -
* @property {number} HUE -
* @property {number} SATURATION -
* @property {number} COLOR -
* @property {number} LUMINOSITY -
* @property {number} NORMAL_NPM -
* @property {number} ADD_NPM -
* @property {number} SCREEN_NPM -
* @property {number} NONE -
* @property {number} SRC_IN -
* @property {number} SRC_OUT -
* @property {number} SRC_ATOP -
* @property {number} DST_OVER -
* @property {number} DST_IN -
* @property {number} DST_OUT -
* @property {number} DST_ATOP -
* @property {number} SUBTRACT -
* @property {number} SRC_OVER -
* @property {number} ERASE -
* @property {number} XOR -
*/
var BLEND_MODES;
(function (BLEND_MODES) {
BLEND_MODES[BLEND_MODES["NORMAL"] = 0] = "NORMAL";
BLEND_MODES[BLEND_MODES["ADD"] = 1] = "ADD";
BLEND_MODES[BLEND_MODES["MULTIPLY"] = 2] = "MULTIPLY";
BLEND_MODES[BLEND_MODES["SCREEN"] = 3] = "SCREEN";
BLEND_MODES[BLEND_MODES["OVERLAY"] = 4] = "OVERLAY";
BLEND_MODES[BLEND_MODES["DARKEN"] = 5] = "DARKEN";
BLEND_MODES[BLEND_MODES["LIGHTEN"] = 6] = "LIGHTEN";
BLEND_MODES[BLEND_MODES["COLOR_DODGE"] = 7] = "COLOR_DODGE";
BLEND_MODES[BLEND_MODES["COLOR_BURN"] = 8] = "COLOR_BURN";
BLEND_MODES[BLEND_MODES["HARD_LIGHT"] = 9] = "HARD_LIGHT";
BLEND_MODES[BLEND_MODES["SOFT_LIGHT"] = 10] = "SOFT_LIGHT";
BLEND_MODES[BLEND_MODES["DIFFERENCE"] = 11] = "DIFFERENCE";
BLEND_MODES[BLEND_MODES["EXCLUSION"] = 12] = "EXCLUSION";
BLEND_MODES[BLEND_MODES["HUE"] = 13] = "HUE";
BLEND_MODES[BLEND_MODES["SATURATION"] = 14] = "SATURATION";
BLEND_MODES[BLEND_MODES["COLOR"] = 15] = "COLOR";
BLEND_MODES[BLEND_MODES["LUMINOSITY"] = 16] = "LUMINOSITY";
BLEND_MODES[BLEND_MODES["NORMAL_NPM"] = 17] = "NORMAL_NPM";
BLEND_MODES[BLEND_MODES["ADD_NPM"] = 18] = "ADD_NPM";
BLEND_MODES[BLEND_MODES["SCREEN_NPM"] = 19] = "SCREEN_NPM";
BLEND_MODES[BLEND_MODES["NONE"] = 20] = "NONE";
BLEND_MODES[BLEND_MODES["SRC_OVER"] = 0] = "SRC_OVER";
BLEND_MODES[BLEND_MODES["SRC_IN"] = 21] = "SRC_IN";
BLEND_MODES[BLEND_MODES["SRC_OUT"] = 22] = "SRC_OUT";
BLEND_MODES[BLEND_MODES["SRC_ATOP"] = 23] = "SRC_ATOP";
BLEND_MODES[BLEND_MODES["DST_OVER"] = 24] = "DST_OVER";
BLEND_MODES[BLEND_MODES["DST_IN"] = 25] = "DST_IN";
BLEND_MODES[BLEND_MODES["DST_OUT"] = 26] = "DST_OUT";
BLEND_MODES[BLEND_MODES["DST_ATOP"] = 27] = "DST_ATOP";
BLEND_MODES[BLEND_MODES["ERASE"] = 26] = "ERASE";
BLEND_MODES[BLEND_MODES["SUBTRACT"] = 28] = "SUBTRACT";
BLEND_MODES[BLEND_MODES["XOR"] = 29] = "XOR";
})(BLEND_MODES || (BLEND_MODES = {}));
/**
* Various webgl draw modes. These can be used to specify which GL drawMode to use
* under certain situations and renderers.
* @memberof PIXI
* @static
* @name DRAW_MODES
* @enum {number}
* @property {number} POINTS -
* @property {number} LINES -
* @property {number} LINE_LOOP -
* @property {number} LINE_STRIP -
* @property {number} TRIANGLES -
* @property {number} TRIANGLE_STRIP -
* @property {number} TRIANGLE_FAN -
*/
var DRAW_MODES;
(function (DRAW_MODES) {
DRAW_MODES[DRAW_MODES["POINTS"] = 0] = "POINTS";
DRAW_MODES[DRAW_MODES["LINES"] = 1] = "LINES";
DRAW_MODES[DRAW_MODES["LINE_LOOP"] = 2] = "LINE_LOOP";
DRAW_MODES[DRAW_MODES["LINE_STRIP"] = 3] = "LINE_STRIP";
DRAW_MODES[DRAW_MODES["TRIANGLES"] = 4] = "TRIANGLES";
DRAW_MODES[DRAW_MODES["TRIANGLE_STRIP"] = 5] = "TRIANGLE_STRIP";
DRAW_MODES[DRAW_MODES["TRIANGLE_FAN"] = 6] = "TRIANGLE_FAN";
})(DRAW_MODES || (DRAW_MODES = {}));
/**
* Various GL texture/resources formats.
* @memberof PIXI
* @static
* @name FORMATS
* @enum {number}
* @property {number} [RGBA=6408] -
* @property {number} [RGB=6407] -
* @property {number} [RG=33319] -
* @property {number} [RED=6403] -
* @property {number} [RGBA_INTEGER=36249] -
* @property {number} [RGB_INTEGER=36248] -
* @property {number} [RG_INTEGER=33320] -
* @property {number} [RED_INTEGER=36244] -
* @property {number} [ALPHA=6406] -
* @property {number} [LUMINANCE=6409] -
* @property {number} [LUMINANCE_ALPHA=6410] -
* @property {number} [DEPTH_COMPONENT=6402] -
* @property {number} [DEPTH_STENCIL=34041] -
*/
var FORMATS;
(function (FORMATS) {
FORMATS[FORMATS["RGBA"] = 6408] = "RGBA";
FORMATS[FORMATS["RGB"] = 6407] = "RGB";
FORMATS[FORMATS["RG"] = 33319] = "RG";
FORMATS[FORMATS["RED"] = 6403] = "RED";
FORMATS[FORMATS["RGBA_INTEGER"] = 36249] = "RGBA_INTEGER";
FORMATS[FORMATS["RGB_INTEGER"] = 36248] = "RGB_INTEGER";
FORMATS[FORMATS["RG_INTEGER"] = 33320] = "RG_INTEGER";
FORMATS[FORMATS["RED_INTEGER"] = 36244] = "RED_INTEGER";
FORMATS[FORMATS["ALPHA"] = 6406] = "ALPHA";
FORMATS[FORMATS["LUMINANCE"] = 6409] = "LUMINANCE";
FORMATS[FORMATS["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
FORMATS[FORMATS["DEPTH_COMPONENT"] = 6402] = "DEPTH_COMPONENT";
FORMATS[FORMATS["DEPTH_STENCIL"] = 34041] = "DEPTH_STENCIL";
})(FORMATS || (FORMATS = {}));
/**
* Various GL target types.
* @memberof PIXI
* @static
* @name TARGETS
* @enum {number}
* @property {number} [TEXTURE_2D=3553] -
* @property {number} [TEXTURE_CUBE_MAP=34067] -
* @property {number} [TEXTURE_2D_ARRAY=35866] -
* @property {number} [TEXTURE_CUBE_MAP_POSITIVE_X=34069] -
* @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_X=34070] -
* @property {number} [TEXTURE_CUBE_MAP_POSITIVE_Y=34071] -
* @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_Y=34072] -
* @property {number} [TEXTURE_CUBE_MAP_POSITIVE_Z=34073] -
* @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_Z=34074] -
*/
var TARGETS;
(function (TARGETS) {
TARGETS[TARGETS["TEXTURE_2D"] = 3553] = "TEXTURE_2D";
TARGETS[TARGETS["TEXTURE_CUBE_MAP"] = 34067] = "TEXTURE_CUBE_MAP";
TARGETS[TARGETS["TEXTURE_2D_ARRAY"] = 35866] = "TEXTURE_2D_ARRAY";
TARGETS[TARGETS["TEXTURE_CUBE_MAP_POSITIVE_X"] = 34069] = "TEXTURE_CUBE_MAP_POSITIVE_X";
TARGETS[TARGETS["TEXTURE_CUBE_MAP_NEGATIVE_X"] = 34070] = "TEXTURE_CUBE_MAP_NEGATIVE_X";
TARGETS[TARGETS["TEXTURE_CUBE_MAP_POSITIVE_Y"] = 34071] = "TEXTURE_CUBE_MAP_POSITIVE_Y";
TARGETS[TARGETS["TEXTURE_CUBE_MAP_NEGATIVE_Y"] = 34072] = "TEXTURE_CUBE_MAP_NEGATIVE_Y";
TARGETS[TARGETS["TEXTURE_CUBE_MAP_POSITIVE_Z"] = 34073] = "TEXTURE_CUBE_MAP_POSITIVE_Z";
TARGETS[TARGETS["TEXTURE_CUBE_MAP_NEGATIVE_Z"] = 34074] = "TEXTURE_CUBE_MAP_NEGATIVE_Z";
})(TARGETS || (TARGETS = {}));
/**
* Various GL data format types.
* @memberof PIXI
* @static
* @name TYPES
* @enum {number}
* @property {number} [UNSIGNED_BYTE=5121] -
* @property {number} [UNSIGNED_SHORT=5123] -
* @property {number} [UNSIGNED_SHORT_5_6_5=33635] -
* @property {number} [UNSIGNED_SHORT_4_4_4_4=32819] -
* @property {number} [UNSIGNED_SHORT_5_5_5_1=32820] -
* @property {number} [UNSIGNED_INT=5125] -
* @property {number} [UNSIGNED_INT_10F_11F_11F_REV=35899] -
* @property {number} [UNSIGNED_INT_2_10_10_10_REV=33640] -
* @property {number} [UNSIGNED_INT_24_8=34042] -
* @property {number} [UNSIGNED_INT_5_9_9_9_REV=35902] -
* @property {number} [BYTE=5120] -
* @property {number} [SHORT=5122] -
* @property {number} [INT=5124] -
* @property {number} [FLOAT=5126] -
* @property {number} [FLOAT_32_UNSIGNED_INT_24_8_REV=36269] -
* @property {number} [HALF_FLOAT=36193] -
*/
var TYPES;
(function (TYPES) {
TYPES[TYPES["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
TYPES[TYPES["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
TYPES[TYPES["UNSIGNED_SHORT_5_6_5"] = 33635] = "UNSIGNED_SHORT_5_6_5";
TYPES[TYPES["UNSIGNED_SHORT_4_4_4_4"] = 32819] = "UNSIGNED_SHORT_4_4_4_4";
TYPES[TYPES["UNSIGNED_SHORT_5_5_5_1"] = 32820] = "UNSIGNED_SHORT_5_5_5_1";
TYPES[TYPES["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
TYPES[TYPES["UNSIGNED_INT_10F_11F_11F_REV"] = 35899] = "UNSIGNED_INT_10F_11F_11F_REV";
TYPES[TYPES["UNSIGNED_INT_2_10_10_10_REV"] = 33640] = "UNSIGNED_INT_2_10_10_10_REV";
TYPES[TYPES["UNSIGNED_INT_24_8"] = 34042] = "UNSIGNED_INT_24_8";
TYPES[TYPES["UNSIGNED_INT_5_9_9_9_REV"] = 35902] = "UNSIGNED_INT_5_9_9_9_REV";
TYPES[TYPES["BYTE"] = 5120] = "BYTE";
TYPES[TYPES["SHORT"] = 5122] = "SHORT";
TYPES[TYPES["INT"] = 5124] = "INT";
TYPES[TYPES["FLOAT"] = 5126] = "FLOAT";
TYPES[TYPES["FLOAT_32_UNSIGNED_INT_24_8_REV"] = 36269] = "FLOAT_32_UNSIGNED_INT_24_8_REV";
TYPES[TYPES["HALF_FLOAT"] = 36193] = "HALF_FLOAT";
})(TYPES || (TYPES = {}));
/**
* Various sampler types. Correspond to `sampler`, `isampler`, `usampler` GLSL types respectively.
* WebGL1 works only with FLOAT.
* @memberof PIXI
* @static
* @name SAMPLER_TYPES
* @enum {number}
* @property {number} [FLOAT=0] -
* @property {number} [INT=1] -
* @property {number} [UINT=2] -
*/
var SAMPLER_TYPES;
(function (SAMPLER_TYPES) {
SAMPLER_TYPES[SAMPLER_TYPES["FLOAT"] = 0] = "FLOAT";
SAMPLER_TYPES[SAMPLER_TYPES["INT"] = 1] = "INT";
SAMPLER_TYPES[SAMPLER_TYPES["UINT"] = 2] = "UINT";
})(SAMPLER_TYPES || (SAMPLER_TYPES = {}));
/**
* The scale modes that are supported by pixi.
*
* The {@link PIXI.settings.SCALE_MODE} scale mode affects the default scaling mode of future operations.
* It can be re-assigned to either LINEAR or NEAREST, depending upon suitability.
* @memberof PIXI
* @static
* @name SCALE_MODES
* @enum {number}
* @property {number} LINEAR Smooth scaling
* @property {number} NEAREST Pixelating scaling
*/
var SCALE_MODES;
(function (SCALE_MODES) {
SCALE_MODES[SCALE_MODES["NEAREST"] = 0] = "NEAREST";
SCALE_MODES[SCALE_MODES["LINEAR"] = 1] = "LINEAR";
})(SCALE_MODES || (SCALE_MODES = {}));
/**
* The wrap modes that are supported by pixi.
*
* The {@link PIXI.settings.WRAP_MODE} wrap mode affects the default wrapping mode of future operations.
* It can be re-assigned to either CLAMP or REPEAT, depending upon suitability.
* If the texture is non power of two then clamp will be used regardless as WebGL can
* only use REPEAT if the texture is po2.
*
* This property only affects WebGL.
* @name WRAP_MODES
* @memberof PIXI
* @static
* @enum {number}
* @property {number} CLAMP - The textures uvs are clamped
* @property {number} REPEAT - The texture uvs tile and repeat
* @property {number} MIRRORED_REPEAT - The texture uvs tile and repeat with mirroring
*/
var WRAP_MODES;
(function (WRAP_MODES) {
WRAP_MODES[WRAP_MODES["CLAMP"] = 33071] = "CLAMP";
WRAP_MODES[WRAP_MODES["REPEAT"] = 10497] = "REPEAT";
WRAP_MODES[WRAP_MODES["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT";
})(WRAP_MODES || (WRAP_MODES = {}));
/**
* Mipmap filtering modes that are supported by pixi.
*
* The {@link PIXI.settings.MIPMAP_TEXTURES} affects default texture filtering.
* Mipmaps are generated for a baseTexture if its `mipmap` field is `ON`,
* or its `POW2` and texture dimensions are powers of 2.
* Due to platform restriction, `ON` option will work like `POW2` for webgl-1.
*
* This property only affects WebGL.
* @name MIPMAP_MODES
* @memberof PIXI
* @static
* @enum {number}
* @property {number} OFF - No mipmaps
* @property {number} POW2 - Generate mipmaps if texture dimensions are pow2
* @property {number} ON - Always generate mipmaps
* @property {number} ON_MANUAL - Use mipmaps, but do not auto-generate them; this is used with a resource
* that supports buffering each level-of-detail.
*/
var MIPMAP_MODES;
(function (MIPMAP_MODES) {
MIPMAP_MODES[MIPMAP_MODES["OFF"] = 0] = "OFF";
MIPMAP_MODES[MIPMAP_MODES["POW2"] = 1] = "POW2";
MIPMAP_MODES[MIPMAP_MODES["ON"] = 2] = "ON";
MIPMAP_MODES[MIPMAP_MODES["ON_MANUAL"] = 3] = "ON_MANUAL";
})(MIPMAP_MODES || (MIPMAP_MODES = {}));
/**
* How to treat textures with premultiplied alpha
* @name ALPHA_MODES
* @memberof PIXI
* @static
* @enum {number}
* @property {number} NO_PREMULTIPLIED_ALPHA - Source is not premultiplied, leave it like that.
* Option for compressed and data textures that are created from typed arrays.
* @property {number} PREMULTIPLY_ON_UPLOAD - Source is not premultiplied, premultiply on upload.
* Default option, used for all loaded images.
* @property {number} PREMULTIPLIED_ALPHA - Source is already premultiplied
* Example: spine atlases with `_pma` suffix.
* @property {number} NPM - Alias for NO_PREMULTIPLIED_ALPHA.
* @property {number} UNPACK - Default option, alias for PREMULTIPLY_ON_UPLOAD.
* @property {number} PMA - Alias for PREMULTIPLIED_ALPHA.
*/
var ALPHA_MODES;
(function (ALPHA_MODES) {
ALPHA_MODES[ALPHA_MODES["NPM"] = 0] = "NPM";
ALPHA_MODES[ALPHA_MODES["UNPACK"] = 1] = "UNPACK";
ALPHA_MODES[ALPHA_MODES["PMA"] = 2] = "PMA";
ALPHA_MODES[ALPHA_MODES["NO_PREMULTIPLIED_ALPHA"] = 0] = "NO_PREMULTIPLIED_ALPHA";
ALPHA_MODES[ALPHA_MODES["PREMULTIPLY_ON_UPLOAD"] = 1] = "PREMULTIPLY_ON_UPLOAD";
ALPHA_MODES[ALPHA_MODES["PREMULTIPLY_ALPHA"] = 2] = "PREMULTIPLY_ALPHA";
ALPHA_MODES[ALPHA_MODES["PREMULTIPLIED_ALPHA"] = 2] = "PREMULTIPLIED_ALPHA";
})(ALPHA_MODES || (ALPHA_MODES = {}));
/**
* Configure whether filter textures are cleared after binding.
*
* Filter textures need not be cleared if the filter does not use pixel blending. {@link CLEAR_MODES.BLIT} will detect
* this and skip clearing as an optimization.
* @name CLEAR_MODES
* @memberof PIXI
* @static
* @enum {number}
* @property {number} BLEND - Do not clear the filter texture. The filter's output will blend on top of the output texture.
* @property {number} CLEAR - Always clear the filter texture.
* @property {number} BLIT - Clear only if {@link FilterSystem.forceClear} is set or if the filter uses pixel blending.
* @property {number} NO - Alias for BLEND, same as `false` in earlier versions
* @property {number} YES - Alias for CLEAR, same as `true` in earlier versions
* @property {number} AUTO - Alias for BLIT
*/
var CLEAR_MODES;
(function (CLEAR_MODES) {
CLEAR_MODES[CLEAR_MODES["NO"] = 0] = "NO";
CLEAR_MODES[CLEAR_MODES["YES"] = 1] = "YES";
CLEAR_MODES[CLEAR_MODES["AUTO"] = 2] = "AUTO";
CLEAR_MODES[CLEAR_MODES["BLEND"] = 0] = "BLEND";
CLEAR_MODES[CLEAR_MODES["CLEAR"] = 1] = "CLEAR";
CLEAR_MODES[CLEAR_MODES["BLIT"] = 2] = "BLIT";
})(CLEAR_MODES || (CLEAR_MODES = {}));
/**
* The gc modes that are supported by pixi.
*
* The {@link PIXI.settings.GC_MODE} Garbage Collection mode for PixiJS textures is AUTO
* If set to GC_MODE, the renderer will occasionally check textures usage. If they are not
* used for a specified period of time they will be removed from the GPU. They will of course
* be uploaded again when they are required. This is a silent behind the scenes process that
* should ensure that the GPU does not get filled up.
*
* Handy for mobile devices!
* This property only affects WebGL.
* @name GC_MODES
* @enum {number}
* @static
* @memberof PIXI
* @property {number} AUTO - Garbage collection will happen periodically automatically
* @property {number} MANUAL - Garbage collection will need to be called manually
*/
var GC_MODES;
(function (GC_MODES) {
GC_MODES[GC_MODES["AUTO"] = 0] = "AUTO";
GC_MODES[GC_MODES["MANUAL"] = 1] = "MANUAL";
})(GC_MODES || (GC_MODES = {}));
/**
* Constants that specify float precision in shaders.
* @name PRECISION
* @memberof PIXI
* @constant
* @static
* @enum {string}
* @property {string} [LOW='lowp'] -
* @property {string} [MEDIUM='mediump'] -
* @property {string} [HIGH='highp'] -
*/
var PRECISION;
(function (PRECISION) {
PRECISION["LOW"] = "lowp";
PRECISION["MEDIUM"] = "mediump";
PRECISION["HIGH"] = "highp";
})(PRECISION || (PRECISION = {}));
/**
* Constants for mask implementations.
* We use `type` suffix because it leads to very different behaviours
* @name MASK_TYPES
* @memberof PIXI
* @static
* @enum {number}
* @property {number} NONE - Mask is ignored
* @property {number} SCISSOR - Scissor mask, rectangle on screen, cheap
* @property {number} STENCIL - Stencil mask, 1-bit, medium, works only if renderer supports stencil
* @property {number} SPRITE - Mask that uses SpriteMaskFilter, uses temporary RenderTexture
* @property {number} COLOR - Color mask (RGBA)
*/
var MASK_TYPES;
(function (MASK_TYPES) {
MASK_TYPES[MASK_TYPES["NONE"] = 0] = "NONE";
MASK_TYPES[MASK_TYPES["SCISSOR"] = 1] = "SCISSOR";
MASK_TYPES[MASK_TYPES["STENCIL"] = 2] = "STENCIL";
MASK_TYPES[MASK_TYPES["SPRITE"] = 3] = "SPRITE";
MASK_TYPES[MASK_TYPES["COLOR"] = 4] = "COLOR";
})(MASK_TYPES || (MASK_TYPES = {}));
/**
* Bitwise OR of masks that indicate the color channels that are rendered to.
* @static
* @memberof PIXI
* @name COLOR_MASK_BITS
* @enum {number}
* @property {number} RED - Red channel.
* @property {number} GREEN - Green channel
* @property {number} BLUE - Blue channel.
* @property {number} ALPHA - Alpha channel.
*/
var COLOR_MASK_BITS;
(function (COLOR_MASK_BITS) {
COLOR_MASK_BITS[COLOR_MASK_BITS["RED"] = 1] = "RED";
COLOR_MASK_BITS[COLOR_MASK_BITS["GREEN"] = 2] = "GREEN";
COLOR_MASK_BITS[COLOR_MASK_BITS["BLUE"] = 4] = "BLUE";
COLOR_MASK_BITS[COLOR_MASK_BITS["ALPHA"] = 8] = "ALPHA";
})(COLOR_MASK_BITS || (COLOR_MASK_BITS = {}));
/**
* Constants for multi-sampling antialiasing.
* @see PIXI.Framebuffer#multisample
* @name MSAA_QUALITY
* @memberof PIXI
* @static
* @enum {number}
* @property {number} NONE - No multisampling for this renderTexture
* @property {number} LOW - Try 2 samples
* @property {number} MEDIUM - Try 4 samples
* @property {number} HIGH - Try 8 samples
*/
var MSAA_QUALITY;
(function (MSAA_QUALITY) {
MSAA_QUALITY[MSAA_QUALITY["NONE"] = 0] = "NONE";
MSAA_QUALITY[MSAA_QUALITY["LOW"] = 2] = "LOW";
MSAA_QUALITY[MSAA_QUALITY["MEDIUM"] = 4] = "MEDIUM";
MSAA_QUALITY[MSAA_QUALITY["HIGH"] = 8] = "HIGH";
})(MSAA_QUALITY || (MSAA_QUALITY = {}));
/**
* Constants for various buffer types in Pixi
* @see PIXI.BUFFER_TYPE
* @name BUFFER_TYPE
* @memberof PIXI
* @static
* @enum {number}
* @property {number} ELEMENT_ARRAY_BUFFER - buffer type for using as an index buffer
* @property {number} ARRAY_BUFFER - buffer type for using attribute data
* @property {number} UNIFORM_BUFFER - the buffer type is for uniform buffer objects
*/
var BUFFER_TYPE;
(function (BUFFER_TYPE) {
BUFFER_TYPE[BUFFER_TYPE["ELEMENT_ARRAY_BUFFER"] = 34963] = "ELEMENT_ARRAY_BUFFER";
BUFFER_TYPE[BUFFER_TYPE["ARRAY_BUFFER"] = 34962] = "ARRAY_BUFFER";
// NOT YET SUPPORTED
BUFFER_TYPE[BUFFER_TYPE["UNIFORM_BUFFER"] = 35345] = "UNIFORM_BUFFER";
})(BUFFER_TYPE || (BUFFER_TYPE = {}));
/**
* The BlurFilterPass applies a horizontal or vertical Gaussian blur to an object.
* @memberof PIXI.filters
*/
var BlurFilterPass = /** @class */ (function (_super) {
__extends(BlurFilterPass, _super);
/**
* @param horizontal - Do pass along the x-axis (`true`) or y-axis (`false`).
* @param strength - The strength of the blur filter.
* @param quality - The quality of the blur filter.
* @param resolution - The resolution of the blur filter.
* @param kernelSize - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.
*/
function BlurFilterPass(horizontal, strength, quality, resolution, kernelSize) {
if (strength === void 0) { strength = 8; }
if (quality === void 0) { quality = 4; }
if (resolution === void 0) { resolution = settings.settings.FILTER_RESOLUTION; }
if (kernelSize === void 0) { kernelSize = 5; }
var _this = this;
var vertSrc = generateBlurVertSource(kernelSize, horizontal);
var fragSrc = generateBlurFragSource(kernelSize);
_this = _super.call(this,
// vertex shader
vertSrc,
// fragment shader
fragSrc) || this;
_this.horizontal = horizontal;
_this.resolution = resolution;
_this._quality = 0;
_this.quality = quality;
_this.blur = strength;
return _this;
class BlurFilterPass extends core.Filter {
constructor(horizontal, strength = 8, quality = 4, resolution = core.settings.FILTER_RESOLUTION, kernelSize = 5) {
const vertSrc = generateBlurVertSource(kernelSize, horizontal);
const fragSrc = generateBlurFragSource(kernelSize);
super(vertSrc, fragSrc);
this.horizontal = horizontal;
this.resolution = resolution;
this._quality = 0;
this.quality = quality;
this.blur = strength;
}
apply(filterManager, input, output, clearMode) {
if (output) {
if (this.horizontal) {
this.uniforms.strength = 1 / output.width * (output.width / input.width);
} else {
this.uniforms.strength = 1 / output.height * (output.height / input.height);
}
} else {
if (this.horizontal) {
this.uniforms.strength = 1 / filterManager.renderer.width * (filterManager.renderer.width / input.width);
} else {
this.uniforms.strength = 1 / filterManager.renderer.height * (filterManager.renderer.height / input.height);
}
}
/**
* Applies the filter.
* @param filterManager - The manager.
* @param input - The input target.
* @param output - The output target.
* @param clearMode - How to clear
*/
BlurFilterPass.prototype.apply = function (filterManager, input, output, clearMode) {
if (output) {
if (this.horizontal) {
this.uniforms.strength = (1 / output.width) * (output.width / input.width);
}
else {
this.uniforms.strength = (1 / output.height) * (output.height / input.height);
}
}
else {
if (this.horizontal) // eslint-disable-line
{
this.uniforms.strength = (1 / filterManager.renderer.width) * (filterManager.renderer.width / input.width);
}
else {
this.uniforms.strength = (1 / filterManager.renderer.height) * (filterManager.renderer.height / input.height); // eslint-disable-line
}
}
// screen space!
this.uniforms.strength *= this.strength;
this.uniforms.strength /= this.passes;
if (this.passes === 1) {
filterManager.applyFilter(this, input, output, clearMode);
}
else {
var renderTarget = filterManager.getFilterTexture();
var renderer = filterManager.renderer;
var flip = input;
var flop = renderTarget;
this.state.blend = false;
filterManager.applyFilter(this, flip, flop, CLEAR_MODES.CLEAR);
for (var i = 1; i < this.passes - 1; i++) {
filterManager.bindAndClear(flip, CLEAR_MODES.BLIT);
this.uniforms.uSampler = flop;
var temp = flop;
flop = flip;
flip = temp;
renderer.shader.bind(this);
renderer.geometry.draw(5);
}
this.state.blend = true;
filterManager.applyFilter(this, flop, output, clearMode);
filterManager.returnFilterTexture(renderTarget);
}
};
Object.defineProperty(BlurFilterPass.prototype, "blur", {
/**
* Sets the strength of both the blur.
* @default 16
*/
get: function () {
return this.strength;
},
set: function (value) {
this.padding = 1 + (Math.abs(value) * 2);
this.strength = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BlurFilterPass.prototype, "quality", {
/**
* Sets the quality of the blur by modifying the number of passes. More passes means higher
* quality bluring but the lower the performance.
* @default 4
*/
get: function () {
return this._quality;
},
set: function (value) {
this._quality = value;
this.passes = value;
},
enumerable: false,
configurable: true
});
return BlurFilterPass;
}(core.Filter));
this.uniforms.strength *= this.strength;
this.uniforms.strength /= this.passes;
if (this.passes === 1) {
filterManager.applyFilter(this, input, output, clearMode);
} else {
const renderTarget = filterManager.getFilterTexture();
const renderer = filterManager.renderer;
let flip = input;
let flop = renderTarget;
this.state.blend = false;
filterManager.applyFilter(this, flip, flop, core.CLEAR_MODES.CLEAR);
for (let i = 1; i < this.passes - 1; i++) {
filterManager.bindAndClear(flip, core.CLEAR_MODES.BLIT);
this.uniforms.uSampler = flop;
const temp = flop;
flop = flip;
flip = temp;
renderer.shader.bind(this);
renderer.geometry.draw(5);
}
this.state.blend = true;
filterManager.applyFilter(this, flop, output, clearMode);
filterManager.returnFilterTexture(renderTarget);
}
}
get blur() {
return this.strength;
}
set blur(value) {
this.padding = 1 + Math.abs(value) * 2;
this.strength = value;
}
get quality() {
return this._quality;
}
set quality(value) {
this._quality = value;
this.passes = value;
}
}
/**
* The BlurFilter applies a Gaussian blur to an object.
*
* The strength of the blur can be set for the x-axis and y-axis separately.
* @memberof PIXI.filters
*/
var BlurFilter = /** @class */ (function (_super) {
__extends(BlurFilter, _super);
/**
* @param strength - The strength of the blur filter.
* @param quality - The quality of the blur filter.
* @param [resolution=PIXI.settings.FILTER_RESOLUTION] - The resolution of the blur filter.
* @param kernelSize - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.
*/
function BlurFilter(strength, quality, resolution, kernelSize) {
if (strength === void 0) { strength = 8; }
if (quality === void 0) { quality = 4; }
if (resolution === void 0) { resolution = settings.settings.FILTER_RESOLUTION; }
if (kernelSize === void 0) { kernelSize = 5; }
var _this = _super.call(this) || this;
_this.blurXFilter = new BlurFilterPass(true, strength, quality, resolution, kernelSize);
_this.blurYFilter = new BlurFilterPass(false, strength, quality, resolution, kernelSize);
_this.resolution = resolution;
_this.quality = quality;
_this.blur = strength;
_this.repeatEdgePixels = false;
return _this;
class BlurFilter extends core.Filter {
constructor(strength = 8, quality = 4, resolution = core.settings.FILTER_RESOLUTION, kernelSize = 5) {
super();
this.blurXFilter = new BlurFilterPass(true, strength, quality, resolution, kernelSize);
this.blurYFilter = new BlurFilterPass(false, strength, quality, resolution, kernelSize);
this.resolution = resolution;
this.quality = quality;
this.blur = strength;
this.repeatEdgePixels = false;
}
apply(filterManager, input, output, clearMode) {
const xStrength = Math.abs(this.blurXFilter.strength);
const yStrength = Math.abs(this.blurYFilter.strength);
if (xStrength && yStrength) {
const renderTarget = filterManager.getFilterTexture();
this.blurXFilter.apply(filterManager, input, renderTarget, core.CLEAR_MODES.CLEAR);
this.blurYFilter.apply(filterManager, renderTarget, output, clearMode);
filterManager.returnFilterTexture(renderTarget);
} else if (yStrength) {
this.blurYFilter.apply(filterManager, input, output, clearMode);
} else {
this.blurXFilter.apply(filterManager, input, output, clearMode);
}
/**
* Applies the filter.
* @param filterManager - The manager.
* @param input - The input target.
* @param output - The output target.
* @param clearMode - How to clear
*/
BlurFilter.prototype.apply = function (filterManager, input, output, clearMode) {
var xStrength = Math.abs(this.blurXFilter.strength);
var yStrength = Math.abs(this.blurYFilter.strength);
if (xStrength && yStrength) {
var renderTarget = filterManager.getFilterTexture();
this.blurXFilter.apply(filterManager, input, renderTarget, CLEAR_MODES.CLEAR);
this.blurYFilter.apply(filterManager, renderTarget, output, clearMode);
filterManager.returnFilterTexture(renderTarget);
}
else if (yStrength) {
this.blurYFilter.apply(filterManager, input, output, clearMode);
}
else {
this.blurXFilter.apply(filterManager, input, output, clearMode);
}
};
BlurFilter.prototype.updatePadding = function () {
if (this._repeatEdgePixels) {
this.padding = 0;
}
else {
this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2;
}
};
Object.defineProperty(BlurFilter.prototype, "blur", {
/**
* Sets the strength of both the blurX and blurY properties simultaneously
* @default 2
*/
get: function () {
return this.blurXFilter.blur;
},
set: function (value) {
this.blurXFilter.blur = this.blurYFilter.blur = value;
this.updatePadding();
},
enumerable: false,
configurable: true
});
Object.defineProperty(BlurFilter.prototype, "quality", {
/**
* Sets the number of passes for blur. More passes means higher quality bluring.
* @default 1
*/
get: function () {
return this.blurXFilter.quality;
},
set: function (value) {
this.blurXFilter.quality = this.blurYFilter.quality = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BlurFilter.prototype, "blurX", {
/**
* Sets the strength of the blurX property
* @default 2
*/
get: function () {
return this.blurXFilter.blur;
},
set: function (value) {
this.blurXFilter.blur = value;
this.updatePadding();
},
enumerable: false,
configurable: true
});
Object.defineProperty(BlurFilter.prototype, "blurY", {
/**
* Sets the strength of the blurY property
* @default 2
*/
get: function () {
return this.blurYFilter.blur;
},
set: function (value) {
this.blurYFilter.blur = value;
this.updatePadding();
},
enumerable: false,
configurable: true
});
Object.defineProperty(BlurFilter.prototype, "blendMode", {
/**
* Sets the blendmode of the filter
* @default PIXI.BLEND_MODES.NORMAL
*/
get: function () {
return this.blurYFilter.blendMode;
},
set: function (value) {
this.blurYFilter.blendMode = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BlurFilter.prototype, "repeatEdgePixels", {
/**
* If set to true the edge of the target will be clamped
* @default false
*/
get: function () {
return this._repeatEdgePixels;
},
set: function (value) {
this._repeatEdgePixels = value;
this.updatePadding();
},
enumerable: false,
configurable: true
});
return BlurFilter;
}(core.Filter));
}
updatePadding() {
if (this._repeatEdgePixels) {
this.padding = 0;
} else {
this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2;
}
}
get blur() {
return this.blurXFilter.blur;
}
set blur(value) {
this.blurXFilter.blur = this.blurYFilter.blur = value;
this.updatePadding();
}
get quality() {
return this.blurXFilter.quality;
}
set quality(value) {
this.blurXFilter.quality = this.blurYFilter.quality = value;
}
get blurX() {
return this.blurXFilter.blur;
}
set blurX(value) {
this.blurXFilter.blur = value;
this.updatePadding();
}
get blurY() {
return this.blurYFilter.blur;
}
set blurY(value) {
this.blurYFilter.blur = value;
this.updatePadding();
}
get blendMode() {
return this.blurYFilter.blendMode;
}
set blendMode(value) {
this.blurYFilter.blendMode = value;
}
get repeatEdgePixels() {
return this._repeatEdgePixels;
}
set repeatEdgePixels(value) {
this._repeatEdgePixels = value;
this.updatePadding();
}
}

@@ -889,0 +245,0 @@ exports.BlurFilter = BlurFilter;

42

dist/cjs/filter-blur.min.js

@@ -1,9 +0,41 @@

/*!
* @pixi/filter-blur - v6.5.3
* Compiled Fri, 09 Sep 2022 13:55:20 UTC
"use strict";/*!
* @pixi/filter-blur - v7.0.0-alpha
* Compiled Fri, 09 Sep 2022 16:09:18 UTC
*
* @pixi/filter-blur is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@pixi/core"),e=require("@pixi/settings"),r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},r(t,e)};function i(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var n,E,_,o,T,u,N,R,l,s,I,A,a,O,L,P,U,S,h,p,c={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},d=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join("\n");!function(t){t[t.WEBGL_LEGACY=0]="WEBGL_LEGACY",t[t.WEBGL=1]="WEBGL",t[t.WEBGL2=2]="WEBGL2"}(n||(n={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.WEBGL=1]="WEBGL",t[t.CANVAS=2]="CANVAS"}(E||(E={})),function(t){t[t.COLOR=16384]="COLOR",t[t.DEPTH=256]="DEPTH",t[t.STENCIL=1024]="STENCIL"}(_||(_={})),function(t){t[t.NORMAL=0]="NORMAL",t[t.ADD=1]="ADD",t[t.MULTIPLY=2]="MULTIPLY",t[t.SCREEN=3]="SCREEN",t[t.OVERLAY=4]="OVERLAY",t[t.DARKEN=5]="DARKEN",t[t.LIGHTEN=6]="LIGHTEN",t[t.COLOR_DODGE=7]="COLOR_DODGE",t[t.COLOR_BURN=8]="COLOR_BURN",t[t.HARD_LIGHT=9]="HARD_LIGHT",t[t.SOFT_LIGHT=10]="SOFT_LIGHT",t[t.DIFFERENCE=11]="DIFFERENCE",t[t.EXCLUSION=12]="EXCLUSION",t[t.HUE=13]="HUE",t[t.SATURATION=14]="SATURATION",t[t.COLOR=15]="COLOR",t[t.LUMINOSITY=16]="LUMINOSITY",t[t.NORMAL_NPM=17]="NORMAL_NPM",t[t.ADD_NPM=18]="ADD_NPM",t[t.SCREEN_NPM=19]="SCREEN_NPM",t[t.NONE=20]="NONE",t[t.SRC_OVER=0]="SRC_OVER",t[t.SRC_IN=21]="SRC_IN",t[t.SRC_OUT=22]="SRC_OUT",t[t.SRC_ATOP=23]="SRC_ATOP",t[t.DST_OVER=24]="DST_OVER",t[t.DST_IN=25]="DST_IN",t[t.DST_OUT=26]="DST_OUT",t[t.DST_ATOP=27]="DST_ATOP",t[t.ERASE=26]="ERASE",t[t.SUBTRACT=28]="SUBTRACT",t[t.XOR=29]="XOR"}(o||(o={})),function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(T||(T={})),function(t){t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL"}(u||(u={})),function(t){t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"}(N||(N={})),function(t){t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT"}(R||(R={})),function(t){t[t.FLOAT=0]="FLOAT",t[t.INT=1]="INT",t[t.UINT=2]="UINT"}(l||(l={})),function(t){t[t.NEAREST=0]="NEAREST",t[t.LINEAR=1]="LINEAR"}(s||(s={})),function(t){t[t.CLAMP=33071]="CLAMP",t[t.REPEAT=10497]="REPEAT",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(I||(I={})),function(t){t[t.OFF=0]="OFF",t[t.POW2=1]="POW2",t[t.ON=2]="ON",t[t.ON_MANUAL=3]="ON_MANUAL"}(A||(A={})),function(t){t[t.NPM=0]="NPM",t[t.UNPACK=1]="UNPACK",t[t.PMA=2]="PMA",t[t.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",t[t.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",t[t.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",t[t.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA"}(a||(a={})),function(t){t[t.NO=0]="NO",t[t.YES=1]="YES",t[t.AUTO=2]="AUTO",t[t.BLEND=0]="BLEND",t[t.CLEAR=1]="CLEAR",t[t.BLIT=2]="BLIT"}(O||(O={})),function(t){t[t.AUTO=0]="AUTO",t[t.MANUAL=1]="MANUAL"}(L||(L={})),function(t){t.LOW="lowp",t.MEDIUM="mediump",t.HIGH="highp"}(P||(P={})),function(t){t[t.NONE=0]="NONE",t[t.SCISSOR=1]="SCISSOR",t[t.STENCIL=2]="STENCIL",t[t.SPRITE=3]="SPRITE",t[t.COLOR=4]="COLOR"}(U||(U={})),function(t){t[t.RED=1]="RED",t[t.GREEN=2]="GREEN",t[t.BLUE=4]="BLUE",t[t.ALPHA=8]="ALPHA"}(S||(S={})),function(t){t[t.NONE=0]="NONE",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=8]="HIGH"}(h||(h={})),function(t){t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"}(p||(p={}));var f=function(t){function r(r,i,n,E,_){void 0===i&&(i=8),void 0===n&&(n=4),void 0===E&&(E=e.settings.FILTER_RESOLUTION),void 0===_&&(_=5);var o=this,T=function(t,e){var r,i=Math.ceil(t/2),n="\n attribute vec2 aVertexPosition;\n\n uniform mat3 projectionMatrix;\n\n uniform float strength;\n\n varying vec2 vBlurTexCoords[%size%];\n\n uniform vec4 inputSize;\n uniform vec4 outputFrame;\n\n vec4 filterVertexPosition( void )\n {\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n }\n\n vec2 filterTextureCoord( void )\n {\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n }\n\n void main(void)\n {\n gl_Position = filterVertexPosition();\n\n vec2 textureCoord = filterTextureCoord();\n %blur%\n }",E="";r=e?"vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":"vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(var _=0;_<t;_++){var o=r.replace("%index%",_.toString());E+=o=o.replace("%sampleIndex%",_-(i-1)+".0"),E+="\n"}return(n=n.replace("%blur%",E)).replace("%size%",t.toString())}(_,r),u=function(t){for(var e,r=c[t],i=r.length,n=d,E="",_=0;_<t;_++){var o="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;".replace("%index%",_.toString());e=_,_>=i&&(e=t-_-1),E+=o=o.replace("%value%",r[e].toString()),E+="\n"}return(n=n.replace("%blur%",E)).replace("%size%",t.toString())}(_);return(o=t.call(this,T,u)||this).horizontal=r,o.resolution=E,o._quality=0,o.quality=n,o.blur=i,o}return i(r,t),r.prototype.apply=function(t,e,r,i){if(r?this.horizontal?this.uniforms.strength=1/r.width*(r.width/e.width):this.uniforms.strength=1/r.height*(r.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,1===this.passes)t.applyFilter(this,e,r,i);else{var n=t.getFilterTexture(),E=t.renderer,_=e,o=n;this.state.blend=!1,t.applyFilter(this,_,o,O.CLEAR);for(var T=1;T<this.passes-1;T++){t.bindAndClear(_,O.BLIT),this.uniforms.uSampler=o;var u=o;o=_,_=u,E.shader.bind(this),E.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,o,r,i),t.returnFilterTexture(n)}},Object.defineProperty(r.prototype,"blur",{get:function(){return this.strength},set:function(t){this.padding=1+2*Math.abs(t),this.strength=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"quality",{get:function(){return this._quality},set:function(t){this._quality=t,this.passes=t},enumerable:!1,configurable:!0}),r}(t.Filter),F=function(t){function r(r,i,n,E){void 0===r&&(r=8),void 0===i&&(i=4),void 0===n&&(n=e.settings.FILTER_RESOLUTION),void 0===E&&(E=5);var _=t.call(this)||this;return _.blurXFilter=new f(!0,r,i,n,E),_.blurYFilter=new f(!1,r,i,n,E),_.resolution=n,_.quality=i,_.blur=r,_.repeatEdgePixels=!1,_}return i(r,t),r.prototype.apply=function(t,e,r,i){var n=Math.abs(this.blurXFilter.strength),E=Math.abs(this.blurYFilter.strength);if(n&&E){var _=t.getFilterTexture();this.blurXFilter.apply(t,e,_,O.CLEAR),this.blurYFilter.apply(t,_,r,i),t.returnFilterTexture(_)}else E?this.blurYFilter.apply(t,e,r,i):this.blurXFilter.apply(t,e,r,i)},r.prototype.updatePadding=function(){this._repeatEdgePixels?this.padding=0:this.padding=2*Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))},Object.defineProperty(r.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"quality",{get:function(){return this.blurXFilter.quality},set:function(t){this.blurXFilter.quality=this.blurYFilter.quality=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t,this.updatePadding()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(t){this.blurYFilter.blur=t,this.updatePadding()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blendMode",{get:function(){return this.blurYFilter.blendMode},set:function(t){this.blurYFilter.blendMode=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"repeatEdgePixels",{get:function(){return this._repeatEdgePixels},set:function(t){this._repeatEdgePixels=t,this.updatePadding()},enumerable:!1,configurable:!0}),r}(t.Filter);exports.BlurFilter=F,exports.BlurFilterPass=f;
*/Object.defineProperty(exports,"__esModule",{value:!0});var a=require("@pixi/core");const p=`
attribute vec2 aVertexPosition;
uniform mat3 projectionMatrix;
uniform float strength;
varying vec2 vBlurTexCoords[%size%];
uniform vec4 inputSize;
uniform vec4 outputFrame;
vec4 filterVertexPosition( void )
{
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
}
vec2 filterTextureCoord( void )
{
return aVertexPosition * (outputFrame.zw * inputSize.zw);
}
void main(void)
{
gl_Position = filterVertexPosition();
vec2 textureCoord = filterTextureCoord();
%blur%
}`;function b(n,t){const i=Math.ceil(n/2);let e=p,s="",u;t?u="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":u="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let l=0;l<n;l++){let r=u.replace("%index%",l.toString());r=r.replace("%sampleIndex%",`${l-(i-1)}.0`),s+=r,s+=`
`}return e=e.replace("%blur%",s),e=e.replace("%size%",n.toString()),e}const c={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},F=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
`);function x(n){const t=c[n],i=t.length;let e=F,s="";const u="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let l;for(let r=0;r<n;r++){let o=u.replace("%index%",r.toString());l=r,r>=i&&(l=n-r-1),o=o.replace("%value%",t[l].toString()),s+=o,s+=`
`}return e=e.replace("%blur%",s),e=e.replace("%size%",n.toString()),e}class h extends a.Filter{constructor(t,i=8,e=4,s=a.settings.FILTER_RESOLUTION,u=5){const l=b(u,t),r=x(u);super(l,r),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=e,this.blur=i}apply(t,i,e,s){if(e?this.horizontal?this.uniforms.strength=1/e.width*(e.width/i.width):this.uniforms.strength=1/e.height*(e.height/i.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/i.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/i.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,i,e,s);else{const u=t.getFilterTexture(),l=t.renderer;let r=i,o=u;this.state.blend=!1,t.applyFilter(this,r,o,a.CLEAR_MODES.CLEAR);for(let d=1;d<this.passes-1;d++){t.bindAndClear(r,a.CLEAR_MODES.BLIT),this.uniforms.uSampler=o;const g=o;o=r,r=g,l.shader.bind(this),l.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,o,e,s),t.returnFilterTexture(u)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class v extends a.Filter{constructor(t=8,i=4,e=a.settings.FILTER_RESOLUTION,s=5){super(),this.blurXFilter=new h(!0,t,i,e,s),this.blurYFilter=new h(!1,t,i,e,s),this.resolution=e,this.quality=i,this.blur=t,this.repeatEdgePixels=!1}apply(t,i,e,s){const u=Math.abs(this.blurXFilter.strength),l=Math.abs(this.blurYFilter.strength);if(u&&l){const r=t.getFilterTexture();this.blurXFilter.apply(t,i,r,a.CLEAR_MODES.CLEAR),this.blurYFilter.apply(t,r,e,s),t.returnFilterTexture(r)}else l?this.blurYFilter.apply(t,i,e,s):this.blurXFilter.apply(t,i,e,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}exports.BlurFilter=v,exports.BlurFilterPass=h;
//# sourceMappingURL=filter-blur.min.js.map

@@ -1,3 +0,3 @@

import type { BLEND_MODES } from '@pixi/constants';
import { CLEAR_MODES } from '@pixi/constants';
import type { BLEND_MODES } from '@pixi/core';
import { CLEAR_MODES } from '@pixi/core';
import { Filter } from '@pixi/core';

@@ -4,0 +4,0 @@ import type { FilterSystem } from '@pixi/core';

{
"name": "@pixi/filter-blur",
"version": "6.5.3",
"version": "7.0.0-alpha",
"main": "dist/cjs/filter-blur.js",
"module": "dist/esm/filter-blur.mjs",
"bundle": "dist/browser/filter-blur.js",
"types": "index.d.ts",

@@ -20,3 +19,2 @@ "exports": {

},
"namespace": "PIXI.filters",
"description": "Filter that blurs the display object",

@@ -38,11 +36,9 @@ "author": "Mat Groves",

"files": [
"lib",
"dist",
"*.d.ts"
],
"peerDependencies": {
"@pixi/core": "6.5.3",
"@pixi/settings": "6.5.3"
},
"gitHead": "28e6b2841a65837a5e2873a3d5a9c27cabbe795a"
"pixiRequirements": [
"@pixi/core"
],
"gitHead": "da993226df64b804a9c00ed9ee4d011191467b8a"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc