- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
import { vertex } from '@tools/fragments';
import fragment from './pixelate.frag';
import { Filter } from '@pixi/core';
import type { Point } from '@pixi/math';
type Size = number | number[] | Point;
/**
* This filter applies a pixelate effect making display objects appear 'blocky'.<br>
* 
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
* @see @pixi/filter-pixelate
* @see pixi-filters
*/
class PixelateFilter extends Filter
{
/**
* @param {PIXI.Point|Array<number>|number} [size=10] - Either the width/height of the size of the pixels, or square size
*/
constructor(size: Size = 10)
{
super(vertex, fragment);
this.size = size;
}
/**
* This a point that describes the size of the blocks.
* x is the width of the block and y is the height.
*
* @member {PIXI.Point|Array<number>|number}
* @default 10
*/
get size(): Size
{
return this.uniforms.size;
}
set size(value: Size)
{
if (typeof value === 'number')
{
value = [value, value];
}
this.uniforms.size = value;
}
}
export { PixelateFilter };