File size: 3,005 Bytes
04f98c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { RenderingContext2D } from './types';
import ViewPort from './ViewPort';
import Mouse from './Mouse';
import Document, { Element, AnimateElement } from './Document';
export interface IScreenOptions {
    /**

     * Window object.

     */
    window?: Window;
    /**

     * WHATWG-compatible `fetch` function.

     */
    fetch?: typeof fetch;
}
export interface IScreenStartOptions {
    /**

     * Whether enable the redraw.

     */
    enableRedraw?: boolean;
    /**

     * Ignore mouse events.

     */
    ignoreMouse?: boolean;
    /**

     * Ignore animations.

     */
    ignoreAnimation?: boolean;
    /**

     * Does not try to resize canvas.

     */
    ignoreDimensions?: boolean;
    /**

     * Does not clear canvas.

     */
    ignoreClear?: boolean;
    /**

     * Scales horizontally to width.

     */
    scaleWidth?: number;
    /**

     * Scales vertically to height.

     */
    scaleHeight?: number;
    /**

     * Draws at a x offset.

     */
    offsetX?: number;
    /**

     * Draws at a y offset.

     */
    offsetY?: number;
    /**

     * Will call the function on every frame, if it returns true, will redraw.

     */
    forceRedraw?(): boolean;
}
export interface IScreenViewBoxConfig {
    document: Document;
    ctx: RenderingContext2D;
    aspectRatio: string;
    width: number;
    desiredWidth: number;
    height: number;
    desiredHeight: number;
    minX?: number;
    minY?: number;
    refX?: number;
    refY?: number;
    clip?: boolean;
    clipX?: number;
    clipY?: number;
}
declare const defaultFetch: typeof fetch;
export default class Screen {
    readonly ctx: RenderingContext2D;
    static readonly defaultWindow: Window & typeof globalThis;
    static readonly defaultFetch: typeof fetch;
    FRAMERATE: number;
    MAX_VIRTUAL_PIXELS: number;
    CLIENT_WIDTH: number;
    CLIENT_HEIGHT: number;
    readonly window?: Window;
    readonly fetch: typeof defaultFetch;
    readonly viewPort: ViewPort;
    readonly mouse: Mouse;
    readonly animations: AnimateElement[];
    private readyPromise;
    private resolveReady;
    private waits;
    private frameDuration;
    private isReadyLock;
    private isFirstRender;
    private intervalId;
    constructor(ctx: RenderingContext2D, { fetch, window }?: IScreenOptions);
    wait(checker: () => boolean): void;
    ready(): Promise<void>;
    isReady(): boolean;
    setDefaults(ctx: RenderingContext2D): void;
    setViewBox({ document, ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY, clip, clipX, clipY }: IScreenViewBoxConfig): void;
    start(element: Element, { enableRedraw, ignoreMouse, ignoreAnimation, ignoreDimensions, ignoreClear, forceRedraw, scaleWidth, scaleHeight, offsetX, offsetY }?: IScreenStartOptions): void;
    stop(): void;
    private shouldUpdate;
    private render;
}
export {};
//# sourceMappingURL=Screen.d.ts.map