UNPKG

ridder

Version:

A straightforward game engine for simple data-driven games in JavaScript

54 lines (53 loc) 2.56 kB
/** * Load a texture into the cache. * @param id - The ID for the texture in the cache. * @param url - The url to the `.png`, `.jpg`, or `.gif` file. */ export declare function loadTexture(id: number, url: string): Promise<void>; /** * Load a custom (render) texture into the cache that you can draw on with code. * * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D} MDN page for the drawing API. * * @see {@link https://github.com/patrickswijgman/ridder/blob/main/examples/render-texture/index.ts} for an example. * * @param id - The ID for the texture in the cache. * @param width - The width of the texture. Preferably a power of 2, e.g. 16, 32, 64, 128, etc. * @param height - The height of the texture. Preferably a power of 2, e.g. 16, 32, 64, 128, etc. * @param draw - The drawing function that takes a `CanvasRenderingContext2D` and the width and height of the texture. */ export declare function loadRenderTexture(id: number, width: number, height: number, draw: (ctx: CanvasRenderingContext2D, width: number, height: number) => void): void; /** * Load an outline version of a texture into the cache. * * @see {@link loadOutlinedTexture} for a version that draws the outline on top of the texture. * * @param id - The ID for the texture in the cache. * @param textureId - The id of the original texture. * @param mode - The mode of the outline. Either "circle" or "square". * @param color - The color of the outline. */ export declare function loadOutlineTexture(id: number, textureId: number, mode: "circle" | "square", color: string): void; /** * Load an outlined version of a texture into the cache. * * @see {@link loadOutlineTexture} for a version that only draws the outline. * * @param id - The ID for the texture in the cache. * @param textureId - The id of the original texture. * @param mode - The mode of the outline. Either "circle" or "square". * @param color - The color of the outline. */ export declare function loadOutlinedTexture(id: number, textureId: number, mode: "circle" | "square", color: string): void; /** * Load a 'flashed' texture into the cache. * This is a texture with a color overlay. * @param id - The ID for the texture in the cache. * @param textureId - The id of the original texture. * @param color - The color of the overlay. */ export declare function loadFlashTexture(id: number, textureId: number, color: string): void; /** * Get a texture from the cache. */ export declare function getTexture(id: number): HTMLCanvasElement;