- 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
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
import { vertex } from '@tools/fragments';
import fragment from './twist.frag';
import { Filter } from '@pixi/core';
import { Point } from '@pixi/math';
interface TwistFilterOptions {
radius: number;
angle: number;
padding: number;
offset: Point;
}
/**
* This filter applies a twist effect making display objects appear twisted in the given direction.<br>
* 
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
* @see @pixi/filter-twist
* @see pixi-filters
*/
class TwistFilter extends Filter
{
/** Default constructor options. */
public static readonly defaults: TwistFilterOptions = {
radius: 200,
angle: 4,
padding: 20,
offset: new Point(),
};
/**
* @param {object} [options] - Object object to use.
* @param {number} [options.radius=200] - The radius of the twist.
* @param {number} [options.angle=4] - The angle of the twist.
* @param {number} [options.padding=20] - Padding for filter area.
* @param {PIXI.Point} [options.offset] - Center of twist, in local, pixel coordinates.
*/
constructor(options?: Partial<TwistFilterOptions>)
{
super(vertex, fragment);
Object.assign(this, TwistFilter.defaults, options);
}
/**
* This point describes the the offset of the twist.
*
* @member {PIXI.Point}
*/
get offset(): Point
{
return this.uniforms.offset;
}
set offset(value: Point)
{
this.uniforms.offset = value;
}
/**
* The radius of the twist.
*/
get radius(): number
{
return this.uniforms.radius;
}
set radius(value: number)
{
this.uniforms.radius = value;
}
/**
* The angle of the twist.
*/
get angle(): number
{
return this.uniforms.angle;
}
set angle(value: number)
{
this.uniforms.angle = value;
}
}
export { TwistFilter };
export type { TwistFilterOptions };