openharmony 鸿蒙 capi-drawing-path-effect-h

2026-08-25 浏览 (1)

drawing_path_effect.h

Overview

This file declares the functions related to the path effect in the drawing module.

File to include: <native_drawing/drawing_path_effect.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Related module: Drawing

Summary

Enumerated value

Nametypedef KeywordDescription
OH_Drawing_PathDashStyleOH_Drawing_PathDashStyleDefines an enum for the drawing styles for path effects.

Functions

NameDescription
OH_Drawing_PathEffect* OH_Drawing_CreateComposePathEffect(OH_Drawing_PathEffect* outer, OH_Drawing_PathEffect* inner)Creates a path effect by sequentially applying the inner effect and then the outer effect.
OH_Drawing_PathEffect* OH_Drawing_CreateCornerPathEffect(float radius)Creates a path effect that transforms the sharp angle between line segments into a rounded corner with the specified radius.
OH_Drawing_PathEffect* OH_Drawing_CreateDashPathEffect(float* intervals, int count, float phase)Creates a dashed path effect. The dashed line effect is determined by a group of "on" and "off" intervals.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If intervals is NULL or count is less than or equal to 0, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
OH_Drawing_PathEffect* OH_Drawing_CreateDiscretePathEffect(float segLength, float deviation)Creates a path effect that segments the path and scatters the segments in an irregular pattern along the path.
OH_Drawing_PathEffect* OH_Drawing_CreatePathDashEffect(const OH_Drawing_Path* path, float advance, float phase,OH_Drawing_PathDashStyle type)Creates a dashed path effect.
OH_Drawing_PathEffect* OH_Drawing_CreateSumPathEffect(OH_Drawing_PathEffect* firstPathEffect,OH_Drawing_PathEffect* secondPathEffect)Creates an overlay path effect based on two distinct path effects that take effect separately.
void OH_Drawing_PathEffectDestroy(OH_Drawing_PathEffect* pathEffect)Destroys an OH_Drawing_PathEffect object and reclaims the memory occupied by the object.

Enum Description

OH_Drawing_PathDashStyle

enum OH_Drawing_PathDashStyle

Description

Enumerates the drawing styles for path effects.

Since: 18

ValueDescription
DRAWING_PATH_DASH_STYLE_TRANSLATETranslation effect.
DRAWING_PATH_DASH_STYLE_ROTATERotation effect.
DRAWING_PATH_DASH_STYLE_MORPHMorphing effect.

Function Description

OH_Drawing_CreateComposePathEffect()

OH_Drawing_PathEffect* OH_Drawing_CreateComposePathEffect(OH_Drawing_PathEffect* outer, OH_Drawing_PathEffect* inner)

Description

Creates a path effect by sequentially applying the inner effect and then the outer effect.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_PathEffect* outerPointer to an outer effect, which is an OH_Drawing_PathEffect object.
OH_Drawing_PathEffect* innerPointer to an inner effect, which is an OH_Drawing_PathEffect object.

Returns

TypeDescription
OH_Drawing_PathEffect*Returns a pointer to the created OH_Drawing_PathEffect object.
If a null pointer is returned, the creation fails. The possible failure cause is that inner or inner is a null pointer.

OH_Drawing_CreateCornerPathEffect()

OH_Drawing_PathEffect* OH_Drawing_CreateCornerPathEffect(float radius)

Description

Creates a path effect that transforms the sharp angle between line segments into a rounded corner with the specified radius.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
float radiusRadius of the rounded corner. The value is valid only when it is greater than 0.

Returns

TypeDescription
OH_Drawing_PathEffect*Returns a pointer to the created OH_Drawing_PathEffect object.
If a null pointer is returned, the creation fails. The possible failure cause is that radius is less than or equal to 0.

OH_Drawing_CreateDashPathEffect()

OH_Drawing_PathEffect* OH_Drawing_CreateDashPathEffect(float* intervals, int count, float phase)

Description

Creates a dashed path effect. The dashed line effect is determined by a group of "on" and "off" intervals.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If intervals is NULL or count is less than or equal to 0, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
float* intervalsPointer to the start address of the dashed line interval array. In the array, an even entry indicates an "on" interval and an odd entry indicates an "off" interval. The unit is px.
int countNumber of entries in the dashed line interval array. The value must be an even number greater than 0.
float phaseOffset in the dashed line interval array.

Returns

TypeDescription
OH_Drawing_PathEffect*Returns a pointer to the created OH_Drawing_PathEffect object.

OH_Drawing_CreateDiscretePathEffect()

OH_Drawing_PathEffect* OH_Drawing_CreateDiscretePathEffect(float segLength, float deviation)

Description

Creates a path effect that segments the path and scatters the segments in an irregular pattern along the path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
float segLengthDistance along the path at which each segment is fragmented. An effect is created when it is greater than 0.
float deviationMaximum amount by which the end points of the segments can be randomly displaced during rendering.

Returns

TypeDescription
OH_Drawing_PathEffect*Returns a pointer to the created OH_Drawing_PathEffect object.

OH_Drawing_CreatePathDashEffect()

OH_Drawing_PathEffect* OH_Drawing_CreatePathDashEffect(const OH_Drawing_Path* path, float advance, float phase,OH_Drawing_PathDashStyle type)

Description

Creates a dashed path effect.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
const OH_Drawing_Path* pathPointer to an OH_Drawing_Path object.
float advanceLength of each dashed line segment.
float phaseOffset of the pattern within the dash segment length.
OH_Drawing_PathDashStyle typeStyle of the dashed path effect.

Returns

TypeDescription
OH_Drawing_PathEffect*Returns a pointer to the created OH_Drawing_PathEffect object.
If a null pointer is returned, the creation fails. The possible failure cause is that path is a null pointer or advance is less than or equal to 0.

OH_Drawing_CreateSumPathEffect()

OH_Drawing_PathEffect* OH_Drawing_CreateSumPathEffect(OH_Drawing_PathEffect* firstPathEffect,OH_Drawing_PathEffect* secondPathEffect)

Description

Creates an overlay path effect based on two distinct path effects that take effect separately.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_PathEffect* firstPathEffectPointer to an OH_Drawing_PathEffect object.
OH_Drawing_PathEffect* secondPathEffectPointer to an OH_Drawing_PathEffect object.

Returns

TypeDescription
OH_Drawing_PathEffect*Returns a pointer to the created OH_Drawing_PathEffect object.
If a null pointer is returned, the creation fails. The possible failure cause is that firstPathEffect or secondPathEffect is a null pointer.

OH_Drawing_PathEffectDestroy()

void OH_Drawing_PathEffectDestroy(OH_Drawing_PathEffect* pathEffect)

Description

Destroys an OH_Drawing_PathEffect object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_PathEffect* pathEffectPointer to an OH_Drawing_PathEffect object.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-drawing-gpu-context-h

openharmony 鸿蒙 capi-drawing-nativepixelmap-

openharmony 鸿蒙 capi-nativevsync-oh-nativevsync-expectedraterange

openharmony 鸿蒙 capi-drawing-oh-drawing-brush

openharmony 鸿蒙 capi-drawing-oh-drawing-image-info

openharmony 鸿蒙 capi-drawing-text-linetypography-h

openharmony 鸿蒙 capi-oh-nativeimage-oh-nativeimage

openharmony 鸿蒙 capi-drawing-typeface-h

openharmony 鸿蒙 capi-drawing-brush-h

openharmony 鸿蒙 capi-nativewindow

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/HE7zJN0j