PathProxy.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import BoundingRect from './BoundingRect';
  2. interface ExtendedCanvasRenderingContext2D extends CanvasRenderingContext2D {
  3. dpr?: number;
  4. }
  5. export declare function normalizeArcAngles(angles: number[], anticlockwise: boolean): void;
  6. export default class PathProxy {
  7. dpr: number;
  8. data: number[] | Float32Array;
  9. private _version;
  10. private _saveData;
  11. private _pendingPtX;
  12. private _pendingPtY;
  13. private _pendingPtDist;
  14. private _ctx;
  15. private _xi;
  16. private _yi;
  17. private _x0;
  18. private _y0;
  19. private _len;
  20. private _pathSegLen;
  21. private _pathLen;
  22. private _ux;
  23. private _uy;
  24. static CMD: {
  25. M: number;
  26. L: number;
  27. C: number;
  28. Q: number;
  29. A: number;
  30. Z: number;
  31. R: number;
  32. };
  33. constructor(notSaveData?: boolean);
  34. increaseVersion(): void;
  35. getVersion(): number;
  36. setScale(sx: number, sy: number, segmentIgnoreThreshold?: number): void;
  37. setDPR(dpr: number): void;
  38. setContext(ctx: ExtendedCanvasRenderingContext2D): void;
  39. getContext(): ExtendedCanvasRenderingContext2D;
  40. beginPath(): this;
  41. reset(): void;
  42. moveTo(x: number, y: number): this;
  43. lineTo(x: number, y: number): this;
  44. bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): this;
  45. quadraticCurveTo(x1: number, y1: number, x2: number, y2: number): this;
  46. arc(cx: number, cy: number, r: number, startAngle: number, endAngle: number, anticlockwise?: boolean): this;
  47. arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this;
  48. rect(x: number, y: number, w: number, h: number): this;
  49. closePath(): this;
  50. fill(ctx: CanvasRenderingContext2D): void;
  51. stroke(ctx: CanvasRenderingContext2D): void;
  52. len(): number;
  53. setData(data: Float32Array | number[]): void;
  54. appendPath(path: PathProxy | PathProxy[]): void;
  55. addData(cmd: number, a?: number, b?: number, c?: number, d?: number, e?: number, f?: number, g?: number, h?: number): void;
  56. private _drawPendingPt;
  57. private _expandData;
  58. toStatic(): void;
  59. getBoundingRect(): BoundingRect;
  60. private _calculateLength;
  61. rebuildPath(ctx: PathRebuilder, percent: number): void;
  62. clone(): PathProxy;
  63. private static initDefaultProps;
  64. }
  65. export interface PathRebuilder {
  66. moveTo(x: number, y: number): void;
  67. lineTo(x: number, y: number): void;
  68. bezierCurveTo(x: number, y: number, x2: number, y2: number, x3: number, y3: number): void;
  69. quadraticCurveTo(x: number, y: number, x2: number, y2: number): void;
  70. arc(cx: number, cy: number, r: number, startAngle: number, endAngle: number, anticlockwise: boolean): void;
  71. ellipse(cx: number, cy: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: boolean): void;
  72. rect(x: number, y: number, width: number, height: number): void;
  73. closePath(): void;
  74. }
  75. export {};