Skip to content

Commit

Permalink
Chore: ASCIIFilter deprecate non-options constructor (#414)
Browse files Browse the repository at this point in the history
* Chore: ASCII Filter Deprecations

* Cleanup

---------

Co-authored-by: Baz Utsahajit <[email protected]>
Co-authored-by: Matt Karl <[email protected]>
  • Loading branch information
3 people authored Feb 14, 2024
1 parent d417cd6 commit bdad3a0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/ascii/AsciiFilter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Color, ColorSource, Filter, GlProgram, GpuProgram } from 'pixi.js';
import { Color, ColorSource, deprecation, Filter, GlProgram, GpuProgram } from 'pixi.js';
import { vertex, wgslVertex } from '../defaults';
import fragment from './ascii.frag';
import source from './ascii.wgsl';
Expand Down Expand Up @@ -53,8 +53,25 @@ export class AsciiFilter extends Filter

private _color!: Color;

constructor(options?: AsciiFilterOptions)
constructor(options?: AsciiFilterOptions);
/**
* @deprecated since 6.0.0
*
* @param {number} [size=8] - Size of the font
*/
constructor(size: number);
constructor(...args: [AsciiFilterOptions?] | [number])
{
let options = args[0] ?? {};

if (typeof options === 'number')
{
// eslint-disable-next-line max-len
deprecation('6.0.0', 'AsciiFilter constructor params are now options object. See params: { size, color, replaceColor }');

options = { size: options };
}

const replaceColor = options?.color && options.replaceColor !== false;

options = { ...AsciiFilter.DEFAULT_OPTIONS, ...options } as AsciiFilterOptions;
Expand Down

0 comments on commit bdad3a0

Please sign in to comment.