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
7
* http://www.apache.org/licenses/LICENSE-2.0
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.
16
declare type CanvasFillRule = "evenodd" | "nonzero";
18
declare class ImageData {
20
readonly data: Uint8ClampedArray;
22
readonly height: number;
24
readonly width: number;
26
constructor(width: number, height: number, data?: Uint8ClampedArray);
28
constructor(width: number, height: number, data?: Uint8ClampedArray, unit?: LengthMetricsUnit);
31
declare interface CanvasPattern {
33
setTransform(transform?: Matrix2D): void;
36
// interface ImageBitmap {
38
// readonly height: number;
40
// readonly width: number;
46
declare class CanvasPath {
48
rect(x: number, y: number, w: number, h: number): void;
50
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
55
declare class CanvasGradient {
57
addColorStop(offset: number, color: string): void;
60
declare class CanvasRenderer extends CanvasPath {
64
globalCompositeOperation: string;
66
fillStyle: string | number | CanvasGradient | CanvasPattern;
68
// drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number): void;
72
clip(fillRule?: CanvasFillRule): void;
76
putImageData(imagedata: ImageData, dx: number | string, dy: number | string): void;
82
dirtyX: number | string,
83
dirtyY: number | string,
84
dirtyWidth: number | string,
85
dirtyHeight: number | string
90
declare class RenderingContextSettings {
94
constructor(antialias?: boolean);
97
declare class CanvasRenderingContext2D extends CanvasRenderer {
99
readonly height: number;
101
readonly width: number;
103
stopImageAnalyzer(): void;
105
constructor(settings?: RenderingContextSettings);
107
static of(): CanvasRenderingContext2D
110
declare interface DrawingCanvas {}
111
declare interface Size {
115
declare class ImageBitmap {
116
constructor(src: string);
117
constructor(src: string, unit: LengthMetricsUnit);
118
constructor(data: PixelMap);
119
constructor(data: PixelMap, unit: LengthMetricsUnit);
123
declare class DrawingRenderingContext {
127
get canvas(): DrawingCanvas;
131
constructor(unit?: LengthMetricsUnit);
134
interface CanvasInterface {
136
(context?: CanvasRenderingContext2D | DrawingRenderingContext): CanvasAttribute;
139
declare class CanvasAttribute extends CommonMethod<CanvasAttribute> {
141
onReady(event: () => void): CanvasAttribute;
143
enableAnalyzer(enable: boolean): CanvasAttribute;
146
declare const Canvas: CanvasInterface;
148
declare const CanvasInstance: CanvasAttribute;