- 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
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
import { TiltShiftXFilter } from './TiltShiftXFilter';
import { TiltShiftYFilter } from './TiltShiftYFilter';
import { Filter, FilterSystem, RenderTexture } from '@pixi/core';
import type { Point } from '@pixi/math';
import type { CLEAR_MODES } from '@pixi/constants';
// @author Vico @vicocotea
// original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js
// by Evan Wallace : http://madebyevan.com/
/**
* A TiltShift Filter. Manages the pass of both a TiltShiftXFilter and TiltShiftYFilter.<br>
* 
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
* @see @pixi/filter-tilt-shift
* @see pixi-filters
*/
class TiltShiftFilter extends Filter
{
private tiltShiftXFilter: TiltShiftXFilter;
private tiltShiftYFilter: TiltShiftYFilter;
/**
* @param {number} [blur=100] - The strength of the blur.
* @param {number} [gradientBlur=600] - The strength of the gradient blur.
* @param {PIXI.Point} [start=null] - The Y value to start the effect at.
* @param {PIXI.Point} [end=null] - The Y value to end the effect at.
*/
constructor(blur = 100, gradientBlur = 600, start?: Point, end?: Point)
{
super();
this.tiltShiftXFilter = new TiltShiftXFilter(blur, gradientBlur, start, end);
this.tiltShiftYFilter = new TiltShiftYFilter(blur, gradientBlur, start, end);
}
apply(filterManager: FilterSystem, input: RenderTexture, output: RenderTexture, clearMode: CLEAR_MODES): void
{
const renderTarget = filterManager.getFilterTexture();
this.tiltShiftXFilter.apply(filterManager, input, renderTarget, 1);
this.tiltShiftYFilter.apply(filterManager, renderTarget, output, clearMode);
filterManager.returnFilterTexture(renderTarget);
}
/**
* The strength of the blur.
*/
get blur(): number
{
return this.tiltShiftXFilter.blur;
}
set blur(value: number)
{
this.tiltShiftXFilter.blur = this.tiltShiftYFilter.blur = value;
}
/**
* The strength of the gradient blur.
*/
get gradientBlur(): number
{
return this.tiltShiftXFilter.gradientBlur;
}
set gradientBlur(value: number)
{
this.tiltShiftXFilter.gradientBlur = this.tiltShiftYFilter.gradientBlur = value;
}
/**
* The Y value to start the effect at.
*
* @member {PIXI.Point}
*/
get start(): Point
{
return this.tiltShiftXFilter.start;
}
set start(value: Point)
{
this.tiltShiftXFilter.start = this.tiltShiftYFilter.start = value;
}
/**
* The Y value to end the effect at.
*
* @member {PIXI.Point}
*/
get end(): Point
{
return this.tiltShiftXFilter.end;
}
set end(value: Point)
{
this.tiltShiftXFilter.end = this.tiltShiftYFilter.end = value;
}
}
export { TiltShiftFilter };