babylon.asciiArtPostProcess.d.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. declare module BABYLON {
  2. /**
  3. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  4. *
  5. * It basically takes care rendering the font front the given font size to a texture.
  6. * This is used later on in the postprocess.
  7. */
  8. class AsciiArtFontTexture extends BaseTexture {
  9. private _font;
  10. private _text;
  11. private _charSize;
  12. /**
  13. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  14. */
  15. readonly charSize: number;
  16. /**
  17. * Create a new instance of the Ascii Art FontTexture class
  18. * @param name the name of the texture
  19. * @param font the font to use, use the W3C CSS notation
  20. * @param text the caracter set to use in the rendering.
  21. * @param scene the scene that owns the texture
  22. */
  23. constructor(name: string, font: string, text: string, scene?: Nullable<Scene>);
  24. /**
  25. * Gets the max char width of a font.
  26. * @param font the font to use, use the W3C CSS notation
  27. * @return the max char width
  28. */
  29. private getFontWidth(font);
  30. /**
  31. * Gets the max char height of a font.
  32. * @param font the font to use, use the W3C CSS notation
  33. * @return the max char height
  34. */
  35. private getFontHeight(font);
  36. /**
  37. * Clones the current AsciiArtTexture.
  38. * @return the clone of the texture.
  39. */
  40. clone(): AsciiArtFontTexture;
  41. /**
  42. * Parses a json object representing the texture and returns an instance of it.
  43. * @param source the source JSON representation
  44. * @param scene the scene to create the texture for
  45. * @return the parsed texture
  46. */
  47. static Parse(source: any, scene: Scene): AsciiArtFontTexture;
  48. }
  49. /**
  50. * Option available in the Ascii Art Post Process.
  51. */
  52. interface IAsciiArtPostProcessOptions {
  53. /**
  54. * The font to use following the w3c font definition.
  55. */
  56. font?: string;
  57. /**
  58. * The character set to use in the postprocess.
  59. */
  60. characterSet?: string;
  61. /**
  62. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  63. * This number is defined between 0 and 1;
  64. */
  65. mixToTile?: number;
  66. /**
  67. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68. * This number is defined between 0 and 1;
  69. */
  70. mixToNormal?: number;
  71. }
  72. /**
  73. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  74. *
  75. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  77. */
  78. class AsciiArtPostProcess extends PostProcess {
  79. /**
  80. * The font texture used to render the char in the post process.
  81. */
  82. private _asciiArtFontTexture;
  83. /**
  84. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85. * This number is defined between 0 and 1;
  86. */
  87. mixToTile: number;
  88. /**
  89. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  90. * This number is defined between 0 and 1;
  91. */
  92. mixToNormal: number;
  93. /**
  94. * Instantiates a new Ascii Art Post Process.
  95. * @param name the name to give to the postprocess
  96. * @camera the camera to apply the post process to.
  97. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  98. */
  99. constructor(name: string, camera: Camera, options?: string | IAsciiArtPostProcessOptions);
  100. }
  101. }