|
|
@@ -5,32 +5,21 @@ define([ |
|
|
|
vertex, |
|
|
|
fragment |
|
|
|
) { |
|
|
|
const _thickness = 1; |
|
|
|
const _alpha = 1.0; |
|
|
|
const _knockout = false; |
|
|
|
|
|
|
|
class OutlineFilter extends PIXI.Filter { |
|
|
|
constructor (thickness = 5, color = 0xFFFFFF, quality = 0.1, alpha = 1.0, knockout = false) { |
|
|
|
constructor ({ thickness = 5, color = 0xFFFFFF, quality = 0.1, alpha = 1.0, knockout = false }) { |
|
|
|
const angleStep = Math.PI / 2; |
|
|
|
color = PIXI.utils.hex2rgb(color); |
|
|
|
|
|
|
|
super(vertex, fragment.replace('$angleStep$', angleStep)); |
|
|
|
|
|
|
|
this.uniforms.uThickness = new Float32Array([thickness, thickness]); |
|
|
|
this.uniforms.uColor = new Float32Array([0, 0.0, 0.0, 1]); |
|
|
|
this.uniforms.uColor = new Float32Array([1, 1, 1, 1]); |
|
|
|
this.uniforms.uAlpha = alpha; |
|
|
|
this.uniforms.uKnockout = knockout; |
|
|
|
|
|
|
|
Object.assign(this, { thickness, color, quality, alpha, knockout }); |
|
|
|
} |
|
|
|
const rgbColor = PIXI.utils.hex2rgb(color); |
|
|
|
this.uniforms.uColor = PIXI.utils.hex2rgb(rgbColor, this.uniforms.uColor); |
|
|
|
|
|
|
|
getAngleStep (quality) { |
|
|
|
const samples = Math.max( |
|
|
|
quality * MAX_SAMPLES, |
|
|
|
MIN_SAMPLES, |
|
|
|
); |
|
|
|
|
|
|
|
return (Math.PI * 2 / samples).toFixed(7); |
|
|
|
Object.assign(this, { thickness, color, quality, alpha, knockout }); |
|
|
|
} |
|
|
|
|
|
|
|
apply (filterManager, input, output, clear) { |
|
|
|