From b229fc4c29ef232d2bdc0b787bf8fb62387bd070 Mon Sep 17 00:00:00 2001 From: chenyuchi Date: Thu, 4 Sep 2025 20:34:05 +0800 Subject: [PATCH] add get canvas() API Signed-off-by: chenyuchi --- api/arkui/component/canvas.static.d.ets | 10 +++++++++- api/arkui/component/units.static.d.ets | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/api/arkui/component/canvas.static.d.ets b/api/arkui/component/canvas.static.d.ets index e9b96b4b48..2edb1ceeeb 100644 --- a/api/arkui/component/canvas.static.d.ets +++ b/api/arkui/component/canvas.static.d.ets @@ -21,7 +21,7 @@ import { CommonMethod, Callback, PixelMap } from './common'; import { FrameNode } from '../FrameNode'; import { ImageAIOptions, ImageAnalyzerConfig } from './imageCommon'; import { Matrix2D } from './matrix2d'; -import { VoidCallback, LengthMetricsUnit, LengthMetrics } from './units'; +import { DrawingCanvas, VoidCallback, LengthMetricsUnit, LengthMetrics } from './units'; import { Size } from '../Graphics'; import { memo, ComponentBuilder } from './../stateManagement/runtime'; import { AttributeModifier, CommonMethod } from './common'; @@ -1743,6 +1743,14 @@ export declare class DrawingRenderingContext { * @since 20 */ get size(): Size; + /** + * Get canvas of the DrawingRenderingContext. + * + * @returns { DrawingCanvas | undefined } The canvas of the DrawingRenderingContext. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + get canvas(): DrawingCanvas | undefined; /** * Invalidate the component, which will cause a re-render of the component. * diff --git a/api/arkui/component/units.static.d.ets b/api/arkui/component/units.static.d.ets index 3a151b75bf..9baf9acace 100644 --- a/api/arkui/component/units.static.d.ets +++ b/api/arkui/component/units.static.d.ets @@ -25,6 +25,7 @@ import { Color, BorderStyle, FontWeight, FontStyle, DividerMode } from './enums' import { OutlineStyle, AttributeModifier, CommonMethod } from './common'; import { LengthMetricsUnit as _LengthMetricsUnit, LengthMetrics as _LengthMetrics, ColorMetrics as _ColorMetrics } from '../Graphics'; import { memo, ComponentBuilder } from './../stateManagement/runtime'; +import _drawing from '../../../api/@ohos.graphics.drawing' /** * Defines the data type of the interface restriction. * @@ -115,6 +116,15 @@ export type Dimension = PX | VP | FP | LPX | Percentage | Resource; */ export type ResourceStr = string | Resource; +/** + * Defines drawing canvas. + * + * @typedef { _drawing.Canvas } DrawingCanvas + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export type DrawingCanvas = _drawing.Canvas; + /** * Defines the padding property. * -- Gitee