From 272a5bdfcb68e4e0d7f9dc6efed1d47e7f2b6db0 Mon Sep 17 00:00:00 2001 From: Baz Utsahajit Date: Thu, 8 Feb 2024 11:55:53 +0000 Subject: [PATCH 1/7] Chore: Bloom Filter Deprecations --- src/bloom/BloomFilter.ts | 113 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 3 deletions(-) diff --git a/src/bloom/BloomFilter.ts b/src/bloom/BloomFilter.ts index 01b403e6d..ec0d1d5e1 100644 --- a/src/bloom/BloomFilter.ts +++ b/src/bloom/BloomFilter.ts @@ -1,4 +1,18 @@ -import { AlphaFilter, BlurFilterPass, FilterSystem, PointData, RenderSurface, Texture, TexturePool } from 'pixi.js'; +/* eslint-disable max-len */ +import { + AlphaFilter, + BlurFilterPass, + deprecation, + FilterSystem, + PointData, + RenderSurface, + Texture, + TexturePool, + // eslint-disable-next-line camelcase + v8_0_0, +} from 'pixi.js'; + +type DeprecatedBlurValue = number | PointData | number[]; export interface BloomFilterOptions { @@ -12,6 +26,11 @@ export interface BloomFilterOptions * @default 4 */ quality?: number; + /** + * The resolution of the blurX & blurY filter. + * @default 1 + */ + resolution?: number; /** * The kernel size of the blur filter. Must be an odd number between 5 and 15 (inclusive). * @default 5 @@ -34,6 +53,7 @@ export class BloomFilter extends AlphaFilter public static readonly DEFAULT_OPTIONS: BloomFilterOptions = { strength: { x: 2, y: 2 }, quality: 4, + resolution: 1, kernelSize: 5 }; @@ -41,9 +61,33 @@ export class BloomFilter extends AlphaFilter private _blurYFilter: BlurFilterPass; private _strength: PointData; - constructor(options?: BloomFilterOptions) + constructor(options?: BloomFilterOptions); + /** + * @deprecated since 8.0.0 + * + * @param {number|PIXI.PointData|number[]} [blur=2] - Sets the strength of both the blurX and blurY properties simultaneously + * @param {number} [quality=4] - The quality of the blurX & blurY filter. + * @param {number} [resolution=1] - The resolution of the blurX & blurY filter. + * @param {number} [kernelSize=5] - The kernelSize of the blurX & blurY filter.Options: 5, 7, 9, 11, 13, 15. + */ + constructor(blur?: DeprecatedBlurValue, quality?: number, resolution?: number, kernelSize?: number); + constructor(...args: [BloomFilterOptions?] | [DeprecatedBlurValue?, number?, number?, number?]) { - options = { ...BloomFilter.DEFAULT_OPTIONS, ...options }; + let options = args[0] ?? {}; + + if (typeof options === 'number' || Array.isArray(options) || ('x' in options && 'y' in options)) + { + // eslint-disable-next-line max-len + deprecation(v8_0_0, 'BloomFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }'); + + options = { strength: convertDeprecatedBlurValue(options) }; + + if (args[1]) options.quality = args[1]; + if (args[2]) options.resolution = args[2]; + if (args[3]) options.kernelSize = args[3]; + } + + options = { ...BloomFilter.DEFAULT_OPTIONS, ...options } as BloomFilterOptions; super(); @@ -139,5 +183,68 @@ export class BloomFilter extends AlphaFilter this._blurXFilter.blur = this.strengthX; this._blurYFilter.blur = this.strengthY; } + + /** + * @deprecated since 8.0.0 + * + * The strength of both the blurX and blurY properties simultaneously + * @default 2 + */ + get blur(): number + { + deprecation(v8_0_0, 'BloomFilter.blur is deprecated, please use BloomFilter.strength instead'); + + return this.strengthX; + } + set blur(value: number) + { + deprecation(v8_0_0, 'BloomFilter.blur is deprecated, please use BloomFilter.strength instead'); + + this.strength = value; + } + + /** + * @deprecated since 8.0.0 + * + * The strength of the blurX property + * @default 2 + */ + get blurX(): number + { + deprecation(v8_0_0, 'BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead'); + + return this.strengthX; + } + set blurX(value: number) + { + deprecation(v8_0_0, 'BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead'); + + this.strengthX = value; + } + + /** + * @deprecated since 8.0.0 + * + * The strength of the blurY property + * @default 2 + */ + get blurY(): number + { + deprecation(v8_0_0, 'BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead'); + + return this.strengthY; + } + set blurY(value: number) + { + deprecation(v8_0_0, 'BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead'); + + this.strengthY = value; + } } +function convertDeprecatedBlurValue(value: DeprecatedBlurValue): PointData | number +{ + if (typeof value === 'number' || ('x' in value && 'y' in value)) return value; + + return { x: value[0], y: value[1] }; +} From 15f04d31440e62268b0c9a3f5b8b04674498eaab Mon Sep 17 00:00:00 2001 From: Baz Utsahajit Date: Tue, 13 Feb 2024 18:08:17 +0000 Subject: [PATCH 2/7] Address Feedback --- src/bloom/BloomFilter.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/bloom/BloomFilter.ts b/src/bloom/BloomFilter.ts index ec0d1d5e1..1dd61084f 100644 --- a/src/bloom/BloomFilter.ts +++ b/src/bloom/BloomFilter.ts @@ -63,7 +63,7 @@ export class BloomFilter extends AlphaFilter constructor(options?: BloomFilterOptions); /** - * @deprecated since 8.0.0 + * @deprecated since 6.0.0 * * @param {number|PIXI.PointData|number[]} [blur=2] - Sets the strength of both the blurX and blurY properties simultaneously * @param {number} [quality=4] - The quality of the blurX & blurY filter. @@ -80,7 +80,11 @@ export class BloomFilter extends AlphaFilter // eslint-disable-next-line max-len deprecation(v8_0_0, 'BloomFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }'); - options = { strength: convertDeprecatedBlurValue(options) }; + let strength = options; + + if (Array.isArray(strength)) strength = { x: strength[0], y: strength[1] }; + + options = { strength }; if (args[1]) options.quality = args[1]; if (args[2]) options.resolution = args[2]; @@ -241,10 +245,3 @@ export class BloomFilter extends AlphaFilter this.strengthY = value; } } - -function convertDeprecatedBlurValue(value: DeprecatedBlurValue): PointData | number -{ - if (typeof value === 'number' || ('x' in value && 'y' in value)) return value; - - return { x: value[0], y: value[1] }; -} From 95998f8f1f3fbca815568b6c999526f7cf98522c Mon Sep 17 00:00:00 2001 From: Baz Utsahajit Date: Wed, 14 Feb 2024 11:44:30 +0000 Subject: [PATCH 3/7] Cleanup --- src/bloom/BloomFilter.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/bloom/BloomFilter.ts b/src/bloom/BloomFilter.ts index 1dd61084f..5711e04c8 100644 --- a/src/bloom/BloomFilter.ts +++ b/src/bloom/BloomFilter.ts @@ -8,8 +8,6 @@ import { RenderSurface, Texture, TexturePool, - // eslint-disable-next-line camelcase - v8_0_0, } from 'pixi.js'; type DeprecatedBlurValue = number | PointData | number[]; @@ -78,7 +76,7 @@ export class BloomFilter extends AlphaFilter if (typeof options === 'number' || Array.isArray(options) || ('x' in options && 'y' in options)) { // eslint-disable-next-line max-len - deprecation(v8_0_0, 'BloomFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }'); + deprecation('6.0.0', 'BloomFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }'); let strength = options; @@ -196,13 +194,13 @@ export class BloomFilter extends AlphaFilter */ get blur(): number { - deprecation(v8_0_0, 'BloomFilter.blur is deprecated, please use BloomFilter.strength instead'); + deprecation('6.0.0', 'BloomFilter.blur is deprecated, please use BloomFilter.strength instead'); return this.strengthX; } set blur(value: number) { - deprecation(v8_0_0, 'BloomFilter.blur is deprecated, please use BloomFilter.strength instead'); + deprecation('6.0.0', 'BloomFilter.blur is deprecated, please use BloomFilter.strength instead'); this.strength = value; } @@ -215,13 +213,13 @@ export class BloomFilter extends AlphaFilter */ get blurX(): number { - deprecation(v8_0_0, 'BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead'); + deprecation('6.0.0', 'BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead'); return this.strengthX; } set blurX(value: number) { - deprecation(v8_0_0, 'BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead'); + deprecation('6.0.0', 'BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead'); this.strengthX = value; } @@ -234,13 +232,13 @@ export class BloomFilter extends AlphaFilter */ get blurY(): number { - deprecation(v8_0_0, 'BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead'); + deprecation('6.0.0', 'BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead'); return this.strengthY; } set blurY(value: number) { - deprecation(v8_0_0, 'BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead'); + deprecation('6.0.0', 'BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead'); this.strengthY = value; } From b07256d6b5d8eefdc88740486160691f5149478f Mon Sep 17 00:00:00 2001 From: Matt Karl Date: Wed, 14 Feb 2024 11:15:51 -0500 Subject: [PATCH 4/7] Update src/bloom/BloomFilter.ts --- src/bloom/BloomFilter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bloom/BloomFilter.ts b/src/bloom/BloomFilter.ts index 5711e04c8..e32e26021 100644 --- a/src/bloom/BloomFilter.ts +++ b/src/bloom/BloomFilter.ts @@ -225,7 +225,7 @@ export class BloomFilter extends AlphaFilter } /** - * @deprecated since 8.0.0 + * @deprecated since 6.0.0 * * The strength of the blurY property * @default 2 From b22dd18ab6413245cb24f84ad1e7e7f236279fcf Mon Sep 17 00:00:00 2001 From: Matt Karl Date: Wed, 14 Feb 2024 11:15:59 -0500 Subject: [PATCH 5/7] Update src/bloom/BloomFilter.ts --- src/bloom/BloomFilter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bloom/BloomFilter.ts b/src/bloom/BloomFilter.ts index e32e26021..14bbedc49 100644 --- a/src/bloom/BloomFilter.ts +++ b/src/bloom/BloomFilter.ts @@ -206,7 +206,7 @@ export class BloomFilter extends AlphaFilter } /** - * @deprecated since 8.0.0 + * @deprecated since 6.0.0 * * The strength of the blurX property * @default 2 From f6a805fb1005df204de149cb19f70b9457c499f6 Mon Sep 17 00:00:00 2001 From: Matt Karl Date: Wed, 14 Feb 2024 11:16:24 -0500 Subject: [PATCH 6/7] Update src/bloom/BloomFilter.ts --- src/bloom/BloomFilter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bloom/BloomFilter.ts b/src/bloom/BloomFilter.ts index 14bbedc49..92acb09a0 100644 --- a/src/bloom/BloomFilter.ts +++ b/src/bloom/BloomFilter.ts @@ -84,9 +84,9 @@ export class BloomFilter extends AlphaFilter options = { strength }; - if (args[1]) options.quality = args[1]; - if (args[2]) options.resolution = args[2]; - if (args[3]) options.kernelSize = args[3]; + if (args[1] !== undefined) options.quality = args[1]; + if (args[2] !== undefined) options.resolution = args[2]; + if (args[3] !== undefined) options.kernelSize = args[3]; } options = { ...BloomFilter.DEFAULT_OPTIONS, ...options } as BloomFilterOptions; From 6fc8de4227a30b7df12032a68bde9f622ced2dc7 Mon Sep 17 00:00:00 2001 From: Matt Karl Date: Wed, 14 Feb 2024 11:16:35 -0500 Subject: [PATCH 7/7] Update src/bloom/BloomFilter.ts --- src/bloom/BloomFilter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bloom/BloomFilter.ts b/src/bloom/BloomFilter.ts index 92acb09a0..2614df85a 100644 --- a/src/bloom/BloomFilter.ts +++ b/src/bloom/BloomFilter.ts @@ -187,7 +187,7 @@ export class BloomFilter extends AlphaFilter } /** - * @deprecated since 8.0.0 + * @deprecated since 6.0.0 * * The strength of both the blurX and blurY properties simultaneously * @default 2