1 | import { RenderingContext2D } from './types';
|
---|
2 | import ViewPort from './ViewPort';
|
---|
3 | import Mouse from './Mouse';
|
---|
4 | import Document, { Element, AnimateElement } from './Document';
|
---|
5 | export interface IScreenOptions {
|
---|
6 | /**
|
---|
7 | * Window object.
|
---|
8 | */
|
---|
9 | window?: Window;
|
---|
10 | /**
|
---|
11 | * WHATWG-compatible `fetch` function.
|
---|
12 | */
|
---|
13 | fetch?: typeof fetch;
|
---|
14 | }
|
---|
15 | export interface IScreenStartOptions {
|
---|
16 | /**
|
---|
17 | * Whether enable the redraw.
|
---|
18 | */
|
---|
19 | enableRedraw?: boolean;
|
---|
20 | /**
|
---|
21 | * Ignore mouse events.
|
---|
22 | */
|
---|
23 | ignoreMouse?: boolean;
|
---|
24 | /**
|
---|
25 | * Ignore animations.
|
---|
26 | */
|
---|
27 | ignoreAnimation?: boolean;
|
---|
28 | /**
|
---|
29 | * Does not try to resize canvas.
|
---|
30 | */
|
---|
31 | ignoreDimensions?: boolean;
|
---|
32 | /**
|
---|
33 | * Does not clear canvas.
|
---|
34 | */
|
---|
35 | ignoreClear?: boolean;
|
---|
36 | /**
|
---|
37 | * Scales horizontally to width.
|
---|
38 | */
|
---|
39 | scaleWidth?: number;
|
---|
40 | /**
|
---|
41 | * Scales vertically to height.
|
---|
42 | */
|
---|
43 | scaleHeight?: number;
|
---|
44 | /**
|
---|
45 | * Draws at a x offset.
|
---|
46 | */
|
---|
47 | offsetX?: number;
|
---|
48 | /**
|
---|
49 | * Draws at a y offset.
|
---|
50 | */
|
---|
51 | offsetY?: number;
|
---|
52 | /**
|
---|
53 | * Will call the function on every frame, if it returns true, will redraw.
|
---|
54 | */
|
---|
55 | forceRedraw?(): boolean;
|
---|
56 | }
|
---|
57 | export interface IScreenViewBoxConfig {
|
---|
58 | document: Document;
|
---|
59 | ctx: RenderingContext2D;
|
---|
60 | aspectRatio: string;
|
---|
61 | width: number;
|
---|
62 | desiredWidth: number;
|
---|
63 | height: number;
|
---|
64 | desiredHeight: number;
|
---|
65 | minX?: number;
|
---|
66 | minY?: number;
|
---|
67 | refX?: number;
|
---|
68 | refY?: number;
|
---|
69 | clip?: boolean;
|
---|
70 | clipX?: number;
|
---|
71 | clipY?: number;
|
---|
72 | }
|
---|
73 | declare const defaultFetch: typeof fetch;
|
---|
74 | export default class Screen {
|
---|
75 | readonly ctx: RenderingContext2D;
|
---|
76 | static readonly defaultWindow: Window & typeof globalThis;
|
---|
77 | static readonly defaultFetch: typeof fetch;
|
---|
78 | FRAMERATE: number;
|
---|
79 | MAX_VIRTUAL_PIXELS: number;
|
---|
80 | CLIENT_WIDTH: number;
|
---|
81 | CLIENT_HEIGHT: number;
|
---|
82 | readonly window?: Window;
|
---|
83 | readonly fetch: typeof defaultFetch;
|
---|
84 | readonly viewPort: ViewPort;
|
---|
85 | readonly mouse: Mouse;
|
---|
86 | readonly animations: AnimateElement[];
|
---|
87 | private readyPromise;
|
---|
88 | private resolveReady;
|
---|
89 | private waits;
|
---|
90 | private frameDuration;
|
---|
91 | private isReadyLock;
|
---|
92 | private isFirstRender;
|
---|
93 | private intervalId;
|
---|
94 | constructor(ctx: RenderingContext2D, { fetch, window }?: IScreenOptions);
|
---|
95 | wait(checker: () => boolean): void;
|
---|
96 | ready(): Promise<void>;
|
---|
97 | isReady(): boolean;
|
---|
98 | setDefaults(ctx: RenderingContext2D): void;
|
---|
99 | setViewBox({ document, ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY, clip, clipX, clipY }: IScreenViewBoxConfig): void;
|
---|
100 | start(element: Element, { enableRedraw, ignoreMouse, ignoreAnimation, ignoreDimensions, ignoreClear, forceRedraw, scaleWidth, scaleHeight, offsetX, offsetY }?: IScreenStartOptions): void;
|
---|
101 | stop(): void;
|
---|
102 | private shouldUpdate;
|
---|
103 | private render;
|
---|
104 | }
|
---|
105 | export {};
|
---|
106 | //# sourceMappingURL=Screen.d.ts.map |
---|