@pixi/filter-radial-blur
Advanced tools
Comparing version 2.7.0 to 3.0.0
/*! | ||
* @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 |
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
28399
10
230
0
1
+ Added@pixi/core@^5.0.0-X
+ Added@pixi/constants@5.3.12(transitive)
+ Added@pixi/core@5.3.12(transitive)
+ Added@pixi/math@5.3.12(transitive)
+ Added@pixi/runner@5.3.12(transitive)
+ Added@pixi/settings@5.3.12(transitive)
+ Added@pixi/ticker@5.3.12(transitive)
+ Added@pixi/utils@5.3.12(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedeventemitter3@3.1.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.6(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedmath-intrinsics@1.0.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedurl@0.11.4(transitive)
- Removed@pixi/colord@2.9.6(transitive)
- Removed@types/css-font-loading-module@0.0.12(transitive)
- Removed@types/earcut@2.1.4(transitive)
- Removed@webgpu/types@0.1.51(transitive)
- Removed@xmldom/xmldom@0.8.10(transitive)
- Removedeventemitter3@5.0.1(transitive)
- Removedparse-svg-path@0.1.2(transitive)
- Removedpixi.js@8.6.5(transitive)