index.d.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /// <reference path="./global.d.ts" />
  2. import type { ExtensionMetadata } from '@pixi/core';
  3. import type { IBaseTextureOptions } from '@pixi/core';
  4. import type { IDestroyOptions } from '@pixi/display';
  5. import type { IPointData } from '@pixi/math';
  6. import type { ISize } from '@pixi/math';
  7. import { ObjectRenderer } from '@pixi/core';
  8. import type { ObservablePoint } from '@pixi/math';
  9. import { QuadUv } from '@pixi/core';
  10. import { Rectangle } from '@pixi/math';
  11. import type { Renderer } from '@pixi/core';
  12. import { Shader } from '@pixi/core';
  13. import { Sprite } from '@pixi/sprite';
  14. import { State } from '@pixi/core';
  15. import { Texture } from '@pixi/core';
  16. import { TextureMatrix } from '@pixi/core';
  17. import type { TextureSource } from '@pixi/core';
  18. import { Transform } from '@pixi/math';
  19. export declare interface TilingSprite extends GlobalMixins.TilingSprite {
  20. }
  21. /**
  22. * A tiling sprite is a fast way of rendering a tiling image.
  23. * @memberof PIXI
  24. */
  25. export declare class TilingSprite extends Sprite {
  26. /** Tile transform */
  27. tileTransform: Transform;
  28. /** Matrix that is applied to UV to get the coords in Texture normalized space to coords in BaseTexture space. */
  29. uvMatrix: TextureMatrix;
  30. /**
  31. * Flags whether the tiling pattern should originate from the origin instead of the top-left corner in
  32. * local space.
  33. *
  34. * This will make the texture coordinates assigned to each vertex dependent on the value of the anchor. Without
  35. * this, the top-left corner always gets the (0, 0) texture coordinate.
  36. * @default false
  37. */
  38. uvRespectAnchor: boolean;
  39. /**
  40. * @param texture - The texture of the tiling sprite.
  41. * @param width - The width of the tiling sprite.
  42. * @param height - The height of the tiling sprite.
  43. */
  44. constructor(texture: Texture, width?: number, height?: number);
  45. /**
  46. * Changes frame clamping in corresponding textureTransform, shortcut
  47. * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas
  48. * @default 0.5
  49. * @member {number}
  50. */
  51. get clampMargin(): number;
  52. set clampMargin(value: number);
  53. /** The scaling of the image that is being tiled. */
  54. get tileScale(): ObservablePoint;
  55. set tileScale(value: IPointData);
  56. /** The offset of the image that is being tiled. */
  57. get tilePosition(): ObservablePoint;
  58. set tilePosition(value: ObservablePoint);
  59. /**
  60. * @protected
  61. */
  62. protected _onTextureUpdate(): void;
  63. /**
  64. * Renders the object using the WebGL renderer
  65. * @param renderer - The renderer
  66. */
  67. protected _render(renderer: Renderer): void;
  68. /** Updates the bounds of the tiling sprite. */
  69. protected _calculateBounds(): void;
  70. /**
  71. * Gets the local bounds of the sprite object.
  72. * @param rect - Optional output rectangle.
  73. * @returns The bounds.
  74. */
  75. getLocalBounds(rect?: Rectangle): Rectangle;
  76. /**
  77. * Checks if a point is inside this tiling sprite.
  78. * @param point - The point to check.
  79. * @returns Whether or not the sprite contains the point.
  80. */
  81. containsPoint(point: IPointData): boolean;
  82. /**
  83. * Destroys this sprite and optionally its texture and children
  84. * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options
  85. * have been set to that value
  86. * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy
  87. * method called as well. 'options' will be passed on to those calls.
  88. * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well
  89. * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well
  90. */
  91. destroy(options?: IDestroyOptions | boolean): void;
  92. /**
  93. * Helper function that creates a new tiling sprite based on the source you provide.
  94. * The source can be - frame id, image url, video url, canvas element, video element, base texture
  95. * @static
  96. * @param {string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source - Source to create texture from
  97. * @param {object} options - See {@link PIXI.BaseTexture}'s constructor for options.
  98. * @param {number} options.width - required width of the tiling sprite
  99. * @param {number} options.height - required height of the tiling sprite
  100. * - See {@link PIXI.BaseTexture}'s constructor for options.
  101. * @param {number} options.width - required width of the tiling sprite
  102. * @param {number} options.height - required height of the tiling sprite
  103. * @returns {PIXI.TilingSprite} The newly created texture
  104. */
  105. static from(source: TextureSource | Texture, options: ISize & IBaseTextureOptions): TilingSprite;
  106. /** The width of the sprite, setting this will actually modify the scale to achieve the value set. */
  107. get width(): number;
  108. set width(value: number);
  109. /** The height of the TilingSprite, setting this will actually modify the scale to achieve the value set. */
  110. get height(): number;
  111. set height(value: number);
  112. }
  113. /**
  114. * WebGL renderer plugin for tiling sprites
  115. * @class
  116. * @memberof PIXI
  117. * @extends PIXI.ObjectRenderer
  118. */
  119. export declare class TilingSpriteRenderer extends ObjectRenderer {
  120. /** @ignore */
  121. static extension: ExtensionMetadata;
  122. shader: Shader;
  123. simpleShader: Shader;
  124. quad: QuadUv;
  125. readonly state: State;
  126. /**
  127. * constructor for renderer
  128. * @param {PIXI.Renderer} renderer - The renderer this tiling awesomeness works for.
  129. */
  130. constructor(renderer: Renderer);
  131. /** Creates shaders when context is initialized. */
  132. contextChange(): void;
  133. /**
  134. * @param {PIXI.TilingSprite} ts - tilingSprite to be rendered
  135. */
  136. render(ts: TilingSprite): void;
  137. }
  138. export { }