From 3d4f7c31822df1a2427b432dca494ed9f798ba7c Mon Sep 17 00:00:00 2001 From: bbazukun123 Date: Wed, 14 Feb 2024 19:42:00 +0000 Subject: [PATCH] Chore: OutlineFilter deprecate non-options constructor (#430) * Chore: Outline Filter Deprecations * Cleanup --------- Co-authored-by: Baz Utsahajit --- src/outline/OutlineFilter.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/outline/OutlineFilter.ts b/src/outline/OutlineFilter.ts index 7d9e75462..6e6fb03ab 100644 --- a/src/outline/OutlineFilter.ts +++ b/src/outline/OutlineFilter.ts @@ -1,4 +1,4 @@ -import { Color, Filter, GlProgram, GpuProgram } from 'pixi.js'; +import { Color, deprecation, Filter, GlProgram, GpuProgram } from 'pixi.js'; import { vertex, wgslVertex } from '../defaults'; import fragment from './outline.frag'; import source from './outline.wgsl'; @@ -77,8 +77,35 @@ export class OutlineFilter extends Filter private _quality!: number; private _color!: Color; - constructor(options?: OutlineFilterOptions) + constructor(options?: OutlineFilterOptions); + /** + * @deprecated since 6.0.0 + * + * @param {number} [thickness=1] - The tickness of the outline. Make it 2 times more for resolution 2 + * @param {number} [color=0x000000] - The color of the outline. + * @param {number} [quality=0.1] - The quality of the outline from `0` to `1`, using a higher quality + * setting will result in slower performance and more accuracy. + * @param {number} [alpha=1.0] - The alpha of the outline. + * @param {boolean} [knockout=false] - Only render outline, not the contents. + */ + constructor(thickness?: number, color?: number, quality?: number, alpha?: number, knockout?: boolean); + constructor(...args: [OutlineFilterOptions?] | [number?, number?, number?, number?, boolean?]) { + let options = args[0] ?? {}; + + if (typeof options === 'number') + { + // eslint-disable-next-line max-len + deprecation('6.0.0', 'OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }'); + + options = { thickness: options }; + + if (args[1] !== undefined) options.color = args[1]; + if (args[2] !== undefined) options.quality = args[2]; + if (args[3] !== undefined) options.alpha = args[3]; + if (args[4] !== undefined) options.knockout = args[4]; + } + options = { ...OutlineFilter.DEFAULT_OPTIONS, ...options }; const quality = options.quality ?? 0.1;