From 53555a2b3743ee25add0f6c53caeb93815467528 Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Tue, 28 May 2024 18:32:09 +0800 Subject: [PATCH] drawing ts interface region upload Signed-off-by: lw19901203 --- api/@ohos.graphics.drawing.d.ts | 156 ++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/api/@ohos.graphics.drawing.d.ts b/api/@ohos.graphics.drawing.d.ts index 63515e219..51191724f 100644 --- a/api/@ohos.graphics.drawing.d.ts +++ b/api/@ohos.graphics.drawing.d.ts @@ -486,6 +486,16 @@ declare namespace drawing { drawPixelMapMesh(pixelmap: image.PixelMap, meshWidth: number, meshHeight: number, vertices: Array, vertOffset: number, colors: Array, colorOffset: number): void; + /** + * Draws a region. + * @param { Region } region - Region object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + drawRegion(region: Region): void; + /** * Set pen to a canvas. * @param { Pen } pen - object. @@ -941,6 +951,19 @@ declare namespace drawing { * @since 12 */ static createDashPathEffect(intervals: Array, phase: number): PathEffect; + + /** + * Makes a corner PathEffect. + * @param { number } radius - Indicates the radius of the tangent circle at the corners of the path. + * The radius must be greater than 0. + * @returns { PathEffect } PathEffect object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @static + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + static createCornerPathEffect(radius: number): PathEffect; } /** @@ -1336,6 +1359,139 @@ declare namespace drawing { */ setBlendMode(mode: BlendMode): void; } + + /** + * Describes a region object. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + class Region { + /** + * Determines whether the test point is in the region. + * @param { number } x - Indicates the x coordinate of the point. The parameter must be an integer. + * @param { number } y - Indicates the y coordinate of the point. The parameter must be an integer. + * @returns { boolean } Returns true if (x, y) is inside region; returns false otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + isPointContained(x: number, y:number): boolean; + + /** + * Determines whether other region is in the region. + * @param { Region } other - Other region object. + * @returns { boolean } Returns true if other region is completely inside the region object; + *
returns false otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + isRegionContained(other: Region): boolean; + + /** + * Replaces region with the result of region op region. + * @param { Region } region - Region object. + * @param { RegionOp } regionOp - Operation type. + * @returns { boolean } Returns true if replaced region is not empty; returns false otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + op(region: Region, regionOp: RegionOp): boolean; + + /** + * Determines whether rect and region does not intersect. + * @param { number } left - Left position of rectangle. The parameter must be an integer. + * @param { number } top - Top position of rectangle. The parameter must be an integer. + * @param { number } right - Right position of rectangle. The parameter must be an integer. + * @param { number } bottom - Bottom position of rectangle. The parameter must be an integer. + * @returns { boolean } Returns true if rect and region is not intersect; returns false otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + quickReject(left: number, top: number, right: number, bottom: number): boolean; + + /** + * Sets the region to match outline of path within clip. + * @param { Path } path - Providing outline. + * @param { Region } clip - Region object. + * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + setPath(path: Path, clip: Region): boolean; + + /** + * Sets a rect to region. + * @param { number } left - Left position of rectangle. The parameter must be an integer. + * @param { number } top - Top position of rectangle. The parameter must be an integer. + * @param { number } right - Right position of rectangle. The parameter must be an integer. + * @param { number } bottom - Bottom position of rectangle. The parameter must be an integer. + * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + setRect(left: number, top: number, right: number, bottom: number): boolean; + } + + /** + * Enumerates of operations when two regions are combined. + * @enum { number } + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + enum RegionOp { + /** + * Difference operation. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + DIFFERENCE = 0, + + /** + * Intersect operation. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + INTERSECT = 1, + + /** + * Union operation. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + UNION = 2, + + /** + * Xor operation. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + XOR = 3, + + /** + * Reverse difference operation. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + REVERSE_DIFFERENCE = 4, + + /** + * Replace operation. + * @syscap SystemCapability.Graphics.Drawing + * @since 12 + */ + REPLACE = 5 + } } export default drawing; \ No newline at end of file