Layer.d.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. __painter: CanvasPainter;
  31. __dirty: boolean;
  32. __firstTimePaint: boolean;
  33. __used: boolean;
  34. __drawIndex: number;
  35. __startIndex: number;
  36. __endIndex: number;
  37. __prevStartIndex: number;
  38. __prevEndIndex: number;
  39. __builtin__: boolean;
  40. constructor(id: string | HTMLCanvasElement, painter: CanvasPainter, dpr?: number);
  41. getElementCount(): number;
  42. afterBrush(): void;
  43. initContext(): void;
  44. setUnpainted(): void;
  45. createBackBuffer(): void;
  46. createRepaintRects(displayList: Displayable[], prevList: Displayable[], viewWidth: number, viewHeight: number): BoundingRect[];
  47. debugGetPaintRects(): BoundingRect[];
  48. resize(width: number, height: number): void;
  49. clear(clearAll?: boolean, clearColor?: string | GradientObject | ImagePatternObject, repaintRects?: BoundingRect[]): void;
  50. refresh: (clearColor?: string | GradientObject | ImagePatternObject) => void;
  51. renderToCanvas: (ctx: CanvasRenderingContext2D) => void;
  52. onclick: ElementEventCallback<unknown, this>;
  53. ondblclick: ElementEventCallback<unknown, this>;
  54. onmouseover: ElementEventCallback<unknown, this>;
  55. onmouseout: ElementEventCallback<unknown, this>;
  56. onmousemove: ElementEventCallback<unknown, this>;
  57. onmousewheel: ElementEventCallback<unknown, this>;
  58. onmousedown: ElementEventCallback<unknown, this>;
  59. onmouseup: ElementEventCallback<unknown, this>;
  60. oncontextmenu: ElementEventCallback<unknown, this>;
  61. ondrag: ElementEventCallback<unknown, this>;
  62. ondragstart: ElementEventCallback<unknown, this>;
  63. ondragend: ElementEventCallback<unknown, this>;
  64. ondragenter: ElementEventCallback<unknown, this>;
  65. ondragleave: ElementEventCallback<unknown, this>;
  66. ondragover: ElementEventCallback<unknown, this>;
  67. ondrop: ElementEventCallback<unknown, this>;
  68. }