UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

42 lines 2.11 kB
/** * Helper to get a canvas with the given size. */ export declare function tgdCanvasCreate(width: number, height: number): HTMLCanvasElement; /** * Helper to get a canvas of the given size and a 2D context on it. * If this is not possible, the method will throw an exception. */ export declare function tgdCanvasCreateWithContext2D(width: number, height: number, settings?: CanvasRenderingContext2DSettings): { canvas: HTMLCanvasElement; ctx: CanvasRenderingContext2D; }; /** * A palette is an image with a different (or not) color for each pixel. * It can be used in a texture with NEAREST filter, for instance. * @param colors CSS colors of each pixel * @param colums If not defined, the canvas will have a size of (colors.length, 1). * But if `colums` is defined, it will be the width of the vanva and the height will * be computed to hold all the colors. * If there are more pixels in the canvas that colors, we just wrap around the colors * array. * @param rows If defined, it will be the height of the canvas. * @example * ``` * // Create a 5x5 checkboard. * const canvas = tgdCanvasCreatePalette(["#000", "#fff"], 5, 5) * ``` */ export declare function tgdCanvasCreatePalette(colors: string[], colums?: number, rows?: number): HTMLCanvasElement; export declare function tgdCanvasCreateFill(width: number, height: number, fillColor?: string): HTMLCanvasElement; export declare function tgdCanvasCreateGradientHorizontal(size: number, colors: string[]): HTMLCanvasElement; export declare function tgdCanvasCreateCreateGradientvertical(size: number, colors: string[]): HTMLCanvasElement; /** * Create a canvas with a linear gradient. * @param width Width of the resulting canvas. * @param height Height of the resulting canvas. * @param directionX X coord of the direction vector. * @param directionY Y coord of the direction vector. * @param colors CSS colors of each step */ export declare function tgdCanvasCreateGradient(width: number, height: number, directionX: number, directionY: number, colors: string[]): HTMLCanvasElement; //# sourceMappingURL=canvas.d.ts.map