Skip to content

Commit e0c96ca

Browse files
committed
Cleanup
1 parent 37c6566 commit e0c96ca

File tree

1 file changed

+22
-40
lines changed

1 file changed

+22
-40
lines changed

src/rgb-split/RGBSplitFilter.ts

+22-40
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
// eslint-disable-next-line camelcase
2-
import { deprecation, Filter, GlProgram, GpuProgram, PointData, v8_0_0 } from 'pixi.js';
1+
import { deprecation, Filter, GlProgram, GpuProgram, PointData } from 'pixi.js';
32
import { vertex, wgslVertex } from '../defaults';
43
import fragment from './rgb-split.frag';
54
import source from './rgb-split.wgsl';
65

7-
type DeprecatedOffset = [number, number] | PointData;
6+
type OffsetType = PointData | [number, number];
87

98
export interface RGBSplitFilterOptions
109
{
1110
/**
1211
* The amount of offset for the red channel.
1312
* @default {x:-10,y:0}
1413
*/
15-
red?: PointData;
14+
red?: OffsetType;
1615
/**
1716
* The amount of offset for the green channel.
1817
* @default {x:0,y:10}
1918
*/
20-
green?: PointData;
19+
green?: OffsetType;
2120
/**
2221
* The amount of offset for the blue channel.
2322
* @default {x:0,y:0}
2423
*/
25-
blue?: PointData;
24+
blue?: OffsetType;
2625
}
2726

2827
/**
@@ -50,32 +49,26 @@ export class RGBSplitFilter extends Filter
5049

5150
constructor(options?: RGBSplitFilterOptions);
5251
/**
53-
* @deprecated since 8.0.0
52+
* @deprecated since 6.0.0
5453
*
5554
* @param {PIXI.PointData | number[]} [red=[-10,0]] - Red channel offset
5655
* @param {PIXI.PointData | number[]} [green=[0, 10]] - Green channel offset
5756
* @param {PIXI.PointData | number[]} [blue=[0, 0]] - Blue channel offset
5857
*/
59-
constructor(red?: DeprecatedOffset, green?: DeprecatedOffset, blue?: DeprecatedOffset);
60-
constructor(...args: [RGBSplitFilterOptions?] | [DeprecatedOffset?, DeprecatedOffset?, DeprecatedOffset?])
58+
constructor(red?: OffsetType, green?: OffsetType, blue?: OffsetType);
59+
constructor(...args: [RGBSplitFilterOptions?] | [OffsetType?, OffsetType?, OffsetType?])
6160
{
6261
let options = args[0] ?? {};
6362

6463
if (Array.isArray(options) || ('x' in options && 'y' in options))
6564
{
6665
// eslint-disable-next-line max-len
67-
deprecation(v8_0_0, 'RGBSplitFilter constructor params are now options object. See params: { red, green, blue }');
68-
69-
options = { red: convertDeprecatedOffset(options) };
70-
71-
if (args[1])
72-
{
73-
options.green = convertDeprecatedOffset(args[1]);
74-
}
75-
if (args[2])
76-
{
77-
options.blue = convertDeprecatedOffset(args[2]);
78-
}
66+
deprecation('6.0.0', 'RGBSplitFilter constructor params are now options object. See params: { red, green, blue }');
67+
68+
options = { red: options };
69+
70+
if (args[1] !== undefined) options.green = args[1];
71+
if (args[2] !== undefined) options.blue = args[2];
7972
}
8073

8174
options = { ...RGBSplitFilter.DEFAULT_OPTIONS, ...options };
@@ -110,19 +103,20 @@ export class RGBSplitFilter extends Filter
110103
});
111104

112105
this.uniforms = this.resources.rgbSplitUniforms.uniforms;
106+
107+
Object.assign(this, options);
113108
}
114109

115110
/**
116111
* Red channel offset.
117112
* @default {x:-10,y:0}
118113
*/
119114
get red(): PointData { return this.uniforms.uRed; }
120-
set red(value: PointData | DeprecatedOffset)
115+
set red(value: OffsetType)
121116
{
122117
if (Array.isArray(value))
123118
{
124-
deprecation(v8_0_0, 'RGBSplitFilter.red now only accepts {x,y} PointData.');
125-
value = convertDeprecatedOffset(value);
119+
value = { x: value[0], y: value[1] };
126120
}
127121

128122
this.uniforms.uRed = value;
@@ -147,12 +141,11 @@ export class RGBSplitFilter extends Filter
147141
* @default {x:0,y:10}
148142
*/
149143
get green(): PointData { return this.uniforms.uGreen; }
150-
set green(value: PointData | DeprecatedOffset)
144+
set green(value: OffsetType)
151145
{
152146
if (Array.isArray(value))
153147
{
154-
deprecation(v8_0_0, 'RGBSplitFilter.green now only accepts {x,y} PointData.');
155-
value = convertDeprecatedOffset(value);
148+
value = { x: value[0], y: value[1] };
156149
}
157150

158151
this.uniforms.uGreen = value;
@@ -177,12 +170,11 @@ export class RGBSplitFilter extends Filter
177170
* @default {x:0,y:0}
178171
*/
179172
get blue(): PointData { return this.uniforms.uBlue; }
180-
set blue(value: PointData | DeprecatedOffset)
173+
set blue(value: OffsetType)
181174
{
182175
if (Array.isArray(value))
183176
{
184-
deprecation(v8_0_0, 'RGBSplitFilter.blue now only accepts {x,y} PointData.');
185-
value = convertDeprecatedOffset(value);
177+
value = { x: value[0], y: value[1] };
186178
}
187179

188180
this.uniforms.uBlue = value;
@@ -202,13 +194,3 @@ export class RGBSplitFilter extends Filter
202194
get blueY(): number { return this.blue.y; }
203195
set blueY(value: number) { this.blue.y = value; }
204196
}
205-
206-
function convertDeprecatedOffset(value: DeprecatedOffset): PointData
207-
{
208-
if (Array.isArray(value))
209-
{
210-
return { x: value[0], y: value[1] };
211-
}
212-
213-
return value;
214-
}

0 commit comments

Comments
 (0)