Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

64 wiersze
1.4 KiB

  1. define([
  2. 'js/rendering/shaders/outline/vert',
  3. 'js/rendering/shaders/outline/frag'
  4. ], function (
  5. vert,
  6. frag
  7. ) {
  8. let OutlineFilter = function (viewWidth, viewHeight, thickness, color) {
  9. thickness = thickness || 1;
  10. PIXI.Filter.call(this,
  11. vert,
  12. frag.replace(/%THICKNESS%/gi, (1.0 / thickness).toFixed(7))
  13. );
  14. this.uniforms.pixelWidth = 0.002;
  15. this.uniforms.pixelHeight = 1.0 / (viewHeight || 1);
  16. this.uniforms.thickness = thickness;
  17. this.uniforms.outlineColor = new Float32Array([0, 0, 0, 1]);
  18. this.alpha = 0;
  19. if (color)
  20. this.color = color;
  21. };
  22. OutlineFilter.prototype = Object.create(PIXI.Filter.prototype);
  23. OutlineFilter.prototype.constructor = OutlineFilter;
  24. Object.defineProperties(OutlineFilter.prototype, {
  25. color: {
  26. get: function () {
  27. return PIXI.utils.rgb2hex(this.uniforms.outlineColor);
  28. },
  29. set: function (value) {
  30. PIXI.utils.hex2rgb(value, this.uniforms.outlineColor);
  31. }
  32. },
  33. alpha: {
  34. set: function (value) {
  35. this.uniforms.alpha = value;
  36. }
  37. },
  38. viewWidth: {
  39. get: function () {
  40. return 1 / this.uniforms.pixelWidth;
  41. },
  42. set: function (value) {
  43. this.uniforms.pixelWidth = 1 / value;
  44. }
  45. },
  46. viewHeight: {
  47. get: function () {
  48. return 1 / this.uniforms.pixelHeight;
  49. },
  50. set: function (value) {
  51. this.uniforms.pixelHeight = 1 / value;
  52. }
  53. }
  54. });
  55. return OutlineFilter;
  56. });