Socket
Socket
Sign inDemoInstall

@pixi/filter-zoom-blur

Package Overview
Dependencies
11
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.3.0

106

lib/filter-zoom-blur.es.js
/*!
* @pixi/filter-zoom-blur - v2.2.0
* Compiled Wed, 18 Oct 2017 20:55:31 UTC
* @pixi/filter-zoom-blur - v2.3.0
* Compiled Tue, 31 Oct 2017 18:03:36 UTC
*

@@ -8,103 +8,3 @@ * pixi-filters is licensed under the MIT License.

*/
if (typeof PIXI === 'undefined' || typeof PIXI.filters === 'undefined') { throw 'PixiJS is required'; }
var vertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n";
var fragment = "varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform vec2 uCenter;\nuniform float uStrength;\nuniform float uInnerRadius;\nuniform float uRadius;\n\nfloat random(vec3 scale, float seed) {\n // use the fragment position for a different seed per-pixel\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main() {\n\n vec2 center = uCenter.xy / filterArea.xy;\n vec2 dir = vec2(center - vTextureCoord);\n float dist = length(vec2(dir.x, dir.y * filterArea.y / filterArea.x));\n\n float strength = uStrength;\n\n const float count = 32.0;\n float countLimit = count;\n\n float minGradient = uInnerRadius * 0.3;\n float gradient = uRadius * 0.3;\n\n float innerRadius = (uInnerRadius + minGradient * 0.5) / filterArea.x;\n float radius = (uRadius - gradient * 0.5) / filterArea.x;\n\n float delta = 0.0;\n float gap;\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (dist > radius) {\n delta = dist - radius;\n gap = gradient;\n }\n\n if (delta > 0.0) {\n float normalCount = gap / filterArea.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n if (countLimit < 1.0)\n {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n float total = 0.0;\n vec4 color = vec4(0.0);\n\n dir *= strength;\n\n for (float t = 0.0; t < count; t++) {\n float percent = (t + offset) / count;\n float weight = 4.0 * (percent - percent * percent);\n vec2 p = vTextureCoord + dir * percent;\n vec4 sample = texture2D(uSampler, p);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n\n if (t > countLimit){\n break;\n }\n }\n\n gl_FragColor = color / total;\n\n // switch back from pre-multiplied alpha\n gl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n}\n";
/**
* The ZoomFilter applies a Zoom blur to an object.
* ![original](../tools/screenshots/dist/original.png)![filter](../tools/screenshots/dist/zoom-blur.png)
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
* @param {number} [strength=0.1] Sets the strength of the zoom blur effect
* @param {PIXI.Point|number[]} [center=[0,0]] The center of the zoom.
* @param {number} [innerRadius=0] The inner radius of zoom. The part in inner circle won't apply zoom blur effect.
* @param {number} [radius=1E8] Outer radius of the zoom, The default value is very very large.
*/
var ZoomBlurFilter = (function (superclass) {
function ZoomBlurFilter(strength, center, innerRadius, radius) {
if ( strength === void 0 ) strength = 0.1;
if ( center === void 0 ) center = [0, 0];
if ( innerRadius === void 0 ) innerRadius = 0;
if ( radius === void 0 ) radius = 1E8;
superclass.call(this, vertex, fragment);
this.center = center;
this.strength = strength;
this.innerRadius = innerRadius;
this.radius = radius;
}
if ( superclass ) ZoomBlurFilter.__proto__ = superclass;
ZoomBlurFilter.prototype = Object.create( superclass && superclass.prototype );
ZoomBlurFilter.prototype.constructor = ZoomBlurFilter;
var prototypeAccessors = { center: {},strength: {},innerRadius: {},radius: {} };
/**
* Center of the effect.
*
* @member {PIXI.Point|number[]}
* @default [0, 0]
*/
prototypeAccessors.center.get = function () {
return this.uniforms.uCenter;
};
prototypeAccessors.center.set = function (value) {
this.uniforms.uCenter = value;
};
/**
* Intensity of the zoom effect.
*
* @member {number}
* @default 0.1
*/
prototypeAccessors.strength.get = function () {
return this.uniforms.uStrength;
};
prototypeAccessors.strength.set = function (value) {
this.uniforms.uStrength = value;
};
/**
* Radius of the inner region not effected by blur.
*
* @member {number}
* @default 0
*/
prototypeAccessors.innerRadius.get = function () {
return this.uniforms.uInnerRadius;
};
prototypeAccessors.innerRadius.set = function (value) {
this.uniforms.uInnerRadius = value;
};
/**
* Outer radius of the effect. The default value is very very big.
*
* @member {number}
* @default 1E8
*/
prototypeAccessors.radius.get = function () {
return this.uniforms.uRadius;
};
prototypeAccessors.radius.set = function (value) {
this.uniforms.uRadius = value;
};
Object.defineProperties( ZoomBlurFilter.prototype, prototypeAccessors );
return ZoomBlurFilter;
}(PIXI.Filter));
// Export to PixiJS namespace
PIXI.filters.ZoomBlurFilter = ZoomBlurFilter;
export { ZoomBlurFilter };
var vertex="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n",fragment="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform vec2 uCenter;\nuniform float uStrength;\nuniform float uInnerRadius;\nuniform float uRadius;\n\nconst float MAX_KERNEL_SIZE = 32.0;\n\nfloat random(vec3 scale, float seed) {\n // use the fragment position for a different seed per-pixel\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main() {\n\n float minGradient = uInnerRadius * 0.3;\n float innerRadius = (uInnerRadius + minGradient * 0.5) / filterArea.x;\n\n float gradient = uRadius * 0.3;\n float radius = (uRadius - gradient * 0.5) / filterArea.x;\n\n float countLimit = MAX_KERNEL_SIZE;\n\n vec2 dir = vec2(uCenter.xy / filterArea.xy - vTextureCoord);\n float dist = length(vec2(dir.x, dir.y * filterArea.y / filterArea.x));\n\n float strength = uStrength;\n\n float delta = 0.0;\n float gap;\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (radius >= 0.0 && dist > radius) { // radius < 0 means it's infinity\n delta = dist - radius;\n gap = gradient;\n }\n\n if (delta > 0.0) {\n float normalCount = gap / filterArea.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n if (countLimit < 1.0)\n {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n float total = 0.0;\n vec4 color = vec4(0.0);\n\n dir *= strength;\n\n for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {\n float percent = (t + offset) / MAX_KERNEL_SIZE;\n float weight = 4.0 * (percent - percent * percent);\n vec2 p = vTextureCoord + dir * percent;\n vec4 sample = texture2D(uSampler, p);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n\n if (t > countLimit){\n break;\n }\n }\n\n gl_FragColor = color / total;\n\n // switch back from pre-multiplied alpha\n gl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n\n}\n",ZoomBlurFilter=function(n){function t(t,e,r,i){void 0===t&&(t=.1),void 0===e&&(e=[0,0]),void 0===r&&(r=0),void 0===i&&(i=-1),n.call(this,vertex,fragment),this.center=e,this.strength=t,this.innerRadius=r,this.radius=i}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={center:{configurable:!0},strength:{configurable:!0},innerRadius:{configurable:!0},radius:{configurable:!0}};return e.center.get=function(){return this.uniforms.uCenter},e.center.set=function(n){this.uniforms.uCenter=n},e.strength.get=function(){return this.uniforms.uStrength},e.strength.set=function(n){this.uniforms.uStrength=n},e.innerRadius.get=function(){return this.uniforms.uInnerRadius},e.innerRadius.set=function(n){this.uniforms.uInnerRadius=n},e.radius.get=function(){return this.uniforms.uRadius},e.radius.set=function(n){(n<0||n===1/0)&&(n=-1),this.uniforms.uRadius=n},Object.defineProperties(t.prototype,e),t}(PIXI.Filter);PIXI.filters.ZoomBlurFilter=ZoomBlurFilter;export{ZoomBlurFilter};
//# sourceMappingURL=filter-zoom-blur.es.js.map
/*!
* @pixi/filter-zoom-blur - v2.2.0
* Compiled Wed, 18 Oct 2017 20:55:30 UTC
* @pixi/filter-zoom-blur - v2.3.0
* Compiled Tue, 31 Oct 2017 18:03:36 UTC
*

@@ -8,113 +8,3 @@ * pixi-filters is licensed under the MIT License.

*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.__filter_zoom_blur = {})));
}(this, (function (exports) { 'use strict';
if (typeof PIXI === 'undefined' || typeof PIXI.filters === 'undefined') { throw 'PixiJS is required'; }
var vertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n";
var fragment = "varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform vec2 uCenter;\nuniform float uStrength;\nuniform float uInnerRadius;\nuniform float uRadius;\n\nfloat random(vec3 scale, float seed) {\n // use the fragment position for a different seed per-pixel\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main() {\n\n vec2 center = uCenter.xy / filterArea.xy;\n vec2 dir = vec2(center - vTextureCoord);\n float dist = length(vec2(dir.x, dir.y * filterArea.y / filterArea.x));\n\n float strength = uStrength;\n\n const float count = 32.0;\n float countLimit = count;\n\n float minGradient = uInnerRadius * 0.3;\n float gradient = uRadius * 0.3;\n\n float innerRadius = (uInnerRadius + minGradient * 0.5) / filterArea.x;\n float radius = (uRadius - gradient * 0.5) / filterArea.x;\n\n float delta = 0.0;\n float gap;\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (dist > radius) {\n delta = dist - radius;\n gap = gradient;\n }\n\n if (delta > 0.0) {\n float normalCount = gap / filterArea.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n if (countLimit < 1.0)\n {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n float total = 0.0;\n vec4 color = vec4(0.0);\n\n dir *= strength;\n\n for (float t = 0.0; t < count; t++) {\n float percent = (t + offset) / count;\n float weight = 4.0 * (percent - percent * percent);\n vec2 p = vTextureCoord + dir * percent;\n vec4 sample = texture2D(uSampler, p);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n\n if (t > countLimit){\n break;\n }\n }\n\n gl_FragColor = color / total;\n\n // switch back from pre-multiplied alpha\n gl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n}\n";
/**
* The ZoomFilter applies a Zoom blur to an object.
* ![original](../tools/screenshots/dist/original.png)![filter](../tools/screenshots/dist/zoom-blur.png)
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
* @param {number} [strength=0.1] Sets the strength of the zoom blur effect
* @param {PIXI.Point|number[]} [center=[0,0]] The center of the zoom.
* @param {number} [innerRadius=0] The inner radius of zoom. The part in inner circle won't apply zoom blur effect.
* @param {number} [radius=1E8] Outer radius of the zoom, The default value is very very large.
*/
var ZoomBlurFilter = (function (superclass) {
function ZoomBlurFilter(strength, center, innerRadius, radius) {
if ( strength === void 0 ) strength = 0.1;
if ( center === void 0 ) center = [0, 0];
if ( innerRadius === void 0 ) innerRadius = 0;
if ( radius === void 0 ) radius = 1E8;
superclass.call(this, vertex, fragment);
this.center = center;
this.strength = strength;
this.innerRadius = innerRadius;
this.radius = radius;
}
if ( superclass ) ZoomBlurFilter.__proto__ = superclass;
ZoomBlurFilter.prototype = Object.create( superclass && superclass.prototype );
ZoomBlurFilter.prototype.constructor = ZoomBlurFilter;
var prototypeAccessors = { center: {},strength: {},innerRadius: {},radius: {} };
/**
* Center of the effect.
*
* @member {PIXI.Point|number[]}
* @default [0, 0]
*/
prototypeAccessors.center.get = function () {
return this.uniforms.uCenter;
};
prototypeAccessors.center.set = function (value) {
this.uniforms.uCenter = value;
};
/**
* Intensity of the zoom effect.
*
* @member {number}
* @default 0.1
*/
prototypeAccessors.strength.get = function () {
return this.uniforms.uStrength;
};
prototypeAccessors.strength.set = function (value) {
this.uniforms.uStrength = value;
};
/**
* Radius of the inner region not effected by blur.
*
* @member {number}
* @default 0
*/
prototypeAccessors.innerRadius.get = function () {
return this.uniforms.uInnerRadius;
};
prototypeAccessors.innerRadius.set = function (value) {
this.uniforms.uInnerRadius = value;
};
/**
* Outer radius of the effect. The default value is very very big.
*
* @member {number}
* @default 1E8
*/
prototypeAccessors.radius.get = function () {
return this.uniforms.uRadius;
};
prototypeAccessors.radius.set = function (value) {
this.uniforms.uRadius = value;
};
Object.defineProperties( ZoomBlurFilter.prototype, prototypeAccessors );
return ZoomBlurFilter;
}(PIXI.Filter));
// Export to PixiJS namespace
PIXI.filters.ZoomBlurFilter = ZoomBlurFilter;
exports.ZoomBlurFilter = ZoomBlurFilter;
Object.defineProperty(exports, '__esModule', { value: true });
})));
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(n.__filter_zoom_blur={})}(this,function(n){"use strict";var e="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n",t="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform vec2 uCenter;\nuniform float uStrength;\nuniform float uInnerRadius;\nuniform float uRadius;\n\nconst float MAX_KERNEL_SIZE = 32.0;\n\nfloat random(vec3 scale, float seed) {\n // use the fragment position for a different seed per-pixel\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main() {\n\n float minGradient = uInnerRadius * 0.3;\n float innerRadius = (uInnerRadius + minGradient * 0.5) / filterArea.x;\n\n float gradient = uRadius * 0.3;\n float radius = (uRadius - gradient * 0.5) / filterArea.x;\n\n float countLimit = MAX_KERNEL_SIZE;\n\n vec2 dir = vec2(uCenter.xy / filterArea.xy - vTextureCoord);\n float dist = length(vec2(dir.x, dir.y * filterArea.y / filterArea.x));\n\n float strength = uStrength;\n\n float delta = 0.0;\n float gap;\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (radius >= 0.0 && dist > radius) { // radius < 0 means it's infinity\n delta = dist - radius;\n gap = gradient;\n }\n\n if (delta > 0.0) {\n float normalCount = gap / filterArea.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n if (countLimit < 1.0)\n {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n float total = 0.0;\n vec4 color = vec4(0.0);\n\n dir *= strength;\n\n for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {\n float percent = (t + offset) / MAX_KERNEL_SIZE;\n float weight = 4.0 * (percent - percent * percent);\n vec2 p = vTextureCoord + dir * percent;\n vec4 sample = texture2D(uSampler, p);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n\n if (t > countLimit){\n break;\n }\n }\n\n gl_FragColor = color / total;\n\n // switch back from pre-multiplied alpha\n gl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n\n}\n",r=function(n){function r(r,i,o,a){void 0===r&&(r=.1),void 0===i&&(i=[0,0]),void 0===o&&(o=0),void 0===a&&(a=-1),n.call(this,e,t),this.center=i,this.strength=r,this.innerRadius=o,this.radius=a}n&&(r.__proto__=n),(r.prototype=Object.create(n&&n.prototype)).constructor=r;var i={center:{configurable:!0},strength:{configurable:!0},innerRadius:{configurable:!0},radius:{configurable:!0}};return i.center.get=function(){return this.uniforms.uCenter},i.center.set=function(n){this.uniforms.uCenter=n},i.strength.get=function(){return this.uniforms.uStrength},i.strength.set=function(n){this.uniforms.uStrength=n},i.innerRadius.get=function(){return this.uniforms.uInnerRadius},i.innerRadius.set=function(n){this.uniforms.uInnerRadius=n},i.radius.get=function(){return this.uniforms.uRadius},i.radius.set=function(n){(n<0||n===1/0)&&(n=-1),this.uniforms.uRadius=n},Object.defineProperties(r.prototype,i),r}(PIXI.Filter);PIXI.filters.ZoomBlurFilter=r,n.ZoomBlurFilter=r,Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=filter-zoom-blur.js.map

17

package.json
{
"name": "@pixi/filter-zoom-blur",
"version": "2.2.0",
"main": "lib/filter-zoom-blur.min.js",
"version": "2.3.0",
"main": "lib/filter-zoom-blur.js",
"description": "Zoom Blur filter",

@@ -10,3 +10,3 @@ "author": "finscn",

],
"module": "lib/filter-zoom-blur.es.min.js",
"module": "lib/filter-zoom-blur.es.js",
"types": "types.d.ts",

@@ -24,5 +24,5 @@ "homepage": "http://pixijs.com/",

"scripts": {
"build:umd": "rollup -c -f umd && rollup -cp -f umd",
"build:es": "rollup -c && rollup -cp",
"build": "npm run build:umd && npm run build:es",
"build:dev": "rollup -c && rollup -c -f umd",
"build": "rollup -cp && rollup -cp -f umd",
"watch": "rollup -cw",
"postversion": "npm run build"

@@ -38,6 +38,7 @@ },

"devDependencies": {
"@tools/build": "^2.0.1",
"@tools/build": "^2.3.0",
"@tools/fragments": "^2.0.0",
"rollup": "^0.45.2"
"rollup": "^0.45.2",
"rollup-watch": "^4.3.1"
}
}
/// <reference types="pixi.js" />
declare namespace PIXI.filters {
class ZoomBlurFilter extends PIXI.Filter {
class ZoomBlurFilter extends PIXI.Filter<{}> {
constructor(strength?:number, center?:PIXI.Point|number[], innerRadius?:number, radius?:number);

@@ -5,0 +5,0 @@ strength:number;

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc