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

@pixi/filter-zoom-blur

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/filter-zoom-blur - npm Package Compare versions

Comparing version 3.0.3 to 3.1.0

6

dist/filter-zoom-blur.js
/*!
* @pixi/filter-zoom-blur - v3.0.3
* Compiled Wed, 29 May 2019 03:04:05 UTC
* @pixi/filter-zoom-blur - v3.1.0
* Compiled Tue, 03 Mar 2020 12:42:37 UTC
*

@@ -8,3 +8,3 @@ * @pixi/filter-zoom-blur is licensed under the MIT License.

*/
var __filters=function(n,t){"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}",r="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\n// author: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand(vec2 co, float seed) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);\n return fract(sin(sn) * c + 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 = rand(vTextureCoord, 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 color /= total;\n // switch back from pre-multiplied alpha\n // color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n",i=function(n){function t(t,i,o,a){void 0===t&&(t=.1),void 0===i&&(i=[0,0]),void 0===o&&(o=0),void 0===a&&(a=-1),n.call(this,e,r),this.center=i,this.strength=t,this.innerRadius=o,this.radius=a}n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t;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(t.prototype,i),t}(t.Filter);return n.ZoomBlurFilter=i,n}({},PIXI);Object.assign(PIXI.filters,__filters);
var __filters=function(n,t){"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}",r="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\n// author: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand(vec2 co, float seed) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);\n return fract(sin(sn) * c + 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 = rand(vTextureCoord, 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 color /= total;\n // switch back from pre-multiplied alpha\n // color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n",i=function(n){function t(t){if(n.call(this,e,r),"object"!=typeof t){var i=arguments[0],o=arguments[1],a=arguments[2],u=arguments[3];t={},void 0!==i&&(t.strength=i),void 0!==o&&(t.center=o),void 0!==a&&(t.innerRadius=a),void 0!==u&&(t.radius=u)}Object.assign(this,{strength:.1,center:[0,0],innerRadius:0,radius:-1},t)}n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t;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(t.prototype,i),t}(t.Filter);return n.ZoomBlurFilter=i,n}({},PIXI);Object.assign(PIXI.filters,__filters);
//# sourceMappingURL=filter-zoom-blur.js.map
/*!
* @pixi/filter-zoom-blur - v3.0.3
* Compiled Wed, 29 May 2019 03:04:05 UTC
* @pixi/filter-zoom-blur - v3.1.0
* Compiled Tue, 03 Mar 2020 12:42:37 UTC
*

@@ -27,20 +27,39 @@ * @pixi/filter-zoom-blur is licensed under the MIT License.

* @see {@link https://www.npmjs.com/package/pixi-filters|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=-1] See `radius` property.
* @param {object} [options] Filter options to use.
* @param {number} [options.strength=0.1] Sets the strength of the zoom blur effect
* @param {PIXI.Point|number[]} [options.center=[0,0]] The center of the zoom.
* @param {number} [options.innerRadius=0] The inner radius of zoom. The part in inner circle won't apply zoom blur effect.
* @param {number} [options.radius=-1] See `radius` property.
*/
var ZoomBlurFilter = /*@__PURE__*/(function (Filter) {
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 = -1;
function ZoomBlurFilter(options) {
Filter.call(this, vertex, fragment);
this.center = center;
this.strength = strength;
this.innerRadius = innerRadius;
this.radius = radius;
// @deprecated (strength, center, innerRadius, radius) args
if (typeof options !== 'object') {
var strength = arguments[0];
var center = arguments[1];
var innerRadius = arguments[2];
var radius = arguments[3];
options = {};
if (strength !== undefined) {
options.strength = strength;
}
if (center !== undefined) {
options.center = center;
}
if (innerRadius !== undefined) {
options.innerRadius = innerRadius;
}
if (radius !== undefined) {
options.radius = radius;
}
}
Object.assign(this, {
strength: 0.1,
center: [0, 0],
innerRadius: 0,
radius: -1,
}, options);
}

@@ -47,0 +66,0 @@

/*!
* @pixi/filter-zoom-blur - v3.0.3
* Compiled Wed, 29 May 2019 03:04:05 UTC
* @pixi/filter-zoom-blur - v3.1.0
* Compiled Tue, 03 Mar 2020 12:42:37 UTC
*

@@ -23,20 +23,39 @@ * @pixi/filter-zoom-blur is licensed under the MIT License.

* @see {@link https://www.npmjs.com/package/pixi-filters|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=-1] See `radius` property.
* @param {object} [options] Filter options to use.
* @param {number} [options.strength=0.1] Sets the strength of the zoom blur effect
* @param {PIXI.Point|number[]} [options.center=[0,0]] The center of the zoom.
* @param {number} [options.innerRadius=0] The inner radius of zoom. The part in inner circle won't apply zoom blur effect.
* @param {number} [options.radius=-1] See `radius` property.
*/
var ZoomBlurFilter = /*@__PURE__*/(function (Filter) {
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 = -1;
function ZoomBlurFilter(options) {
Filter.call(this, vertex, fragment);
this.center = center;
this.strength = strength;
this.innerRadius = innerRadius;
this.radius = radius;
// @deprecated (strength, center, innerRadius, radius) args
if (typeof options !== 'object') {
var strength = arguments[0];
var center = arguments[1];
var innerRadius = arguments[2];
var radius = arguments[3];
options = {};
if (strength !== undefined) {
options.strength = strength;
}
if (center !== undefined) {
options.center = center;
}
if (innerRadius !== undefined) {
options.innerRadius = innerRadius;
}
if (radius !== undefined) {
options.radius = radius;
}
}
Object.assign(this, {
strength: 0.1,
center: [0, 0],
innerRadius: 0,
radius: -1,
}, options);
}

@@ -43,0 +62,0 @@

{
"name": "@pixi/filter-zoom-blur",
"version": "3.0.3",
"version": "3.1.0",
"main": "lib/filter-zoom-blur.cjs.js",

@@ -28,4 +28,4 @@ "bundle": "dist/filter-zoom-blur.js",

],
"dependencies": {
"@pixi/core": "^5.0.0-X"
"peerDependencies": {
"@pixi/core": "^5.0.0"
},

@@ -35,3 +35,3 @@ "devDependencies": {

},
"gitHead": "0483cafcb2d4324a7db147c641d13ffc33ca657a"
"gitHead": "f4fb8729c0c5a7c35dcb60cbe6d096d5d8947c94"
}
/// <reference types="pixi.js" />
declare module "@pixi/filter-zoom-blur" {
export interface ZoomBlurFilterOptions {
strength?:number;
center?:PIXI.Point|[number, number];
innerRadius?:number;
radius?:number;
}
export class ZoomBlurFilter extends PIXI.Filter {
constructor(strength?:number, center?:PIXI.Point|number[], innerRadius?:number, radius?:number);
constructor(options?:ZoomBlurFilterOptions);
constructor(strength?:number, center?:PIXI.Point|[number, number], innerRadius?:number, radius?:number);
strength:number;
center:PIXI.Point|number[];
center:PIXI.Point|[number, number];
innerRadius:number;

@@ -8,0 +15,0 @@ radius:number;

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