index.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. /// <reference path="./global.d.ts" />
  2. /**
  3. * The Circle object is used to help draw graphics and can also be used to specify a hit area for displayObjects.
  4. * @memberof PIXI
  5. */
  6. export declare class Circle {
  7. /** @default 0 */
  8. x: number;
  9. /** @default 0 */
  10. y: number;
  11. /** @default 0 */
  12. radius: number;
  13. /**
  14. * The type of the object, mainly used to avoid `instanceof` checks
  15. * @default PIXI.SHAPES.CIRC
  16. * @see PIXI.SHAPES
  17. */
  18. readonly type: SHAPES.CIRC;
  19. /**
  20. * @param x - The X coordinate of the center of this circle
  21. * @param y - The Y coordinate of the center of this circle
  22. * @param radius - The radius of the circle
  23. */
  24. constructor(x?: number, y?: number, radius?: number);
  25. /**
  26. * Creates a clone of this Circle instance
  27. * @returns A copy of the Circle
  28. */
  29. clone(): Circle;
  30. /**
  31. * Checks whether the x and y coordinates given are contained within this circle
  32. * @param x - The X coordinate of the point to test
  33. * @param y - The Y coordinate of the point to test
  34. * @returns Whether the x/y coordinates are within this Circle
  35. */
  36. contains(x: number, y: number): boolean;
  37. /**
  38. * Returns the framing rectangle of the circle as a Rectangle object
  39. * @returns The framing rectangle
  40. */
  41. getBounds(): Rectangle;
  42. toString(): string;
  43. }
  44. /**
  45. * Conversion factor for converting degrees to radians.
  46. * @static
  47. * @member {number}
  48. * @memberof PIXI
  49. */
  50. export declare const DEG_TO_RAD: number;
  51. /**
  52. * The Ellipse object is used to help draw graphics and can also be used to specify a hit area for displayObjects.
  53. * @memberof PIXI
  54. */
  55. export declare class Ellipse {
  56. /** @default 0 */
  57. x: number;
  58. /** @default 0 */
  59. y: number;
  60. /** @default 0 */
  61. width: number;
  62. /** @default 0 */
  63. height: number;
  64. /**
  65. * The type of the object, mainly used to avoid `instanceof` checks
  66. * @default PIXI.SHAPES.ELIP
  67. * @see PIXI.SHAPES
  68. */
  69. readonly type: SHAPES.ELIP;
  70. /**
  71. * @param x - The X coordinate of the center of this ellipse
  72. * @param y - The Y coordinate of the center of this ellipse
  73. * @param halfWidth - The half width of this ellipse
  74. * @param halfHeight - The half height of this ellipse
  75. */
  76. constructor(x?: number, y?: number, halfWidth?: number, halfHeight?: number);
  77. /**
  78. * Creates a clone of this Ellipse instance
  79. * @returns {PIXI.Ellipse} A copy of the ellipse
  80. */
  81. clone(): Ellipse;
  82. /**
  83. * Checks whether the x and y coordinates given are contained within this ellipse
  84. * @param x - The X coordinate of the point to test
  85. * @param y - The Y coordinate of the point to test
  86. * @returns Whether the x/y coords are within this ellipse
  87. */
  88. contains(x: number, y: number): boolean;
  89. /**
  90. * Returns the framing rectangle of the ellipse as a Rectangle object
  91. * @returns The framing rectangle
  92. */
  93. getBounds(): Rectangle;
  94. toString(): string;
  95. }
  96. declare type GD8Symmetry = number;
  97. /**
  98. * Implements the dihedral group D8, which is similar to
  99. * [group D4]{@link http://mathworld.wolfram.com/DihedralGroupD4.html};
  100. * D8 is the same but with diagonals, and it is used for texture
  101. * rotations.
  102. *
  103. * The directions the U- and V- axes after rotation
  104. * of an angle of `a: GD8Constant` are the vectors `(uX(a), uY(a))`
  105. * and `(vX(a), vY(a))`. These aren't necessarily unit vectors.
  106. *
  107. * **Origin:**<br>
  108. * This is the small part of gameofbombs.com portal system. It works.
  109. * @see PIXI.groupD8.E
  110. * @see PIXI.groupD8.SE
  111. * @see PIXI.groupD8.S
  112. * @see PIXI.groupD8.SW
  113. * @see PIXI.groupD8.W
  114. * @see PIXI.groupD8.NW
  115. * @see PIXI.groupD8.N
  116. * @see PIXI.groupD8.NE
  117. * @author Ivan @ivanpopelyshev
  118. * @namespace PIXI.groupD8
  119. * @memberof PIXI
  120. */
  121. export declare const groupD8: {
  122. /**
  123. * | Rotation | Direction |
  124. * |----------|-----------|
  125. * | 0° | East |
  126. * @memberof PIXI.groupD8
  127. * @constant {PIXI.GD8Symmetry}
  128. */
  129. E: number;
  130. /**
  131. * | Rotation | Direction |
  132. * |----------|-----------|
  133. * | 45°↻ | Southeast |
  134. * @memberof PIXI.groupD8
  135. * @constant {PIXI.GD8Symmetry}
  136. */
  137. SE: number;
  138. /**
  139. * | Rotation | Direction |
  140. * |----------|-----------|
  141. * | 90°↻ | South |
  142. * @memberof PIXI.groupD8
  143. * @constant {PIXI.GD8Symmetry}
  144. */
  145. S: number;
  146. /**
  147. * | Rotation | Direction |
  148. * |----------|-----------|
  149. * | 135°↻ | Southwest |
  150. * @memberof PIXI.groupD8
  151. * @constant {PIXI.GD8Symmetry}
  152. */
  153. SW: number;
  154. /**
  155. * | Rotation | Direction |
  156. * |----------|-----------|
  157. * | 180° | West |
  158. * @memberof PIXI.groupD8
  159. * @constant {PIXI.GD8Symmetry}
  160. */
  161. W: number;
  162. /**
  163. * | Rotation | Direction |
  164. * |-------------|--------------|
  165. * | -135°/225°↻ | Northwest |
  166. * @memberof PIXI.groupD8
  167. * @constant {PIXI.GD8Symmetry}
  168. */
  169. NW: number;
  170. /**
  171. * | Rotation | Direction |
  172. * |-------------|--------------|
  173. * | -90°/270°↻ | North |
  174. * @memberof PIXI.groupD8
  175. * @constant {PIXI.GD8Symmetry}
  176. */
  177. N: number;
  178. /**
  179. * | Rotation | Direction |
  180. * |-------------|--------------|
  181. * | -45°/315°↻ | Northeast |
  182. * @memberof PIXI.groupD8
  183. * @constant {PIXI.GD8Symmetry}
  184. */
  185. NE: number;
  186. /**
  187. * Reflection about Y-axis.
  188. * @memberof PIXI.groupD8
  189. * @constant {PIXI.GD8Symmetry}
  190. */
  191. MIRROR_VERTICAL: number;
  192. /**
  193. * Reflection about the main diagonal.
  194. * @memberof PIXI.groupD8
  195. * @constant {PIXI.GD8Symmetry}
  196. */
  197. MAIN_DIAGONAL: number;
  198. /**
  199. * Reflection about X-axis.
  200. * @memberof PIXI.groupD8
  201. * @constant {PIXI.GD8Symmetry}
  202. */
  203. MIRROR_HORIZONTAL: number;
  204. /**
  205. * Reflection about reverse diagonal.
  206. * @memberof PIXI.groupD8
  207. * @constant {PIXI.GD8Symmetry}
  208. */
  209. REVERSE_DIAGONAL: number;
  210. /**
  211. * @memberof PIXI.groupD8
  212. * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
  213. * @returns {PIXI.GD8Symmetry} The X-component of the U-axis
  214. * after rotating the axes.
  215. */
  216. uX: (ind: GD8Symmetry) => GD8Symmetry;
  217. /**
  218. * @memberof PIXI.groupD8
  219. * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
  220. * @returns {PIXI.GD8Symmetry} The Y-component of the U-axis
  221. * after rotating the axes.
  222. */
  223. uY: (ind: GD8Symmetry) => GD8Symmetry;
  224. /**
  225. * @memberof PIXI.groupD8
  226. * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
  227. * @returns {PIXI.GD8Symmetry} The X-component of the V-axis
  228. * after rotating the axes.
  229. */
  230. vX: (ind: GD8Symmetry) => GD8Symmetry;
  231. /**
  232. * @memberof PIXI.groupD8
  233. * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
  234. * @returns {PIXI.GD8Symmetry} The Y-component of the V-axis
  235. * after rotating the axes.
  236. */
  237. vY: (ind: GD8Symmetry) => GD8Symmetry;
  238. /**
  239. * @memberof PIXI.groupD8
  240. * @param {PIXI.GD8Symmetry} rotation - symmetry whose opposite
  241. * is needed. Only rotations have opposite symmetries while
  242. * reflections don't.
  243. * @returns {PIXI.GD8Symmetry} The opposite symmetry of `rotation`
  244. */
  245. inv: (rotation: GD8Symmetry) => GD8Symmetry;
  246. /**
  247. * Composes the two D8 operations.
  248. *
  249. * Taking `^` as reflection:
  250. *
  251. * | | E=0 | S=2 | W=4 | N=6 | E^=8 | S^=10 | W^=12 | N^=14 |
  252. * |-------|-----|-----|-----|-----|------|-------|-------|-------|
  253. * | E=0 | E | S | W | N | E^ | S^ | W^ | N^ |
  254. * | S=2 | S | W | N | E | S^ | W^ | N^ | E^ |
  255. * | W=4 | W | N | E | S | W^ | N^ | E^ | S^ |
  256. * | N=6 | N | E | S | W | N^ | E^ | S^ | W^ |
  257. * | E^=8 | E^ | N^ | W^ | S^ | E | N | W | S |
  258. * | S^=10 | S^ | E^ | N^ | W^ | S | E | N | W |
  259. * | W^=12 | W^ | S^ | E^ | N^ | W | S | E | N |
  260. * | N^=14 | N^ | W^ | S^ | E^ | N | W | S | E |
  261. *
  262. * [This is a Cayley table]{@link https://en.wikipedia.org/wiki/Cayley_table}
  263. * @memberof PIXI.groupD8
  264. * @param {PIXI.GD8Symmetry} rotationSecond - Second operation, which
  265. * is the row in the above cayley table.
  266. * @param {PIXI.GD8Symmetry} rotationFirst - First operation, which
  267. * is the column in the above cayley table.
  268. * @returns {PIXI.GD8Symmetry} Composed operation
  269. */
  270. add: (rotationSecond: GD8Symmetry, rotationFirst: GD8Symmetry) => GD8Symmetry;
  271. /**
  272. * Reverse of `add`.
  273. * @memberof PIXI.groupD8
  274. * @param {PIXI.GD8Symmetry} rotationSecond - Second operation
  275. * @param {PIXI.GD8Symmetry} rotationFirst - First operation
  276. * @returns {PIXI.GD8Symmetry} Result
  277. */
  278. sub: (rotationSecond: GD8Symmetry, rotationFirst: GD8Symmetry) => GD8Symmetry;
  279. /**
  280. * Adds 180 degrees to rotation, which is a commutative
  281. * operation.
  282. * @memberof PIXI.groupD8
  283. * @param {number} rotation - The number to rotate.
  284. * @returns {number} Rotated number
  285. */
  286. rotate180: (rotation: number) => number;
  287. /**
  288. * Checks if the rotation angle is vertical, i.e. south
  289. * or north. It doesn't work for reflections.
  290. * @memberof PIXI.groupD8
  291. * @param {PIXI.GD8Symmetry} rotation - The number to check.
  292. * @returns {boolean} Whether or not the direction is vertical
  293. */
  294. isVertical: (rotation: GD8Symmetry) => boolean;
  295. /**
  296. * Approximates the vector `V(dx,dy)` into one of the
  297. * eight directions provided by `groupD8`.
  298. * @memberof PIXI.groupD8
  299. * @param {number} dx - X-component of the vector
  300. * @param {number} dy - Y-component of the vector
  301. * @returns {PIXI.GD8Symmetry} Approximation of the vector into
  302. * one of the eight symmetries.
  303. */
  304. byDirection: (dx: number, dy: number) => GD8Symmetry;
  305. /**
  306. * Helps sprite to compensate texture packer rotation.
  307. * @memberof PIXI.groupD8
  308. * @param {PIXI.Matrix} matrix - sprite world matrix
  309. * @param {PIXI.GD8Symmetry} rotation - The rotation factor to use.
  310. * @param {number} tx - sprite anchoring
  311. * @param {number} ty - sprite anchoring
  312. */
  313. matrixAppendRotationInv: (matrix: Matrix, rotation: GD8Symmetry, tx?: number, ty?: number) => void;
  314. };
  315. export declare interface IPoint extends IPointData {
  316. copyFrom(p: IPointData): this;
  317. copyTo<T extends IPoint>(p: T): T;
  318. equals(p: IPointData): boolean;
  319. set(x?: number, y?: number): void;
  320. }
  321. export declare interface IPointData extends GlobalMixins.IPointData {
  322. x: number;
  323. y: number;
  324. }
  325. export declare type IShape = Circle | Ellipse | Polygon | Rectangle | RoundedRectangle;
  326. export declare interface ISize {
  327. width: number;
  328. height: number;
  329. }
  330. /**
  331. * The PixiJS Matrix as a class makes it a lot faster.
  332. *
  333. * Here is a representation of it:
  334. * ```js
  335. * | a | c | tx|
  336. * | b | d | ty|
  337. * | 0 | 0 | 1 |
  338. * ```
  339. * @memberof PIXI
  340. */
  341. export declare class Matrix {
  342. /** @default 1 */
  343. a: number;
  344. /** @default 0 */
  345. b: number;
  346. /** @default 0 */
  347. c: number;
  348. /** @default 1 */
  349. d: number;
  350. /** @default 0 */
  351. tx: number;
  352. /** @default 0 */
  353. ty: number;
  354. array: Float32Array | null;
  355. /**
  356. * @param a - x scale
  357. * @param b - y skew
  358. * @param c - x skew
  359. * @param d - y scale
  360. * @param tx - x translation
  361. * @param ty - y translation
  362. */
  363. constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
  364. /**
  365. * Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
  366. *
  367. * a = array[0]
  368. * b = array[1]
  369. * c = array[3]
  370. * d = array[4]
  371. * tx = array[2]
  372. * ty = array[5]
  373. * @param array - The array that the matrix will be populated from.
  374. */
  375. fromArray(array: number[]): void;
  376. /**
  377. * Sets the matrix properties.
  378. * @param a - Matrix component
  379. * @param b - Matrix component
  380. * @param c - Matrix component
  381. * @param d - Matrix component
  382. * @param tx - Matrix component
  383. * @param ty - Matrix component
  384. * @returns This matrix. Good for chaining method calls.
  385. */
  386. set(a: number, b: number, c: number, d: number, tx: number, ty: number): this;
  387. /**
  388. * Creates an array from the current Matrix object.
  389. * @param transpose - Whether we need to transpose the matrix or not
  390. * @param [out=new Float32Array(9)] - If provided the array will be assigned to out
  391. * @returns The newly created array which contains the matrix
  392. */
  393. toArray(transpose: boolean, out?: Float32Array): Float32Array;
  394. /**
  395. * Get a new position with the current transformation applied.
  396. * Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
  397. * @param pos - The origin
  398. * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
  399. * @returns {PIXI.Point} The new point, transformed through this matrix
  400. */
  401. apply<P extends IPointData = Point>(pos: IPointData, newPos?: P): P;
  402. /**
  403. * Get a new position with the inverse of the current transformation applied.
  404. * Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
  405. * @param pos - The origin
  406. * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
  407. * @returns {PIXI.Point} The new point, inverse-transformed through this matrix
  408. */
  409. applyInverse<P extends IPointData = Point>(pos: IPointData, newPos?: P): P;
  410. /**
  411. * Translates the matrix on the x and y.
  412. * @param x - How much to translate x by
  413. * @param y - How much to translate y by
  414. * @returns This matrix. Good for chaining method calls.
  415. */
  416. translate(x: number, y: number): this;
  417. /**
  418. * Applies a scale transformation to the matrix.
  419. * @param x - The amount to scale horizontally
  420. * @param y - The amount to scale vertically
  421. * @returns This matrix. Good for chaining method calls.
  422. */
  423. scale(x: number, y: number): this;
  424. /**
  425. * Applies a rotation transformation to the matrix.
  426. * @param angle - The angle in radians.
  427. * @returns This matrix. Good for chaining method calls.
  428. */
  429. rotate(angle: number): this;
  430. /**
  431. * Appends the given Matrix to this Matrix.
  432. * @param matrix - The matrix to append.
  433. * @returns This matrix. Good for chaining method calls.
  434. */
  435. append(matrix: Matrix): this;
  436. /**
  437. * Sets the matrix based on all the available properties
  438. * @param x - Position on the x axis
  439. * @param y - Position on the y axis
  440. * @param pivotX - Pivot on the x axis
  441. * @param pivotY - Pivot on the y axis
  442. * @param scaleX - Scale on the x axis
  443. * @param scaleY - Scale on the y axis
  444. * @param rotation - Rotation in radians
  445. * @param skewX - Skew on the x axis
  446. * @param skewY - Skew on the y axis
  447. * @returns This matrix. Good for chaining method calls.
  448. */
  449. setTransform(x: number, y: number, pivotX: number, pivotY: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number): this;
  450. /**
  451. * Prepends the given Matrix to this Matrix.
  452. * @param matrix - The matrix to prepend
  453. * @returns This matrix. Good for chaining method calls.
  454. */
  455. prepend(matrix: Matrix): this;
  456. /**
  457. * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
  458. * @param transform - The transform to apply the properties to.
  459. * @returns The transform with the newly applied properties
  460. */
  461. decompose(transform: Transform): Transform;
  462. /**
  463. * Inverts this matrix
  464. * @returns This matrix. Good for chaining method calls.
  465. */
  466. invert(): this;
  467. /**
  468. * Resets this Matrix to an identity (default) matrix.
  469. * @returns This matrix. Good for chaining method calls.
  470. */
  471. identity(): this;
  472. /**
  473. * Creates a new Matrix object with the same values as this one.
  474. * @returns A copy of this matrix. Good for chaining method calls.
  475. */
  476. clone(): Matrix;
  477. /**
  478. * Changes the values of the given matrix to be the same as the ones in this matrix
  479. * @param matrix - The matrix to copy to.
  480. * @returns The matrix given in parameter with its values updated.
  481. */
  482. copyTo(matrix: Matrix): Matrix;
  483. /**
  484. * Changes the values of the matrix to be the same as the ones in given matrix
  485. * @param {PIXI.Matrix} matrix - The matrix to copy from.
  486. * @returns {PIXI.Matrix} this
  487. */
  488. copyFrom(matrix: Matrix): this;
  489. toString(): string;
  490. /**
  491. * A default (identity) matrix
  492. * @readonly
  493. */
  494. static get IDENTITY(): Matrix;
  495. /**
  496. * A temp matrix
  497. * @readonly
  498. */
  499. static get TEMP_MATRIX(): Matrix;
  500. }
  501. export declare interface ObservablePoint extends GlobalMixins.Point, IPoint {
  502. }
  503. /**
  504. * The ObservablePoint object represents a location in a two-dimensional coordinate system, where `x` represents
  505. * the position on the horizontal axis and `y` represents the position on the vertical axis.
  506. *
  507. * An `ObservablePoint` is a point that triggers a callback when the point's position is changed.
  508. * @memberof PIXI
  509. */
  510. export declare class ObservablePoint<T = any> implements IPoint {
  511. /** The callback function triggered when `x` and/or `y` are changed */
  512. cb: (this: T) => any;
  513. /** The owner of the callback */
  514. scope: any;
  515. _x: number;
  516. _y: number;
  517. /**
  518. * Creates a new `ObservablePoint`
  519. * @param cb - callback function triggered when `x` and/or `y` are changed
  520. * @param scope - owner of callback
  521. * @param {number} [x=0] - position of the point on the x axis
  522. * @param {number} [y=0] - position of the point on the y axis
  523. */
  524. constructor(cb: (this: T) => any, scope: T, x?: number, y?: number);
  525. /**
  526. * Creates a clone of this point.
  527. * The callback and scope params can be overridden otherwise they will default
  528. * to the clone object's values.
  529. * @override
  530. * @param cb - The callback function triggered when `x` and/or `y` are changed
  531. * @param scope - The owner of the callback
  532. * @returns a copy of this observable point
  533. */
  534. clone(cb?: (this: T) => any, scope?: any): ObservablePoint;
  535. /**
  536. * Sets the point to a new `x` and `y` position.
  537. * If `y` is omitted, both `x` and `y` will be set to `x`.
  538. * @param {number} [x=0] - position of the point on the x axis
  539. * @param {number} [y=x] - position of the point on the y axis
  540. * @returns The observable point instance itself
  541. */
  542. set(x?: number, y?: number): this;
  543. /**
  544. * Copies x and y from the given point (`p`)
  545. * @param p - The point to copy from. Can be any of type that is or extends `IPointData`
  546. * @returns The observable point instance itself
  547. */
  548. copyFrom(p: IPointData): this;
  549. /**
  550. * Copies this point's x and y into that of the given point (`p`)
  551. * @param p - The point to copy to. Can be any of type that is or extends `IPointData`
  552. * @returns The point (`p`) with values updated
  553. */
  554. copyTo<T extends IPoint>(p: T): T;
  555. /**
  556. * Accepts another point (`p`) and returns `true` if the given point is equal to this point
  557. * @param p - The point to check
  558. * @returns Returns `true` if both `x` and `y` are equal
  559. */
  560. equals(p: IPointData): boolean;
  561. toString(): string;
  562. /** Position of the observable point on the x axis. */
  563. get x(): number;
  564. set x(value: number);
  565. /** Position of the observable point on the y axis. */
  566. get y(): number;
  567. set y(value: number);
  568. }
  569. /**
  570. * Two Pi.
  571. * @static
  572. * @member {number}
  573. * @memberof PIXI
  574. */
  575. export declare const PI_2: number;
  576. export declare interface Point extends GlobalMixins.Point, IPoint {
  577. }
  578. /**
  579. * The Point object represents a location in a two-dimensional coordinate system, where `x` represents
  580. * the position on the horizontal axis and `y` represents the position on the vertical axis
  581. * @class
  582. * @memberof PIXI
  583. * @implements {IPoint}
  584. */
  585. export declare class Point implements IPoint {
  586. /** Position of the point on the x axis */
  587. x: number;
  588. /** Position of the point on the y axis */
  589. y: number;
  590. /**
  591. * Creates a new `Point`
  592. * @param {number} [x=0] - position of the point on the x axis
  593. * @param {number} [y=0] - position of the point on the y axis
  594. */
  595. constructor(x?: number, y?: number);
  596. /**
  597. * Creates a clone of this point
  598. * @returns A clone of this point
  599. */
  600. clone(): Point;
  601. /**
  602. * Copies `x` and `y` from the given point into this point
  603. * @param p - The point to copy from
  604. * @returns The point instance itself
  605. */
  606. copyFrom(p: IPointData): this;
  607. /**
  608. * Copies this point's x and y into the given point (`p`).
  609. * @param p - The point to copy to. Can be any of type that is or extends `IPointData`
  610. * @returns The point (`p`) with values updated
  611. */
  612. copyTo<T extends IPoint>(p: T): T;
  613. /**
  614. * Accepts another point (`p`) and returns `true` if the given point is equal to this point
  615. * @param p - The point to check
  616. * @returns Returns `true` if both `x` and `y` are equal
  617. */
  618. equals(p: IPointData): boolean;
  619. /**
  620. * Sets the point to a new `x` and `y` position.
  621. * If `y` is omitted, both `x` and `y` will be set to `x`.
  622. * @param {number} [x=0] - position of the point on the `x` axis
  623. * @param {number} [y=x] - position of the point on the `y` axis
  624. * @returns The point instance itself
  625. */
  626. set(x?: number, y?: number): this;
  627. toString(): string;
  628. }
  629. /**
  630. * A class to define a shape via user defined coordinates.
  631. * @memberof PIXI
  632. */
  633. export declare class Polygon {
  634. /** An array of the points of this polygon. */
  635. points: number[];
  636. /** `false` after moveTo, `true` after `closePath`. In all other cases it is `true`. */
  637. closeStroke: boolean;
  638. /**
  639. * The type of the object, mainly used to avoid `instanceof` checks
  640. * @default PIXI.SHAPES.POLY
  641. * @see PIXI.SHAPES
  642. */
  643. readonly type: SHAPES.POLY;
  644. constructor(points: IPointData[] | number[]);
  645. constructor(...points: IPointData[] | number[]);
  646. /**
  647. * Creates a clone of this polygon.
  648. * @returns - A copy of the polygon.
  649. */
  650. clone(): Polygon;
  651. /**
  652. * Checks whether the x and y coordinates passed to this function are contained within this polygon.
  653. * @param x - The X coordinate of the point to test.
  654. * @param y - The Y coordinate of the point to test.
  655. * @returns - Whether the x/y coordinates are within this polygon.
  656. */
  657. contains(x: number, y: number): boolean;
  658. toString(): string;
  659. }
  660. /**
  661. * Conversion factor for converting radians to degrees.
  662. * @static
  663. * @member {number} RAD_TO_DEG
  664. * @memberof PIXI
  665. */
  666. export declare const RAD_TO_DEG: number;
  667. export declare interface Rectangle extends GlobalMixins.Rectangle {
  668. }
  669. /**
  670. * Size object, contains width and height
  671. * @memberof PIXI
  672. * @typedef {object} ISize@typedef {object} ISize
  673. * @property {number} width - Width component
  674. * @property {number} height - Height component
  675. */
  676. /**
  677. * Rectangle object is an area defined by its position, as indicated by its top-left corner
  678. * point (x, y) and by its width and its height.
  679. * @memberof PIXI
  680. */
  681. export declare class Rectangle {
  682. /** @default 0 */
  683. x: number;
  684. /** @default 0 */
  685. y: number;
  686. /** @default 0 */
  687. width: number;
  688. /** @default 0 */
  689. height: number;
  690. /**
  691. * The type of the object, mainly used to avoid `instanceof` checks
  692. * @default PIXI.SHAPES.RECT
  693. * @see PIXI.SHAPES
  694. */
  695. readonly type: SHAPES.RECT;
  696. /**
  697. * @param x - The X coordinate of the upper-left corner of the rectangle
  698. * @param y - The Y coordinate of the upper-left corner of the rectangle
  699. * @param width - The overall width of the rectangle
  700. * @param height - The overall height of the rectangle
  701. */
  702. constructor(x?: string | number, y?: string | number, width?: string | number, height?: string | number);
  703. /** Returns the left edge of the rectangle. */
  704. get left(): number;
  705. /** Returns the right edge of the rectangle. */
  706. get right(): number;
  707. /** Returns the top edge of the rectangle. */
  708. get top(): number;
  709. /** Returns the bottom edge of the rectangle. */
  710. get bottom(): number;
  711. /** A constant empty rectangle. */
  712. static get EMPTY(): Rectangle;
  713. /**
  714. * Creates a clone of this Rectangle
  715. * @returns a copy of the rectangle
  716. */
  717. clone(): Rectangle;
  718. /**
  719. * Copies another rectangle to this one.
  720. * @param rectangle - The rectangle to copy from.
  721. * @returns Returns itself.
  722. */
  723. copyFrom(rectangle: Rectangle): Rectangle;
  724. /**
  725. * Copies this rectangle to another one.
  726. * @param rectangle - The rectangle to copy to.
  727. * @returns Returns given parameter.
  728. */
  729. copyTo(rectangle: Rectangle): Rectangle;
  730. /**
  731. * Checks whether the x and y coordinates given are contained within this Rectangle
  732. * @param x - The X coordinate of the point to test
  733. * @param y - The Y coordinate of the point to test
  734. * @returns Whether the x/y coordinates are within this Rectangle
  735. */
  736. contains(x: number, y: number): boolean;
  737. /**
  738. * Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.
  739. * Returns true only if the area of the intersection is >0, this means that Rectangles
  740. * sharing a side are not overlapping. Another side effect is that an arealess rectangle
  741. * (width or height equal to zero) can't intersect any other rectangle.
  742. * @param {Rectangle} other - The Rectangle to intersect with `this`.
  743. * @param {Matrix} transform - The transformation matrix of `other`.
  744. * @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.
  745. */
  746. intersects(other: Rectangle, transform?: Matrix): boolean;
  747. /**
  748. * Pads the rectangle making it grow in all directions.
  749. * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
  750. * @param paddingX - The horizontal padding amount.
  751. * @param paddingY - The vertical padding amount.
  752. * @returns Returns itself.
  753. */
  754. pad(paddingX?: number, paddingY?: number): this;
  755. /**
  756. * Fits this rectangle around the passed one.
  757. * @param rectangle - The rectangle to fit.
  758. * @returns Returns itself.
  759. */
  760. fit(rectangle: Rectangle): this;
  761. /**
  762. * Enlarges rectangle that way its corners lie on grid
  763. * @param resolution - resolution
  764. * @param eps - precision
  765. * @returns Returns itself.
  766. */
  767. ceil(resolution?: number, eps?: number): this;
  768. /**
  769. * Enlarges this rectangle to include the passed rectangle.
  770. * @param rectangle - The rectangle to include.
  771. * @returns Returns itself.
  772. */
  773. enlarge(rectangle: Rectangle): this;
  774. toString(): string;
  775. }
  776. /**
  777. * The Rounded Rectangle object is an area that has nice rounded corners, as indicated by its
  778. * top-left corner point (x, y) and by its width and its height and its radius.
  779. * @memberof PIXI
  780. */
  781. export declare class RoundedRectangle {
  782. /** @default 0 */
  783. x: number;
  784. /** @default 0 */
  785. y: number;
  786. /** @default 0 */
  787. width: number;
  788. /** @default 0 */
  789. height: number;
  790. /** @default 20 */
  791. radius: number;
  792. /**
  793. * The type of the object, mainly used to avoid `instanceof` checks
  794. * @default PIXI.SHAPES.RREC
  795. * @see PIXI.SHAPES
  796. */
  797. readonly type: SHAPES.RREC;
  798. /**
  799. * @param x - The X coordinate of the upper-left corner of the rounded rectangle
  800. * @param y - The Y coordinate of the upper-left corner of the rounded rectangle
  801. * @param width - The overall width of this rounded rectangle
  802. * @param height - The overall height of this rounded rectangle
  803. * @param radius - Controls the radius of the rounded corners
  804. */
  805. constructor(x?: number, y?: number, width?: number, height?: number, radius?: number);
  806. /**
  807. * Creates a clone of this Rounded Rectangle.
  808. * @returns - A copy of the rounded rectangle.
  809. */
  810. clone(): RoundedRectangle;
  811. /**
  812. * Checks whether the x and y coordinates given are contained within this Rounded Rectangle
  813. * @param x - The X coordinate of the point to test.
  814. * @param y - The Y coordinate of the point to test.
  815. * @returns - Whether the x/y coordinates are within this Rounded Rectangle.
  816. */
  817. contains(x: number, y: number): boolean;
  818. toString(): string;
  819. }
  820. /**
  821. * Constants that identify shapes, mainly to prevent `instanceof` calls.
  822. * @static
  823. * @memberof PIXI
  824. * @enum {number}
  825. * @property {number} POLY Polygon
  826. * @property {number} RECT Rectangle
  827. * @property {number} CIRC Circle
  828. * @property {number} ELIP Ellipse
  829. * @property {number} RREC Rounded Rectangle
  830. */
  831. export declare enum SHAPES {
  832. POLY = 0,
  833. RECT = 1,
  834. CIRC = 2,
  835. ELIP = 3,
  836. RREC = 4
  837. }
  838. export declare interface Transform extends GlobalMixins.Transform {
  839. }
  840. /**
  841. * Transform that takes care about its versions.
  842. * @memberof PIXI
  843. */
  844. export declare class Transform {
  845. /** A default (identity) transform. */
  846. static readonly IDENTITY: Transform;
  847. /** The world transformation matrix. */
  848. worldTransform: Matrix;
  849. /** The local transformation matrix. */
  850. localTransform: Matrix;
  851. /** The coordinate of the object relative to the local coordinates of the parent. */
  852. position: ObservablePoint;
  853. /** The scale factor of the object. */
  854. scale: ObservablePoint;
  855. /** The pivot point of the displayObject that it rotates around. */
  856. pivot: ObservablePoint;
  857. /** The skew amount, on the x and y axis. */
  858. skew: ObservablePoint;
  859. /** The locally unique ID of the parent's world transform used to calculate the current world transformation matrix. */
  860. _parentID: number;
  861. /** The locally unique ID of the world transform. */
  862. _worldID: number;
  863. /** The rotation amount. */
  864. protected _rotation: number;
  865. /**
  866. * The X-coordinate value of the normalized local X axis,
  867. * the first column of the local transformation matrix without a scale.
  868. */
  869. protected _cx: number;
  870. /**
  871. * The Y-coordinate value of the normalized local X axis,
  872. * the first column of the local transformation matrix without a scale.
  873. */
  874. protected _sx: number;
  875. /**
  876. * The X-coordinate value of the normalized local Y axis,
  877. * the second column of the local transformation matrix without a scale.
  878. */
  879. protected _cy: number;
  880. /**
  881. * The Y-coordinate value of the normalized local Y axis,
  882. * the second column of the local transformation matrix without a scale.
  883. */
  884. protected _sy: number;
  885. /** The locally unique ID of the local transform. */
  886. protected _localID: number;
  887. /** The locally unique ID of the local transform used to calculate the current local transformation matrix. */
  888. protected _currentLocalID: number;
  889. constructor();
  890. /** Called when a value changes. */
  891. protected onChange(): void;
  892. /** Called when the skew or the rotation changes. */
  893. protected updateSkew(): void;
  894. toString(): string;
  895. /** Updates the local transformation matrix. */
  896. updateLocalTransform(): void;
  897. /**
  898. * Updates the local and the world transformation matrices.
  899. * @param parentTransform - The parent transform
  900. */
  901. updateTransform(parentTransform: Transform): void;
  902. /**
  903. * Decomposes a matrix and sets the transforms properties based on it.
  904. * @param matrix - The matrix to decompose
  905. */
  906. setFromMatrix(matrix: Matrix): void;
  907. /** The rotation of the object in radians. */
  908. get rotation(): number;
  909. set rotation(value: number);
  910. }
  911. export { }