forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.deno_canvas.d.ts
142 lines (131 loc) · 3.97 KB
/
lib.deno_canvas.d.ts
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-var
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/**
* Specifies whether the image should be decoded using color space conversion.
* Either none or default (default). The value default indicates that
* implementation-specific behavior is used.
*
* @category Canvas
*/
type ColorSpaceConversion = "default" | "none";
/**
* Specifies how the bitmap image should be oriented.
*
* @category Canvas
*/
type ImageOrientation = "flipY" | "from-image" | "none";
/**
* Specifies whether the bitmap's color channels should be premultiplied by
* the alpha channel.
*
* @category Canvas
*/
type PremultiplyAlpha = "default" | "none" | "premultiply";
/**
* Specifies the algorithm to be used for resizing the input to match the
* output dimensions. One of `pixelated`, `low` (default), `medium`, or `high`.
*
* @category Canvas
*/
type ResizeQuality = "high" | "low" | "medium" | "pixelated";
/**
* The `ImageBitmapSource` type represents an image data source that can be
* used to create an `ImageBitmap`.
*
* @category Canvas */
type ImageBitmapSource = Blob | ImageData;
/**
* The options of {@linkcode createImageBitmap}.
*
* @category Canvas */
interface ImageBitmapOptions {
/**
* Specifies whether the image should be decoded using color space
* conversion. Either none or default (default). The value default
* indicates that implementation-specific behavior is used.
*/
colorSpaceConversion?: ColorSpaceConversion;
/** Specifies how the bitmap image should be oriented. */
imageOrientation?: ImageOrientation;
/**
* Specifies whether the bitmap's color channels should be premultiplied
* by the alpha channel. One of none, premultiply, or default (default).
*/
premultiplyAlpha?: PremultiplyAlpha;
/** The output height. */
resizeHeight?: number;
/**
* Specifies the algorithm to be used for resizing the input to match the
* output dimensions. One of pixelated, low (default), medium, or high.
*/
resizeQuality?: ResizeQuality;
/** The output width. */
resizeWidth?: number;
}
/**
* Create a new {@linkcode ImageBitmap} object from a given source.
*
* @param image The image to create an {@linkcode ImageBitmap} from.
* @param options The options for creating the {@linkcode ImageBitmap}.
*
* @category Canvas
*/
declare function createImageBitmap(
image: ImageBitmapSource,
options?: ImageBitmapOptions,
): Promise<ImageBitmap>;
/**
* Create a new {@linkcode ImageBitmap} object from a given source, cropping
* to the specified rectangle.
*
* @param image The image to create an {@linkcode ImageBitmap} from.
* @param sx The x coordinate of the top-left corner of the sub-rectangle from
* which the {@linkcode ImageBitmap} will be cropped.
* @param sy The y coordinate of the top-left corner of the sub-rectangle from
* which the {@linkcode ImageBitmap} will be cropped.
* @param sw The width of the sub-rectangle from which the
* {@linkcode ImageBitmap} will be cropped.
* @param sh The height of the sub-rectangle from which the
* {@linkcode ImageBitmap} will be cropped.
* @param options The options for creating the {@linkcode ImageBitmap}.
*
* @category Canvas
*/
declare function createImageBitmap(
image: ImageBitmapSource,
sx: number,
sy: number,
sw: number,
sh: number,
options?: ImageBitmapOptions,
): Promise<ImageBitmap>;
/**
* `ImageBitmap` interface represents a bitmap image which can be drawn to a canvas.
*
* @category Canvas
*/
interface ImageBitmap {
/**
* The height of the bitmap.
*/
readonly height: number;
/**
* The width of the bitmap.
*/
readonly width: number;
/**
* Releases imageBitmap's resources.
*/
close(): void;
}
/**
* `ImageBitmap` represents a bitmap image which can be drawn to a canvas.
*
* @category Canvas
*/
declare var ImageBitmap: {
prototype: ImageBitmap;
new (): ImageBitmap;
};