index.d.ts 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /// <reference path="./global.d.ts" />
  2. import type { DRAW_MODES } from '@pixi/constants';
  3. import type { IArrayBuffer } from '@pixi/core';
  4. import type { IDestroyOptions } from '@pixi/display';
  5. import type { IPoint } from '@pixi/math';
  6. import type { ITypedArray } from '@pixi/core';
  7. import { Mesh } from '@pixi/mesh';
  8. import { MeshGeometry } from '@pixi/mesh';
  9. import type { Renderer } from '@pixi/core';
  10. import { Texture } from '@pixi/core';
  11. export declare interface NineSlicePlane extends GlobalMixins.NineSlicePlane {
  12. }
  13. /**
  14. * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful
  15. * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically
  16. *
  17. *```js
  18. * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15);
  19. * ```
  20. * <pre>
  21. * A B
  22. * +---+----------------------+---+
  23. * C | 1 | 2 | 3 |
  24. * +---+----------------------+---+
  25. * | | | |
  26. * | 4 | 5 | 6 |
  27. * | | | |
  28. * +---+----------------------+---+
  29. * D | 7 | 8 | 9 |
  30. * +---+----------------------+---+
  31. * When changing this objects width and/or height:
  32. * areas 1 3 7 and 9 will remain unscaled.
  33. * areas 2 and 8 will be stretched horizontally
  34. * areas 4 and 6 will be stretched vertically
  35. * area 5 will be stretched both horizontally and vertically
  36. * </pre>
  37. * @memberof PIXI
  38. */
  39. export declare class NineSlicePlane extends SimplePlane {
  40. private _origWidth;
  41. private _origHeight;
  42. /**
  43. * The width of the left column (a).
  44. * @private
  45. */
  46. _leftWidth: number;
  47. /**
  48. * The width of the right column (b)
  49. * @private
  50. */
  51. _rightWidth: number;
  52. /**
  53. * The height of the top row (c)
  54. * @private
  55. */
  56. _topHeight: number;
  57. /**
  58. * The height of the bottom row (d)
  59. * @private
  60. */
  61. _bottomHeight: number;
  62. /**
  63. * @param texture - The texture to use on the NineSlicePlane.
  64. * @param {number} [leftWidth=10] - size of the left vertical bar (A)
  65. * @param {number} [topHeight=10] - size of the top horizontal bar (C)
  66. * @param {number} [rightWidth=10] - size of the right vertical bar (B)
  67. * @param {number} [bottomHeight=10] - size of the bottom horizontal bar (D)
  68. */
  69. constructor(texture: Texture, leftWidth?: number, topHeight?: number, rightWidth?: number, bottomHeight?: number);
  70. textureUpdated(): void;
  71. get vertices(): ITypedArray;
  72. set vertices(value: ITypedArray);
  73. /** Updates the horizontal vertices. */
  74. updateHorizontalVertices(): void;
  75. /** Updates the vertical vertices. */
  76. updateVerticalVertices(): void;
  77. /**
  78. * Returns the smaller of a set of vertical and horizontal scale of nine slice corners.
  79. * @returns Smaller number of vertical and horizontal scale.
  80. */
  81. private _getMinScale;
  82. /** The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */
  83. get width(): number;
  84. set width(value: number);
  85. /** The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */
  86. get height(): number;
  87. set height(value: number);
  88. /** The width of the left column. */
  89. get leftWidth(): number;
  90. set leftWidth(value: number);
  91. /** The width of the right column. */
  92. get rightWidth(): number;
  93. set rightWidth(value: number);
  94. /** The height of the top row. */
  95. get topHeight(): number;
  96. set topHeight(value: number);
  97. /** The height of the bottom row. */
  98. get bottomHeight(): number;
  99. set bottomHeight(value: number);
  100. /** Refreshes NineSlicePlane coords. All of them. */
  101. private _refresh;
  102. }
  103. /**
  104. * @memberof PIXI
  105. */
  106. export declare class PlaneGeometry extends MeshGeometry {
  107. segWidth: number;
  108. segHeight: number;
  109. width: number;
  110. height: number;
  111. /**
  112. * @param width - The width of the plane.
  113. * @param height - The height of the plane.
  114. * @param segWidth - Number of horizontal segments.
  115. * @param segHeight - Number of vertical segments.
  116. */
  117. constructor(width?: number, height?: number, segWidth?: number, segHeight?: number);
  118. /**
  119. * Refreshes plane coordinates
  120. * @private
  121. */
  122. build(): void;
  123. }
  124. /**
  125. * RopeGeometry allows you to draw a geometry across several points and then manipulate these points.
  126. *
  127. * ```js
  128. * for (let i = 0; i < 20; i++) {
  129. * points.push(new PIXI.Point(i * 50, 0));
  130. * };
  131. * const rope = new PIXI.RopeGeometry(100, points);
  132. * ```
  133. * @memberof PIXI
  134. */
  135. export declare class RopeGeometry extends MeshGeometry {
  136. /** An array of points that determine the rope. */
  137. points: IPoint[];
  138. /** Rope texture scale, if zero then the rope texture is stretched. */
  139. readonly textureScale: number;
  140. /**
  141. * The width (i.e., thickness) of the rope.
  142. * @readonly
  143. */
  144. _width: number;
  145. /**
  146. * @param width - The width (i.e., thickness) of the rope.
  147. * @param points - An array of {@link PIXI.Point} objects to construct this rope.
  148. * @param textureScale - By default the rope texture will be stretched to match
  149. * rope length. If textureScale is positive this value will be treated as a scaling
  150. * factor and the texture will preserve its aspect ratio instead. To create a tiling rope
  151. * set baseTexture.wrapMode to {@link PIXI.WRAP_MODES.REPEAT} and use a power of two texture,
  152. * then set textureScale=1 to keep the original texture pixel size.
  153. * In order to reduce alpha channel artifacts provide a larger texture and downsample -
  154. * i.e. set textureScale=0.5 to scale it down twice.
  155. */
  156. constructor(width: number, points: IPoint[], textureScale?: number);
  157. /**
  158. * The width (i.e., thickness) of the rope.
  159. * @readonly
  160. */
  161. get width(): number;
  162. /** Refreshes Rope indices and uvs */
  163. private build;
  164. /** refreshes vertices of Rope mesh */
  165. updateVertices(): void;
  166. update(): void;
  167. }
  168. /**
  169. * The Simple Mesh class mimics Mesh in PixiJS v4, providing easy-to-use constructor arguments.
  170. * For more robust customization, use {@link PIXI.Mesh}.
  171. * @memberof PIXI
  172. */
  173. export declare class SimpleMesh extends Mesh {
  174. /** Upload vertices buffer each frame. */
  175. autoUpdate: boolean;
  176. /**
  177. * @param texture - The texture to use
  178. * @param {Float32Array} [vertices] - if you want to specify the vertices
  179. * @param {Float32Array} [uvs] - if you want to specify the uvs
  180. * @param {Uint16Array} [indices] - if you want to specify the indices
  181. * @param drawMode - the drawMode, can be any of the Mesh.DRAW_MODES consts
  182. */
  183. constructor(texture?: Texture, vertices?: IArrayBuffer, uvs?: IArrayBuffer, indices?: IArrayBuffer, drawMode?: DRAW_MODES);
  184. /**
  185. * Collection of vertices data.
  186. * @type {Float32Array}
  187. */
  188. get vertices(): ITypedArray;
  189. set vertices(value: ITypedArray);
  190. _render(renderer: Renderer): void;
  191. }
  192. /**
  193. * The SimplePlane allows you to draw a texture across several points and then manipulate these points
  194. *
  195. *```js
  196. * for (let i = 0; i < 20; i++) {
  197. * points.push(new PIXI.Point(i * 50, 0));
  198. * };
  199. * let SimplePlane = new PIXI.SimplePlane(PIXI.Texture.from("snake.png"), points);
  200. * ```
  201. * @memberof PIXI
  202. */
  203. export declare class SimplePlane extends Mesh {
  204. /** The geometry is automatically updated when the texture size changes. */
  205. autoResize: boolean;
  206. protected _textureID: number;
  207. /**
  208. * @param texture - The texture to use on the SimplePlane.
  209. * @param verticesX - The number of vertices in the x-axis
  210. * @param verticesY - The number of vertices in the y-axis
  211. */
  212. constructor(texture: Texture, verticesX?: number, verticesY?: number);
  213. /**
  214. * Method used for overrides, to do something in case texture frame was changed.
  215. * Meshes based on plane can override it and change more details based on texture.
  216. */
  217. textureUpdated(): void;
  218. set texture(value: Texture);
  219. get texture(): Texture;
  220. _render(renderer: Renderer): void;
  221. destroy(options?: IDestroyOptions | boolean): void;
  222. }
  223. /**
  224. * The rope allows you to draw a texture across several points and then manipulate these points
  225. *
  226. *```js
  227. * for (let i = 0; i < 20; i++) {
  228. * points.push(new PIXI.Point(i * 50, 0));
  229. * };
  230. * let rope = new PIXI.SimpleRope(PIXI.Texture.from("snake.png"), points);
  231. * ```
  232. * @memberof PIXI
  233. */
  234. export declare class SimpleRope extends Mesh {
  235. autoUpdate: boolean;
  236. /**
  237. * @param texture - The texture to use on the rope.
  238. * @param points - An array of {@link PIXI.Point} objects to construct this rope.
  239. * @param {number} textureScale - Optional. Positive values scale rope texture
  240. * keeping its aspect ratio. You can reduce alpha channel artifacts by providing a larger texture
  241. * and downsampling here. If set to zero, texture will be stretched instead.
  242. */
  243. constructor(texture: Texture, points: IPoint[], textureScale?: number);
  244. _render(renderer: Renderer): void;
  245. }
  246. export { }