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

@pixi/filter-radial-blur

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 2.7.0 to 3.0.0

dist/filter-radial-blur.js

106

lib/filter-radial-blur.esm.js
/*!
* @pixi/filter-radial-blur - v2.7.0
* Compiled Sun, 13 Jan 2019 22:51:52 UTC
* Compiled Fri, 10 May 2019 22:56:42 UTC
*

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

*/
import{Filter as n}from"pixi.js";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 float uRadian;\nuniform vec2 uCenter;\nuniform float uRadius;\nuniform int uKernelSize;\n\nconst int MAX_KERNEL_SIZE = 2048;\n\nvoid main(void)\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n if (uKernelSize == 0)\n {\n gl_FragColor = color;\n return;\n }\n\n float aspect = filterArea.y / filterArea.x;\n vec2 center = uCenter.xy / filterArea.xy;\n float gradient = uRadius / filterArea.x * 0.3;\n float radius = uRadius / filterArea.x - gradient * 0.5;\n int k = uKernelSize - 1;\n\n vec2 coord = vTextureCoord;\n vec2 dir = vec2(center - coord);\n float dist = length(vec2(dir.x, dir.y * aspect));\n\n float radianStep = uRadian;\n if (radius >= 0.0 && dist > radius) {\n float delta = dist - radius;\n float gap = gradient;\n float scale = 1.0 - abs(delta / gap);\n if (scale <= 0.0) {\n gl_FragColor = color;\n return;\n }\n radianStep *= scale;\n }\n radianStep /= float(k);\n\n float s = sin(radianStep);\n float c = cos(radianStep);\n mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c));\n\n for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) {\n if (i == k) {\n break;\n }\n\n coord -= center;\n coord.y *= aspect;\n coord = rotationMatrix * coord;\n coord.y /= aspect;\n coord += center;\n\n vec4 sample = texture2D(uSampler, coord);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample;\n }\n\n gl_FragColor = color / float(uKernelSize);\n}\n",t=function(n){function t(t,i,o,a){void 0===t&&(t=0),void 0===i&&(i=[0,0]),void 0===o&&(o=5),void 0===a&&(a=-1),n.call(this,e,r),this._angle=0,this.angle=t,this.center=i,this.kernelSize=o,this.radius=a}n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t;var i={angle:{configurable:!0},center:{configurable:!0},radius:{configurable:!0}};return t.prototype.apply=function(n,e,r,t){this.uniforms.uKernelSize=0!==this._angle?this.kernelSize:0,n.applyFilter(this,e,r,t)},i.angle.set=function(n){this._angle=n,this.uniforms.uRadian=n*Math.PI/180},i.angle.get=function(){return this._angle},i.center.get=function(){return this.uniforms.uCenter},i.center.set=function(n){this.uniforms.uCenter=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}(n);export{t as RadialBlurFilter};
import { Filter } from '@pixi/core';
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}";
var fragment = "varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform float uRadian;\nuniform vec2 uCenter;\nuniform float uRadius;\nuniform int uKernelSize;\n\nconst int MAX_KERNEL_SIZE = 2048;\n\nvoid main(void)\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n if (uKernelSize == 0)\n {\n gl_FragColor = color;\n return;\n }\n\n float aspect = filterArea.y / filterArea.x;\n vec2 center = uCenter.xy / filterArea.xy;\n float gradient = uRadius / filterArea.x * 0.3;\n float radius = uRadius / filterArea.x - gradient * 0.5;\n int k = uKernelSize - 1;\n\n vec2 coord = vTextureCoord;\n vec2 dir = vec2(center - coord);\n float dist = length(vec2(dir.x, dir.y * aspect));\n\n float radianStep = uRadian;\n if (radius >= 0.0 && dist > radius) {\n float delta = dist - radius;\n float gap = gradient;\n float scale = 1.0 - abs(delta / gap);\n if (scale <= 0.0) {\n gl_FragColor = color;\n return;\n }\n radianStep *= scale;\n }\n radianStep /= float(k);\n\n float s = sin(radianStep);\n float c = cos(radianStep);\n mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c));\n\n for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) {\n if (i == k) {\n break;\n }\n\n coord -= center;\n coord.y *= aspect;\n coord = rotationMatrix * coord;\n coord.y /= aspect;\n coord += center;\n\n vec4 sample = texture2D(uSampler, coord);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample;\n }\n\n gl_FragColor = color / float(uKernelSize);\n}\n";
/**
* The RadialBlurFilter applies a Motion blur to an object.<br>
* ![original](../tools/screenshots/dist/original.png)![filter](../tools/screenshots/dist/radial-blur.png)
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
* @see {@link https://www.npmjs.com/package/@pixi/filter-radial-blur|@pixi/filter-radial-blur}
* @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters}
* @param {number} [angle=0] Sets the angle of the motion for blur effect.
* @param {PIXI.Point|number[]} [center=[0,0]] The center of the radial.
* @param {number} [kernelSize=5] - The kernelSize of the blur filter. But be odd number >= 3
* @param {number} [radius=-1] - The maximum size of the blur radius, `-1` is infinite
*/
var RadialBlurFilter = /*@__PURE__*/(function (Filter) {
function RadialBlurFilter(angle, center, kernelSize, radius) {
if ( angle === void 0 ) angle = 0;
if ( center === void 0 ) center = [0, 0];
if ( kernelSize === void 0 ) kernelSize = 5;
if ( radius === void 0 ) radius = -1;
Filter.call(this, vertex, fragment);
this._angle = 0;
this.angle = angle;
this.center = center;
this.kernelSize = kernelSize;
this.radius = radius;
}
if ( Filter ) RadialBlurFilter.__proto__ = Filter;
RadialBlurFilter.prototype = Object.create( Filter && Filter.prototype );
RadialBlurFilter.prototype.constructor = RadialBlurFilter;
var prototypeAccessors = { angle: { configurable: true },center: { configurable: true },radius: { configurable: true } };
/**
* Override existing apply method in PIXI.Filter
* @private
*/
RadialBlurFilter.prototype.apply = function apply (filterManager, input, output, clear) {
this.uniforms.uKernelSize = this._angle !== 0 ? this.kernelSize : 0;
filterManager.applyFilter(this, input, output, clear);
};
/**
* Sets the angle in degrees of the motion for blur effect.
*
* @member {PIXI.Point|number[]}
* @default [0, 0]
*/
prototypeAccessors.angle.set = function (value) {
this._angle = value;
this.uniforms.uRadian = value * Math.PI / 180;
};
prototypeAccessors.angle.get = function () {
return this._angle;
};
/**
* 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;
};
/**
* Outer radius of the effect. The default value of `-1` is infinite.
*
* @member {number}
* @default -1
*/
prototypeAccessors.radius.get = function () {
return this.uniforms.uRadius;
};
prototypeAccessors.radius.set = function (value) {
if (value < 0 || value === Infinity) {
value = -1;
}
this.uniforms.uRadius = value;
};
Object.defineProperties( RadialBlurFilter.prototype, prototypeAccessors );
return RadialBlurFilter;
}(Filter));
export { RadialBlurFilter };
//# sourceMappingURL=filter-radial-blur.esm.js.map

