1
- import { Filter , GlProgram , GpuProgram } from 'pixi.js' ;
1
+ import { deprecation , Filter , GlProgram , GpuProgram } from 'pixi.js' ;
2
2
import { vertex , wgslVertex } from '../defaults' ;
3
3
import fragment from './radial-blur.frag' ;
4
4
import source from './radial-blur.wgsl' ;
@@ -18,7 +18,7 @@ export interface RadialBlurFilterOptions
18
18
* once defined in the constructor
19
19
* @default {x:0,y:0}
20
20
*/
21
- center ?: PointData ;
21
+ center ?: PointData | number [ ] ;
22
22
/**
23
23
* The kernelSize of the blur filter. Must be odd number >= 3
24
24
* @default 5
@@ -59,8 +59,38 @@ export class RadialBlurFilter extends Filter
59
59
private _angle ! : number ;
60
60
private _kernelSize ! : number ;
61
61
62
- constructor ( options ?: RadialBlurFilterOptions )
62
+ constructor ( options ?: RadialBlurFilterOptions ) ;
63
+ /**
64
+ * @deprecated since 6.0.0
65
+ *
66
+ * @param {number } [angle=0] - Sets the angle of the motion for blur effect.
67
+ * @param {PIXI.Point|number[] } [center=[0,0]] - The center of the radial.
68
+ * @param {number } [kernelSize=5] - The kernelSize of the blur filter. Must be odd number >= 3
69
+ * @param {number } [radius=-1] - The maximum size of the blur radius, `-1` is infinite
70
+ */
71
+ constructor ( angle ?: number , center ?: PointData | number [ ] , kernelSize ?: number , radius ?: number ) ;
72
+ constructor ( ...args : [ RadialBlurFilterOptions ?] | [ number ?, ( PointData | number [ ] ) ?, number ?, number ?] )
63
73
{
74
+ let options = args [ 0 ] ?? { } ;
75
+
76
+ if ( typeof options === 'number' )
77
+ {
78
+ // eslint-disable-next-line max-len
79
+ deprecation ( '6.0.0' , 'RadialBlurFilter constructor params are now options object. See params: { angle, center, kernelSize, radius }' ) ;
80
+
81
+ options = { angle : options } ;
82
+
83
+ if ( args [ 1 ] )
84
+ {
85
+ const x = 'x' in args [ 1 ] ? args [ 1 ] . x : args [ 1 ] [ 0 ] ;
86
+ const y = 'y' in args [ 1 ] ? args [ 1 ] . y : args [ 1 ] [ 1 ] ;
87
+
88
+ options . center = { x, y } ;
89
+ }
90
+ if ( args [ 2 ] ) options . kernelSize = args [ 2 ] ;
91
+ if ( args [ 3 ] ) options . radius = args [ 3 ] ;
92
+ }
93
+
64
94
options = { ...RadialBlurFilter . DEFAULT_OPTIONS , ...options } ;
65
95
66
96
const gpuProgram = GpuProgram . from ( {
@@ -87,7 +117,7 @@ export class RadialBlurFilter extends Filter
87
117
radialBlurUniforms : {
88
118
uRadian : { value : 0 , type : 'f32' } ,
89
119
uCenter : { value : options . center , type : 'vec2<f32>' } ,
90
- uKernelSize : { value : options . kernelSize , type : 'f32 ' } ,
120
+ uKernelSize : { value : options . kernelSize , type : 'i32 ' } ,
91
121
uRadius : { value : options . radius , type : 'f32' } ,
92
122
}
93
123
} ,
@@ -122,7 +152,15 @@ export class RadialBlurFilter extends Filter
122
152
* @default {x:0,y:0}
123
153
*/
124
154
get center ( ) : PointData { return this . uniforms . uCenter ; }
125
- set center ( value : PointData ) { this . uniforms . uCenter = value ; }
155
+ set center ( value : PointData | number [ ] )
156
+ {
157
+ if ( Array . isArray ( value ) )
158
+ {
159
+ value = { x : value [ 0 ] , y : value [ 1 ] } ;
160
+ }
161
+
162
+ this . uniforms . uCenter = value ;
163
+ }
126
164
127
165
/**
128
166
* Sets the velocity of the motion for blur effect on the `x` axis
0 commit comments