Painter.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import Layer, { LayerConfig } from './Layer';
  2. import Displayable from '../graphic/Displayable';
  3. import { GradientObject } from '../graphic/Gradient';
  4. import { ImagePatternObject } from '../graphic/Pattern';
  5. import Storage from '../Storage';
  6. import { PainterBase } from '../PainterBase';
  7. interface CanvasPainterOption {
  8. devicePixelRatio?: number;
  9. width?: number | string;
  10. height?: number | string;
  11. useDirtyRect?: boolean;
  12. }
  13. export default class CanvasPainter implements PainterBase {
  14. type: string;
  15. root: HTMLElement;
  16. dpr: number;
  17. storage: Storage;
  18. private _singleCanvas;
  19. private _opts;
  20. private _zlevelList;
  21. private _prevDisplayList;
  22. private _layers;
  23. private _layerConfig;
  24. private _needsManuallyCompositing;
  25. private _width;
  26. private _height;
  27. private _domRoot;
  28. private _hoverlayer;
  29. private _redrawId;
  30. private _backgroundColor;
  31. constructor(root: HTMLElement, storage: Storage, opts: CanvasPainterOption, id: number);
  32. getType(): string;
  33. isSingleCanvas(): boolean;
  34. getViewportRoot(): HTMLElement;
  35. getViewportRootOffset(): {
  36. offsetLeft: number;
  37. offsetTop: number;
  38. };
  39. refresh(paintAll?: boolean): this;
  40. refreshHover(): void;
  41. private _paintHoverList;
  42. getHoverLayer(): Layer;
  43. paintOne(ctx: CanvasRenderingContext2D, el: Displayable): void;
  44. private _paintList;
  45. private _compositeManually;
  46. private _doPaintList;
  47. private _doPaintEl;
  48. getLayer(zlevel: number, virtual?: boolean): Layer;
  49. insertLayer(zlevel: number, layer: Layer): void;
  50. eachLayer<T>(cb: (this: T, layer: Layer, z: number) => void, context?: T): void;
  51. eachBuiltinLayer<T>(cb: (this: T, layer: Layer, z: number) => void, context?: T): void;
  52. eachOtherLayer<T>(cb: (this: T, layer: Layer, z: number) => void, context?: T): void;
  53. getLayers(): {
  54. [key: number]: Layer;
  55. };
  56. _updateLayerStatus(list: Displayable[]): void;
  57. clear(): this;
  58. _clearLayer(layer: Layer): void;
  59. setBackgroundColor(backgroundColor: string | GradientObject | ImagePatternObject): void;
  60. configLayer(zlevel: number, config: LayerConfig): void;
  61. delLayer(zlevel: number): void;
  62. resize(width?: number | string, height?: number | string): this;
  63. clearLayer(zlevel: number): void;
  64. dispose(): void;
  65. getRenderedCanvas(opts?: {
  66. backgroundColor?: string | GradientObject | ImagePatternObject;
  67. pixelRatio?: number;
  68. }): HTMLCanvasElement;
  69. getWidth(): number;
  70. getHeight(): number;
  71. }
  72. export {};