16

package.json
{
"name": "@pixi/filter-radial-blur",
"version": "2.7.0",
"main": "lib/filter-radial-blur.js",
"description": "PixiJS v4 filter to apply a radial blur effect",
"version": "3.0.0",
"main": "lib/filter-radial-blur.cjs.js",
"bundle": "dist/filter-radial-blur.js",
"description": "PixiJS filter to apply a radial blur effect",
"author": "finscn <finscn@gmail.com>",

@@ -21,11 +22,12 @@ "module": "lib/filter-radial-blur.esm.js",

"lib",
"dist",
"types.d.ts"
],
"peerDependencies": {
"pixi.js": ">=4.5.0"
"dependencies": {
"@pixi/core": "^5.0.0-X"
},
"devDependencies": {
"@tools/fragments": "^2.0.0"
"@tools/fragments": "^3.0.0"
},
"gitHead": "a1329fadd2910c48842c92f254be77d971a823ca"
"gitHead": "0902eca3fe476dd7dacc9330f504d8e2ade6c9bd"
}
# RadialBlurFilter
PixiJS v4 filter to apply a radial blur effect.
PixiJS filter to apply a radial blur effect.

@@ -5,0 +5,0 @@ ## Installation

/// <reference types="pixi.js" />
declare namespace PIXI.filters {
class RadialBlurFilter extends PIXI.Filter<{}> {
declare module "@pixi/filter-radial-blur" {
export class RadialBlurFilter extends PIXI.Filter {
constructor(angle?:number, center?:number[]|PIXI.Point, kernelSize?:number, radius?:number);

@@ -10,6 +10,2 @@ angle:number;

}
}
declare module "@pixi/filter-radial-blur" {
export = PIXI.filters;
}
}

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