zrender.d.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*!
  2. * ZRender, a high performance 2d drawing library.
  3. *
  4. * Copyright (c) 2013, Baidu Inc.
  5. * All rights reserved.
  6. *
  7. * LICENSE
  8. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  9. */
  10. import Handler from './Handler';
  11. import Storage from './Storage';
  12. import { PainterBase } from './PainterBase';
  13. import Animation from './animation/Animation';
  14. import Element, { ElementEventCallback } from './Element';
  15. import { ElementEventName, WithThisType } from './core/types';
  16. import { LayerConfig } from './canvas/Layer';
  17. import { GradientObject } from './graphic/Gradient';
  18. import { PatternObject } from './graphic/Pattern';
  19. import { EventCallback } from './core/Eventful';
  20. import Displayable from './graphic/Displayable';
  21. declare type PainterBaseCtor = {
  22. new (dom: HTMLElement, storage: Storage, ...args: any[]): PainterBase;
  23. };
  24. declare class ZRender {
  25. dom?: HTMLElement;
  26. id: number;
  27. storage: Storage;
  28. painter: PainterBase;
  29. handler: Handler;
  30. animation: Animation;
  31. private _sleepAfterStill;
  32. private _stillFrameAccum;
  33. private _needsRefresh;
  34. private _needsRefreshHover;
  35. private _darkMode;
  36. private _backgroundColor;
  37. constructor(id: number, dom?: HTMLElement, opts?: ZRenderInitOpt);
  38. add(el: Element): void;
  39. remove(el: Element): void;
  40. configLayer(zLevel: number, config: LayerConfig): void;
  41. setBackgroundColor(backgroundColor: string | GradientObject | PatternObject): void;
  42. getBackgroundColor(): string | GradientObject | PatternObject;
  43. setDarkMode(darkMode: boolean): void;
  44. isDarkMode(): boolean;
  45. refreshImmediately(fromInside?: boolean): void;
  46. refresh(): void;
  47. flush(): void;
  48. private _flush;
  49. setSleepAfterStill(stillFramesCount: number): void;
  50. wakeUp(): void;
  51. refreshHover(): void;
  52. refreshHoverImmediately(): void;
  53. resize(opts?: {
  54. width?: number | string;
  55. height?: number | string;
  56. }): void;
  57. clearAnimation(): void;
  58. getWidth(): number;
  59. getHeight(): number;
  60. setCursorStyle(cursorStyle: string): void;
  61. findHover(x: number, y: number): {
  62. target: Displayable;
  63. topTarget: Displayable;
  64. };
  65. on<Ctx>(eventName: ElementEventName, eventHandler: ElementEventCallback<Ctx, ZRenderType>, context?: Ctx): this;
  66. on<Ctx>(eventName: string, eventHandler: WithThisType<EventCallback<any[]>, unknown extends Ctx ? ZRenderType : Ctx>, context?: Ctx): this;
  67. off(eventName?: string, eventHandler?: EventCallback): void;
  68. trigger(eventName: string, event?: unknown): void;
  69. clear(): void;
  70. dispose(): void;
  71. }
  72. export interface ZRenderInitOpt {
  73. renderer?: string;
  74. devicePixelRatio?: number;
  75. width?: number | string;
  76. height?: number | string;
  77. useDirtyRect?: boolean;
  78. ssr?: boolean;
  79. }
  80. export declare function init(dom?: HTMLElement | null, opts?: ZRenderInitOpt): ZRender;
  81. export declare function dispose(zr: ZRender): void;
  82. export declare function disposeAll(): void;
  83. export declare function getInstance(id: number): ZRender;
  84. export declare function registerPainter(name: string, Ctor: PainterBaseCtor): void;
  85. export declare const version = "5.3.2";
  86. export interface ZRenderType extends ZRender {
  87. }
  88. export {};