poly2tri.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Type definitions for poly2tri v0.9.10
  2. // Project: http://github.com/r3mi/poly2tri.js/
  3. // Definitions by: Elemar Junior <https://github.com/elemarjr/>
  4. // Definitions: https://github.com/borisyankov/DefinitelyTyped
  5. declare module poly2tri {
  6. interface IPointLike {
  7. x: number;
  8. y: number;
  9. }
  10. class Point implements IPointLike {
  11. x: number;
  12. y: number;
  13. constructor(x: number, y: number);
  14. toString(): string;
  15. toJSON(): JSON;
  16. clone(): Point;
  17. set_zero(): Point;
  18. set(x: number, y: number): Point;
  19. negate(): Point;
  20. add(n: IPointLike): Point;
  21. sub(n: IPointLike): Point;
  22. mul(s: number): Point;
  23. length(): number;
  24. normalize(): number;
  25. equals(p: IPointLike): boolean;
  26. static negate(p: IPointLike): Point;
  27. static add(a: IPointLike, b: IPointLike): Point;
  28. static sub(a: IPointLike, b: IPointLike): Point;
  29. static mul(s: number, p: IPointLike): Point;
  30. static cross(a: number, b: number): number;
  31. static cross(a: IPointLike, b: number): number;
  32. static cross(a: IPointLike, b: IPointLike): number;
  33. static cross(a: number, b: IPointLike): number;
  34. static toStringBase(p: IPointLike): string;
  35. static toString(p: IPointLike): string;
  36. static compare(a: IPointLike, b: IPointLike): number;
  37. static equals(a: IPointLike, b: IPointLike): boolean;
  38. static dot(a: IPointLike, b: IPointLike): number;
  39. }
  40. class SweepContext {
  41. constructor(contour: Array<IPointLike>);
  42. constructor(contour: Array<IPointLike>, options: JSON);
  43. addHole(polyline: Array<IPointLike>): SweepContext;
  44. addHoles(holes: Array<Array<IPointLike>>): SweepContext;
  45. addPoint(point: IPointLike): SweepContext;
  46. addPoints(point: Array<IPointLike>): SweepContext;
  47. triangulate(): SweepContext;
  48. getBoundingBox(): { min: IPointLike; max: IPointLike; };
  49. getTriangles(): Array<Triangle>;
  50. }
  51. class Triangle {
  52. constructor(a: IPointLike, b: IPointLike, c: IPointLike);
  53. toString(): string;
  54. getPoint(index: number): IPointLike;
  55. getPoints(): Array<IPointLike>;
  56. containsPoint(point: IPointLike): boolean;
  57. containsPoints(p1: IPointLike, p2: IPointLike): boolean;
  58. isInterior(): boolean;
  59. }
  60. }