idlize

Форк
0
/
canvas.d.ts 
148 строк · 3.3 Кб
1
/*
2
 * Copyright (c) 2024 Huawei Device Co., Ltd.
3
 * Licensed under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License.
5
 * You may obtain a copy of the License at
6
 *
7
 *     http://www.apache.org/licenses/LICENSE-2.0
8
 *
9
 * Unless required by applicable law or agreed to in writing, software
10
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 * See the License for the specific language governing permissions and
13
 * limitations under the License.
14
 */
15

16
declare type CanvasFillRule = "evenodd" | "nonzero";
17

18
declare class ImageData {
19

20
  readonly data: Uint8ClampedArray;
21

22
  readonly height: number;
23

24
  readonly width: number;
25

26
  constructor(width: number, height: number, data?: Uint8ClampedArray);
27

28
  constructor(width: number, height: number, data?: Uint8ClampedArray, unit?: LengthMetricsUnit);
29
}
30

31
declare interface CanvasPattern {
32

33
  setTransform(transform?: Matrix2D): void;
34
}
35

36
// interface ImageBitmap {
37

38
//   readonly height: number;
39

40
//   readonly width: number;
41

42
//   close(): void;
43
// }
44

45

46
declare class CanvasPath {
47

48
  rect(x: number, y: number, w: number, h: number): void;
49

50
  arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
51

52
  closePath(): void;
53
}
54

55
declare class CanvasGradient {
56

57
  addColorStop(offset: number, color: string): void;
58
}
59

60
declare class CanvasRenderer extends CanvasPath {
61

62
  globalAlpha: number;
63

64
  globalCompositeOperation: string;
65

66
  fillStyle: string | number | CanvasGradient | CanvasPattern;
67

68
  // drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number): void;
69

70
  beginPath(): void;
71

72
  clip(fillRule?: CanvasFillRule): void;
73

74
  reset(): void;
75

76
  putImageData(imagedata: ImageData, dx: number | string, dy: number | string): void;
77

78
  putImageData(
79
    imagedata: ImageData,
80
    dx: number | string,
81
    dy: number | string,
82
    dirtyX: number | string,
83
    dirtyY: number | string,
84
    dirtyWidth: number | string,
85
    dirtyHeight: number | string
86
  ): void;
87

88
}
89

90
declare class RenderingContextSettings {
91

92
  antialias?: boolean;
93

94
  constructor(antialias?: boolean);
95
}
96

97
declare class CanvasRenderingContext2D extends CanvasRenderer {
98

99
  readonly height: number;
100

101
  readonly width: number;
102

103
  stopImageAnalyzer(): void;
104

105
  constructor(settings?: RenderingContextSettings);
106

107
  static of(): CanvasRenderingContext2D
108
}
109

110
declare interface DrawingCanvas {}
111
declare interface Size {
112
  width: number;
113
  height: number;
114
}
115
declare class ImageBitmap {
116
  constructor(src: string);
117
  constructor(src: string, unit: LengthMetricsUnit);
118
  constructor(data: PixelMap);
119
  constructor(data: PixelMap, unit: LengthMetricsUnit);
120
  close(): void;
121
}
122

123
declare class DrawingRenderingContext {
124

125
  get size(): Size;
126

127
  get canvas(): DrawingCanvas;
128

129
  invalidate(): void;
130

131
  constructor(unit?: LengthMetricsUnit);
132
}
133

134
interface CanvasInterface {
135

136
  (context?: CanvasRenderingContext2D | DrawingRenderingContext): CanvasAttribute;
137
}
138

139
declare class CanvasAttribute extends CommonMethod<CanvasAttribute> {
140

141
  onReady(event: () => void): CanvasAttribute;
142

143
  enableAnalyzer(enable: boolean): CanvasAttribute;
144
}
145

146
declare const Canvas: CanvasInterface;
147

148
declare const CanvasInstance: CanvasAttribute;
149

150

151

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.