UNPKG

1.41 kBTypeScriptView Raw
1import { CompressedPixelFormat, PixelFormat, TextureDataType } from "../constants.js";
2import { Texture } from "../textures/Texture.js";
3
4/**
5 * Scales the texture as large as possible within its surface without cropping or stretching the texture. The method
6 * preserves the original aspect ratio of the texture. Akin to CSS `object-fit: contain`.
7 */
8declare function contain(texture: Texture, aspect: number): Texture;
9
10/**
11 * Scales the texture to the smallest possible size to fill the surface, leaving no empty space. The method preserves
12 * the original aspect ratio of the texture. Akin to CSS `object-fit: cover`.
13 */
14declare function cover(texture: Texture, aspect: number): Texture;
15
16/**
17 * Configures the texture to the default transformation. Akin to CSS `object-fit: fill`.
18 */
19declare function fill(texture: Texture): Texture;
20
21/**
22 * Given the width, height, format, and type of a texture. Determines how many bytes must be used to represent the
23 * texture.
24 */
25declare function getByteLength(
26 width: number,
27 height: number,
28 format: PixelFormat | CompressedPixelFormat,
29 type: TextureDataType,
30): number;
31
32/**
33 * A class containing utility functions for textures.
34 */
35declare const TextureUtils: {
36 contain: typeof contain;
37 cover: typeof cover;
38 fill: typeof fill;
39 getByteLength: typeof getByteLength;
40};
41
42export { contain, cover, fill, getByteLength, TextureUtils };