Layer.d.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { ImagePatternObject } from '../graphic/Pattern';
  2. import CanvasPainter from './Painter';
  3. import { GradientObject } from '../graphic/Gradient';
  4. import Eventful from '../core/Eventful';
  5. import { ElementEventCallback } from '../Element';
  6. import Displayable from '../graphic/Displayable';
  7. import BoundingRect from '../core/BoundingRect';
  8. export interface LayerConfig {
  9. clearColor?: string | GradientObject | ImagePatternObject;
  10. motionBlur?: boolean;
  11. lastFrameAlpha?: number;
  12. }
  13. export default class Layer extends Eventful {
  14. id: string;
  15. dom: HTMLCanvasElement;
  16. domBack: HTMLCanvasElement;
  17. ctx: CanvasRenderingContext2D;
  18. ctxBack: CanvasRenderingContext2D;
  19. painter: CanvasPainter;
  20. clearColor: string | GradientObject | ImagePatternObject;
  21. motionBlur: boolean;
  22. lastFrameAlpha: number;
  23. dpr: number;
  24. virtual: boolean;
  25. config: {};
  26. incremental: boolean;
  27. zlevel: number;
  28. maxRepaintRectCount: number;
  29. private _paintRects;
  30. __dirty: boolean;
  31. __firstTimePaint: boolean;
  32. __used: boolean;
  33. __drawIndex: number;
  34. __startIndex: number;
  35. __endIndex: number;
  36. __prevStartIndex: number;
  37. __prevEndIndex: number;
  38. __builtin__: boolean;
  39. constructor(id: string | HTMLCanvasElement, painter: CanvasPainter, dpr?: number);
  40. getElementCount(): number;
  41. afterBrush(): void;
  42. initContext(): void;
  43. setUnpainted(): void;
  44. createBackBuffer(): void;
  45. createRepaintRects(displayList: Displayable[], prevList: Displayable[], viewWidth: number, viewHeight: number): BoundingRect[];
  46. debugGetPaintRects(): BoundingRect[];
  47. resize(width: number, height: number): void;
  48. clear(clearAll?: boolean, clearColor?: string | GradientObject | ImagePatternObject, repaintRects?: BoundingRect[]): void;
  49. refresh: (clearColor?: string | GradientObject | ImagePatternObject) => void;
  50. renderToCanvas: (ctx: CanvasRenderingContext2D) => void;
  51. onclick: ElementEventCallback<unknown, this>;
  52. ondblclick: ElementEventCallback<unknown, this>;
  53. onmouseover: ElementEventCallback<unknown, this>;
  54. onmouseout: ElementEventCallback<unknown, this>;
  55. onmousemove: ElementEventCallback<unknown, this>;
  56. onmousewheel: ElementEventCallback<unknown, this>;
  57. onmousedown: ElementEventCallback<unknown, this>;
  58. onmouseup: ElementEventCallback<unknown, this>;
  59. oncontextmenu: ElementEventCallback<unknown, this>;
  60. ondrag: ElementEventCallback<unknown, this>;
  61. ondragstart: ElementEventCallback<unknown, this>;
  62. ondragend: ElementEventCallback<unknown, this>;
  63. ondragenter: ElementEventCallback<unknown, this>;
  64. ondragleave: ElementEventCallback<unknown, this>;
  65. ondragover: ElementEventCallback<unknown, this>;
  66. ondrop: ElementEventCallback<unknown, this>;
  67. }