• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# drawing_pen.h
2
3## 概述
4
5文件中定义了与画笔相关的功能函数。
6
7<!--RP1-->
8**相关示例:** [NDKAPIDrawing (API14)](https://gitcode.com/openharmony/applications_app_samples/tree/master/code/DocsSample/Drawing/NDKAPIDrawing)<!--RP1End-->
9
10**引用文件:** <native_drawing/drawing_pen.h>
11
12**库:** libnative_drawing.so
13
14**起始版本:** 8
15
16**相关模块:** [Drawing](capi-drawing.md)
17
18## 汇总
19
20### 结构体
21
22| 名称 | typedef关键字 | 描述 |
23| -- | -- | -- |
24| [OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md) | OH_NativeColorSpaceManager | 声明色域管理对象,提供获取色域基础属性的能力。 |
25
26### 枚举
27
28| 名称 | typedef关键字 | 描述 |
29| -- | -- | -- |
30| [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle) | OH_Drawing_PenLineCapStyle | 枚举集合定义了画笔笔帽的样式,即画笔在绘制线段时,在线段头尾端点的样式。 |
31| [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle) | OH_Drawing_PenLineJoinStyle | 枚举集合定义了线条转角的样式,即画笔在绘制折线段时,在折线转角处的样式。 |
32
33### 函数
34
35| 名称 | 描述 |
36| -- | -- |
37| [OH_Drawing_Pen* OH_Drawing_PenCreate(void)](#oh_drawing_pencreate) | 用于创建一个画笔对象。 |
38| [OH_Drawing_Pen* OH_Drawing_PenCopy(OH_Drawing_Pen* pen)](#oh_drawing_pencopy) | 创建一个画笔对象副本[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md),用于拷贝一个已有画笔对象。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
39| [void OH_Drawing_PenDestroy(OH_Drawing_Pen* pen)](#oh_drawing_pendestroy) | 用于销毁画笔对象并回收该对象占有的内存。 |
40| [bool OH_Drawing_PenIsAntiAlias(const OH_Drawing_Pen* pen)](#oh_drawing_penisantialias) | 用于获取画笔是否设置抗锯齿属性,如果为真则说明画笔会启用抗锯齿功能,在绘制图形时会对图形的边缘像素进行半透明的模糊处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
41| [void OH_Drawing_PenSetAntiAlias(OH_Drawing_Pen* pen, bool antiAlias)](#oh_drawing_pensetantialias) | 用于设置画笔的抗锯齿属性,设置为真则画笔在绘制图形时会对图形的边缘像素进行半透明的模糊处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
42| [uint32_t OH_Drawing_PenGetColor(const OH_Drawing_Pen* pen)](#oh_drawing_pengetcolor) | 用于获取画笔的颜色属性,颜色属性描述了画笔绘制图形轮廓时使用的颜色,用一个32位(ARGB)的变量表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
43| [void OH_Drawing_PenSetColor(OH_Drawing_Pen* pen, uint32_t color)](#oh_drawing_pensetcolor) | 用于设置画笔的颜色属性,颜色属性描述了画笔绘制图形轮廓时使用的颜色,用一个32位(ARGB)的变量表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
44| [uint8_t OH_Drawing_PenGetAlpha(const OH_Drawing_Pen* pen)](#oh_drawing_pengetalpha) | 获取画笔的透明度值。画笔在勾勒图形时透明通道会使用该值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
45| [void OH_Drawing_PenSetAlpha(OH_Drawing_Pen* pen, uint8_t alpha)](#oh_drawing_pensetalpha) | 为画笔设置透明度值。画笔在勾勒图形时透明通道会使用该值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
46| [float OH_Drawing_PenGetWidth(const OH_Drawing_Pen* pen)](#oh_drawing_pengetwidth) | 用于获取画笔的厚度属性,厚度属性描述了画笔绘制图形轮廓的宽度。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
47| [void OH_Drawing_PenSetWidth(OH_Drawing_Pen* pen, float width)](#oh_drawing_pensetwidth) | 用于设置画笔的厚度属性,厚度属性描述了画笔绘制图形轮廓的宽度。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
48| [float OH_Drawing_PenGetMiterLimit(const OH_Drawing_Pen* pen)](#oh_drawing_pengetmiterlimit) | 用于获取折线尖角的限制值,当画笔绘制一条折线,转角类型设置为尖角时,那么此时该属性用于限制出现尖角的长度范围,如果超出则平角显示,不超出依然为尖角。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
49| [void OH_Drawing_PenSetMiterLimit(OH_Drawing_Pen* pen, float miter)](#oh_drawing_pensetmiterlimit) | 用于设置折线尖角的限制值,当画笔绘制一条折线,转角类型设置为尖角时,那么此时该属性用于限制出现尖角的长度范围,如果超出则平角显示,不超出依然为尖角。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
50| [OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap(const OH_Drawing_Pen* pen)](#oh_drawing_pengetcap) | 用于获取画笔笔帽的样式。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
51| [void OH_Drawing_PenSetCap(OH_Drawing_Pen* pen, OH_Drawing_PenLineCapStyle capStyle)](#oh_drawing_pensetcap) | 用于设置画笔笔帽样式。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>capStyle不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。 |
52| [OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin(const OH_Drawing_Pen* pen)](#oh_drawing_pengetjoin) | 用于获取画笔绘制折线转角的样式。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
53| [void OH_Drawing_PenSetJoin(OH_Drawing_Pen* pen, OH_Drawing_PenLineJoinStyle joinStyle)](#oh_drawing_pensetjoin) | 用于设置画笔绘制转角的样式。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>joinStyle不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。 |
54| [void OH_Drawing_PenSetShaderEffect(OH_Drawing_Pen* pen, OH_Drawing_ShaderEffect* shaderEffect)](#oh_drawing_pensetshadereffect) | 设置画笔着色器效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
55| [void OH_Drawing_PenSetShadowLayer(OH_Drawing_Pen* pen, OH_Drawing_ShadowLayer* shadowLayer)](#oh_drawing_pensetshadowlayer) | 设置画笔阴影层效果,设置的阴影层效果当前仅在绘制文字时生效。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
56| [void OH_Drawing_PenSetPathEffect(OH_Drawing_Pen* pen, OH_Drawing_PathEffect* pathEffect)](#oh_drawing_pensetpatheffect) | 设置画笔路径效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
57| [void OH_Drawing_PenSetFilter(OH_Drawing_Pen* pen, OH_Drawing_Filter* filter)](#oh_drawing_pensetfilter) | 设置画笔滤波器。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
58| [void OH_Drawing_PenGetFilter(OH_Drawing_Pen* pen, OH_Drawing_Filter* filter)](#oh_drawing_pengetfilter) | 从画笔获取滤波器[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)。滤波器是一个容器,可以承载蒙版滤波器和颜色滤波器。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen、filter任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
59| [void OH_Drawing_PenSetBlendMode(OH_Drawing_Pen* pen, OH_Drawing_BlendMode blendMode)](#oh_drawing_pensetblendmode) | 为画笔设置一个混合器,该混合器实现了指定的混合模式枚举。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>blendMode不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。 |
60| [bool OH_Drawing_PenGetFillPath(OH_Drawing_Pen* pen, const OH_Drawing_Path* src, OH_Drawing_Path* dst,const OH_Drawing_Rect* rect, const OH_Drawing_Matrix* matrix)](#oh_drawing_pengetfillpath) | 获取使用画笔绘制的源路径轮廓,并用目标路径表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen、src、dst任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
61| [void OH_Drawing_PenReset(OH_Drawing_Pen* pen)](#oh_drawing_penreset) | 将画笔重置至初始值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
62| [OH_Drawing_ErrorCode OH_Drawing_PenSetColor4f(OH_Drawing_Pen* pen, float a, float r, float g, float b,OH_NativeColorSpaceManager* colorSpaceManager)](#oh_drawing_pensetcolor4f) | 用于设置画笔的颜色属性,颜色属性描述了画笔绘制图形轮廓时使用的颜色。<br> 颜色采用浮点数表示的ARGB格式,色彩空间由[OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md)指定。<br> 如果colorSpaceManager为nullptr,使用SRGB(基于IEC 61966-2.1:1999的标准红绿蓝色彩空间)色彩空间作为默认值。 |
63| [OH_Drawing_ErrorCode OH_Drawing_PenGetAlphaFloat(const OH_Drawing_Pen* pen, float* a)](#oh_drawing_pengetalphafloat) | 获取画笔颜色的透明度值。 |
64| [OH_Drawing_ErrorCode OH_Drawing_PenGetRedFloat(const OH_Drawing_Pen* pen, float* r)](#oh_drawing_pengetredfloat) | 获取画笔颜色的红色分量。 |
65| [OH_Drawing_ErrorCode OH_Drawing_PenGetGreenFloat(const OH_Drawing_Pen* pen, float* g)](#oh_drawing_pengetgreenfloat) | 获取画笔颜色的绿色分量。 |
66| [OH_Drawing_ErrorCode OH_Drawing_PenGetBlueFloat(const OH_Drawing_Pen* pen, float* b)](#oh_drawing_pengetbluefloat) | 获取画笔颜色的蓝色分量。 |
67
68## 枚举类型说明
69
70### OH_Drawing_PenLineCapStyle
71
72```
73enum OH_Drawing_PenLineCapStyle
74```
75
76**描述**
77
78枚举集合定义了画笔笔帽的样式,即画笔在绘制线段时,在线段头尾端点的样式。
79
80**起始版本:** 8
81
82| 枚举项 | 描述 |
83| -- | -- |
84| LINE_FLAT_CAP | 没有笔帽样式,线条头尾端点处横切。 |
85| LINE_SQUARE_CAP | 笔帽的样式为方框,线条的头尾端点处多出一个方框,方框宽度和线段一样宽,高度时线段厚度的一半。 |
86| LINE_ROUND_CAP | 笔帽的样式为圆弧,线条的头尾端点处多出一个半圆弧,半圆的直径与线段厚度一致。 |
87
88### OH_Drawing_PenLineJoinStyle
89
90```
91enum OH_Drawing_PenLineJoinStyle
92```
93
94**描述**
95
96枚举集合定义了线条转角的样式,即画笔在绘制折线段时,在折线转角处的样式。
97
98**起始版本:** 8
99
100| 枚举项 | 描述 |
101| -- | -- |
102| LINE_MITER_JOIN | 转角类型为尖角,如果折线角度比较小,则尖角会很长,需要使用限制值(miter limit)进行限制。 |
103| LINE_ROUND_JOIN | 转角类型为圆头。 |
104| LINE_BEVEL_JOIN | 转角类型为平头。 |
105
106
107## 函数说明
108
109### OH_Drawing_PenCreate()
110
111```
112OH_Drawing_Pen* OH_Drawing_PenCreate(void)
113```
114
115**描述**
116
117用于创建一个画笔对象。
118
119**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
120
121**起始版本:** 8
122
123**返回:**
124
125| 类型 | 说明 |
126| -- | -- |
127| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* | 函数会返回一个指针,指针指向创建的画笔对象。 |
128
129### OH_Drawing_PenCopy()
130
131```
132OH_Drawing_Pen* OH_Drawing_PenCopy(OH_Drawing_Pen* pen)
133```
134
135**描述**
136
137创建一个画笔对象副本[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md),用于拷贝一个已有画笔对象。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
138
139**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
140
141**起始版本:** 12
142
143
144**参数:**
145
146| 参数项 | 描述 |
147| -- | -- |
148| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
149
150**返回:**
151
152| 类型 | 说明 |
153| -- | -- |
154| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* | 函数会返回一个指针,指针指向创建的画笔对象副本[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)。如果对象返回NULL,表示创建失败;可能的原因是可用内存为空,或者是pen为NULL。 |
155
156### OH_Drawing_PenDestroy()
157
158```
159void OH_Drawing_PenDestroy(OH_Drawing_Pen* pen)
160```
161
162**描述**
163
164用于销毁画笔对象并回收该对象占有的内存。
165
166**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
167
168**起始版本:** 8
169
170
171**参数:**
172
173| 参数项 | 描述 |
174| -- | -- |
175| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
176
177### OH_Drawing_PenIsAntiAlias()
178
179```
180bool OH_Drawing_PenIsAntiAlias(const OH_Drawing_Pen* pen)
181```
182
183**描述**
184
185用于获取画笔是否设置抗锯齿属性,如果为真则说明画笔会启用抗锯齿功能,在绘制图形时会对图形的边缘像素进行半透明的模糊处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
186
187**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
188
189**起始版本:** 8
190
191
192**参数:**
193
194| 参数项 | 描述 |
195| -- | -- |
196| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
197
198**返回:**
199
200| 类型 | 说明 |
201| -- | -- |
202| bool | 函数返回画笔对象是否设置抗锯齿属性,返回真则设置了抗锯齿,返回假则没有设置抗锯齿。 |
203
204### OH_Drawing_PenSetAntiAlias()
205
206```
207void OH_Drawing_PenSetAntiAlias(OH_Drawing_Pen* pen, bool antiAlias)
208```
209
210**描述**
211
212用于设置画笔的抗锯齿属性,设置为真则画笔在绘制图形时会对图形的边缘像素进行半透明的模糊处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
213
214**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
215
216**起始版本:** 8
217
218
219**参数:**
220
221| 参数项 | 描述 |
222| -- | -- |
223| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
224| bool antiAlias | 真为抗锯齿,假则不做抗锯齿处理。 |
225
226### OH_Drawing_PenGetColor()
227
228```
229uint32_t OH_Drawing_PenGetColor(const OH_Drawing_Pen* pen)
230```
231
232**描述**
233
234用于获取画笔的颜色属性,颜色属性描述了画笔绘制图形轮廓时使用的颜色,用一个32位(ARGB)的变量表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
235
236**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
237
238**起始版本:** 8
239
240
241**参数:**
242
243| 参数项 | 描述 |
244| -- | -- |
245| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
246
247**返回:**
248
249| 类型 | 说明 |
250| -- | -- |
251| uint32_t | 函数返回一个描述颜色的32位(ARGB)变量。 |
252
253### OH_Drawing_PenSetColor()
254
255```
256void OH_Drawing_PenSetColor(OH_Drawing_Pen* pen, uint32_t color)
257```
258
259**描述**
260
261用于设置画笔的颜色属性,颜色属性描述了画笔绘制图形轮廓时使用的颜色,用一个32位(ARGB)的变量表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
262
263**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
264
265**起始版本:** 8
266
267
268**参数:**
269
270| 参数项 | 描述 |
271| -- | -- |
272| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
273| uint32_t color | 描述颜色的32位(ARGB)变量。 |
274
275### OH_Drawing_PenGetAlpha()
276
277```
278uint8_t OH_Drawing_PenGetAlpha(const OH_Drawing_Pen* pen)
279```
280
281**描述**
282
283获取画笔的透明度值。画笔在勾勒图形时透明通道会使用该值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
284
285**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
286
287**起始版本:** 11
288
289
290**参数:**
291
292| 参数项 | 描述 |
293| -- | -- |
294| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 表示指向画笔对象的指针。 |
295
296**返回:**
297
298| 类型 | 说明 |
299| -- | -- |
300| uint8_t | 返回一个8比特的值表示透明度。 |
301
302### OH_Drawing_PenSetAlpha()
303
304```
305void OH_Drawing_PenSetAlpha(OH_Drawing_Pen* pen, uint8_t alpha)
306```
307
308**描述**
309
310为画笔设置透明度值。画笔在勾勒图形时透明通道会使用该值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
311
312**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
313
314**起始版本:** 11
315
316
317**参数:**
318
319| 参数项 | 描述 |
320| -- | -- |
321| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 表示指向画笔对象的指针。 |
322| uint8_t alpha | 表示要设置的透明度值,是一个8比特的变量。 |
323
324### OH_Drawing_PenGetWidth()
325
326```
327float OH_Drawing_PenGetWidth(const OH_Drawing_Pen* pen)
328```
329
330**描述**
331
332用于获取画笔的厚度属性,厚度属性描述了画笔绘制图形轮廓的宽度。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
333
334**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
335
336**起始版本:** 8
337
338
339**参数:**
340
341| 参数项 | 描述 |
342| -- | -- |
343| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
344
345**返回:**
346
347| 类型 | 说明 |
348| -- | -- |
349| float | 函数返回画笔的厚度。 |
350
351### OH_Drawing_PenSetWidth()
352
353```
354void OH_Drawing_PenSetWidth(OH_Drawing_Pen* pen, float width)
355```
356
357**描述**
358
359用于设置画笔的厚度属性,厚度属性描述了画笔绘制图形轮廓的宽度。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
360
361**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
362
363**起始版本:** 8
364
365
366**参数:**
367
368| 参数项 | 描述 |
369| -- | -- |
370| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
371| float width | 描述画笔厚度的变量。 |
372
373### OH_Drawing_PenGetMiterLimit()
374
375```
376float OH_Drawing_PenGetMiterLimit(const OH_Drawing_Pen* pen)
377```
378
379**描述**
380
381用于获取折线尖角的限制值,当画笔绘制一条折线,转角类型设置为尖角时,那么此时该属性用于限制出现尖角的长度范围,如果超出则平角显示,不超出依然为尖角。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
382
383**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
384
385**起始版本:** 8
386
387
388**参数:**
389
390| 参数项 | 描述 |
391| -- | -- |
392| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
393
394**返回:**
395
396| 类型 | 说明 |
397| -- | -- |
398| float | 函数返回尖角的限制值。 |
399
400### OH_Drawing_PenSetMiterLimit()
401
402```
403void OH_Drawing_PenSetMiterLimit(OH_Drawing_Pen* pen, float miter)
404```
405
406**描述**
407
408用于设置折线尖角的限制值,当画笔绘制一条折线,转角类型设置为尖角时,那么此时该属性用于限制出现尖角的长度范围,如果超出则平角显示,不超出依然为尖角。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
409
410**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
411
412**起始版本:** 8
413
414
415**参数:**
416
417| 参数项 | 描述 |
418| -- | -- |
419| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
420| float miter | 描述尖角限制值的变量。 |
421
422### OH_Drawing_PenGetCap()
423
424```
425OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap(const OH_Drawing_Pen* pen)
426```
427
428**描述**
429
430用于获取画笔笔帽的样式。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
431
432**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
433
434**起始版本:** 8
435
436
437**参数:**
438
439| 参数项 | 描述 |
440| -- | -- |
441| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
442
443**返回:**
444
445| 类型 | 说明 |
446| -- | -- |
447| [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle) | 函数返回画笔笔帽样式。 |
448
449### OH_Drawing_PenSetCap()
450
451```
452void OH_Drawing_PenSetCap(OH_Drawing_Pen* pen, OH_Drawing_PenLineCapStyle capStyle)
453```
454
455**描述**
456
457用于设置画笔笔帽样式。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>capStyle不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。
458
459**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
460
461**起始版本:** 8
462
463
464**参数:**
465
466| 参数项 | 描述 |
467| -- | -- |
468| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
469| [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle) capStyle | 描述画笔笔帽样式的变量。 |
470
471### OH_Drawing_PenGetJoin()
472
473```
474OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin(const OH_Drawing_Pen* pen)
475```
476
477**描述**
478
479用于获取画笔绘制折线转角的样式。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
480
481**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
482
483**起始版本:** 8
484
485
486**参数:**
487
488| 参数项 | 描述 |
489| -- | -- |
490| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
491
492**返回:**
493
494| 类型 | 说明 |
495| -- | -- |
496| [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle) | 函数返回折线转角的样式。 |
497
498### OH_Drawing_PenSetJoin()
499
500```
501void OH_Drawing_PenSetJoin(OH_Drawing_Pen* pen, OH_Drawing_PenLineJoinStyle joinStyle)
502```
503
504**描述**
505
506用于设置画笔绘制转角的样式。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>joinStyle不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。
507
508**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
509
510**起始版本:** 8
511
512
513**参数:**
514
515| 参数项 | 描述 |
516| -- | -- |
517| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象的指针。 |
518| [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle) joinStyle | 折线转角样式。 |
519
520### OH_Drawing_PenSetShaderEffect()
521
522```
523void OH_Drawing_PenSetShaderEffect(OH_Drawing_Pen* pen, OH_Drawing_ShaderEffect* shaderEffect)
524```
525
526**描述**
527
528设置画笔着色器效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
529
530**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
531
532**起始版本:** 11
533
534
535**参数:**
536
537| 参数项 | 描述 |
538| -- | -- |
539| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
540| [OH_Drawing_ShaderEffect](capi-drawing-oh-drawing-shadereffect.md)* shaderEffect | 指向着色器对象[OH_Drawing_ShaderEffect](capi-drawing-oh-drawing-shadereffect.md)的指针,为NULL表示清空着色器效果。 |
541
542### OH_Drawing_PenSetShadowLayer()
543
544```
545void OH_Drawing_PenSetShadowLayer(OH_Drawing_Pen* pen, OH_Drawing_ShadowLayer* shadowLayer)
546```
547
548**描述**
549
550设置画笔阴影层效果,设置的阴影层效果当前仅在绘制文字时生效。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
551
552**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
553
554**起始版本:** 12
555
556
557**参数:**
558
559| 参数项 | 描述 |
560| -- | -- |
561| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
562| [OH_Drawing_ShadowLayer](capi-drawing-oh-drawing-shadowlayer.md)* shadowLayer | 指向阴影层对象[OH_Drawing_ShadowLayer](capi-drawing-oh-drawing-shadowlayer.md)的指针,为NULL表示清空阴影层效果。 |
563
564### OH_Drawing_PenSetPathEffect()
565
566```
567void OH_Drawing_PenSetPathEffect(OH_Drawing_Pen* pen, OH_Drawing_PathEffect* pathEffect)
568```
569
570**描述**
571
572设置画笔路径效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
573
574**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
575
576**起始版本:** 12
577
578
579**参数:**
580
581| 参数项 | 描述 |
582| -- | -- |
583| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
584| [OH_Drawing_PathEffect](capi-drawing-oh-drawing-patheffect.md)* pathEffect | 指向路径效果对象[OH_Drawing_PathEffect](capi-drawing-oh-drawing-patheffect.md)的指针,为NULL表示清空路径效果。 |
585
586### OH_Drawing_PenSetFilter()
587
588```
589void OH_Drawing_PenSetFilter(OH_Drawing_Pen* pen, OH_Drawing_Filter* filter)
590```
591
592**描述**
593
594设置画笔滤波器。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
595
596**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
597
598**起始版本:** 11
599
600
601**参数:**
602
603| 参数项 | 描述 |
604| -- | -- |
605| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
606| [OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)* filter | 指向滤波器[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)的指针,为NULL表示清空画笔滤波器。 |
607
608### OH_Drawing_PenGetFilter()
609
610```
611void OH_Drawing_PenGetFilter(OH_Drawing_Pen* pen, OH_Drawing_Filter* filter)
612```
613
614**描述**
615
616从画笔获取滤波器[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)。滤波器是一个容器,可以承载蒙版滤波器和颜色滤波器。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen、filter任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
617
618**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
619
620**起始版本:** 12
621
622
623**参数:**
624
625| 参数项 | 描述 |
626| -- | -- |
627| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
628| [OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)* filter | 指向滤波器对象[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)的指针。 |
629
630### OH_Drawing_PenSetBlendMode()
631
632```
633void OH_Drawing_PenSetBlendMode(OH_Drawing_Pen* pen, OH_Drawing_BlendMode blendMode)
634```
635
636**描述**
637
638为画笔设置一个混合器,该混合器实现了指定的混合模式枚举。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>blendMode不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。
639
640**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
641
642**起始版本:** 12
643
644
645**参数:**
646
647| 参数项 | 描述 |
648| -- | -- |
649| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
650| [OH_Drawing_BlendMode](capi-drawing-types-h.md#oh_drawing_blendmode) blendMode | 混合模式枚举类型[OH_Drawing_BlendMode](capi-drawing-types-h.md#oh_drawing_blendmode)。 |
651
652### OH_Drawing_PenGetFillPath()
653
654```
655bool OH_Drawing_PenGetFillPath(OH_Drawing_Pen* pen, const OH_Drawing_Path* src, OH_Drawing_Path* dst,const OH_Drawing_Rect* rect, const OH_Drawing_Matrix* matrix)
656```
657
658**描述**
659
660获取使用画笔绘制的源路径轮廓,并用目标路径表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen、src、dst任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
661
662**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
663
664**起始版本:** 12
665
666
667**参数:**
668
669| 参数项 | 描述 |
670| -- | -- |
671| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
672| const [OH_Drawing_Path](capi-drawing-oh-drawing-path.md)* src | 指向源路径对象[OH_Drawing_Path](capi-drawing-oh-drawing-path.md)的指针。 |
673| [OH_Drawing_Path](capi-drawing-oh-drawing-path.md)* dst | 指向目标路径对象[OH_Drawing_Path](capi-drawing-oh-drawing-path.md)的指针。 |
674| const [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象[OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)的指针,推荐使用NULL。 |
675| const [OH_Drawing_Matrix](capi-drawing-oh-drawing-matrix.md)* matrix | 指向矩阵对象[OH_Drawing_Matrix](capi-drawing-oh-drawing-matrix.md)的指针,推荐使用NULL, 默认是一个单位矩阵。 |
676
677**返回:**
678
679| 类型 | 说明 |
680| -- | -- |
681| bool | 获取目标路径是否成功。true表示获取成功,false表示获取失败。 |
682
683### OH_Drawing_PenReset()
684
685```
686void OH_Drawing_PenReset(OH_Drawing_Pen* pen)
687```
688
689**描述**
690
691将画笔重置至初始值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>pen为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
692
693**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
694
695**起始版本:** 12
696
697
698**参数:**
699
700| 参数项 | 描述 |
701| -- | -- |
702| [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
703
704
705### OH_Drawing_PenSetColor4f()
706
707```
708OH_Drawing_ErrorCode OH_Drawing_PenSetColor4f(OH_Drawing_Pen* pen, float a, float r, float g, float b,OH_NativeColorSpaceManager* colorSpaceManager)
709```
710
711**描述**
712
713用于设置画笔的颜色属性,颜色属性描述了画笔绘制图形轮廓时使用的颜色。<br> 颜色采用浮点数表示的ARGB格式,色彩空间由[OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md)指定。<br> 如果colorSpaceManager为nullptr,使用SRGB(基于IEC 61966-2.1:1999的标准红绿蓝色彩空间)色彩空间作为默认值。
714
715**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
716
717**起始版本:** 20
718
719**参数:**
720
721| 参数项 | 描述 |
722| -- | -- |
723| OH_Drawing_Pen* pen | 表示指向[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)对象的指针。 |
724| float a | 表示颜色中的透明度值,用0.0 ~ 1.0之间的浮点数表示,大于1.0时,取1.0,小于0.0时,取0.0。 |
725| float r | 表示颜色中的红色分量,用0.0 ~ 1.0之间的浮点数表示,大于1.0时,取1.0,小于0.0时,取0.0。 |
726| float g | 表示颜色中的绿色分量,用0.0 ~ 1.0之间的浮点数表示,大于1.0时,取1.0,小于0.0时,取0.0。 |
727| float b | 表示颜色中的蓝色分量,用0.0 ~ 1.0之间的浮点数表示,大于1.0时,取1.0,小于0.0时,取0.0。 |
728| [OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md)* colorSpaceManager | 表示指向[OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md)对象的指针。 |
729
730**返回:**
731
732| 类型 | 说明 |
733| -- | -- |
734| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数pen为NULL。 |
735
736### OH_Drawing_PenGetAlphaFloat()
737
738```
739OH_Drawing_ErrorCode OH_Drawing_PenGetAlphaFloat(const OH_Drawing_Pen* pen, float* a)
740```
741
742**描述**
743
744获取画笔颜色的透明度值。
745
746**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
747
748**起始版本:** 20
749
750**参数:**
751
752| 参数项 | 描述 |
753| -- | -- |
754| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 表示指向[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)对象的指针。 |
755| float* a | 表示颜色中的透明度,范围为0.0 ~ 1.0的浮点数。 |
756
757**返回:**
758
759| 类型 | 说明 |
760| -- | -- |
761| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数pen或a为NULL。 |
762
763### OH_Drawing_PenGetRedFloat()
764
765```
766OH_Drawing_ErrorCode OH_Drawing_PenGetRedFloat(const OH_Drawing_Pen* pen, float* r)
767```
768
769**描述**
770
771获取画笔颜色的红色分量。
772
773**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
774
775**起始版本:** 20
776
777**参数:**
778
779| 参数项 | 描述 |
780| -- | -- |
781| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 表示指向[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)对象的指针。 |
782| float* r | 表示颜色中的红色分量,范围为0.0 ~ 1.0的浮点数。 |
783
784**返回:**
785
786| 类型 | 说明 |
787| -- | -- |
788| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数pen或r为NULL。 |
789
790### OH_Drawing_PenGetGreenFloat()
791
792```
793OH_Drawing_ErrorCode OH_Drawing_PenGetGreenFloat(const OH_Drawing_Pen* pen, float* g)
794```
795
796**描述**
797
798获取画笔颜色的绿色分量。
799
800**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
801
802**起始版本:** 20
803
804**参数:**
805
806| 参数项 | 描述 |
807| -- | -- |
808| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 表示指向[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)对象的指针。 |
809| float* g | 表示颜色中的绿色分量,范围为0.0 ~ 1.0的浮点数。 |
810
811**返回:**
812
813| 类型 | 说明 |
814| -- | -- |
815| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数pen或g为NULL。 |
816
817### OH_Drawing_PenGetBlueFloat()
818
819```
820OH_Drawing_ErrorCode OH_Drawing_PenGetBlueFloat(const OH_Drawing_Pen* pen, float* b)
821```
822
823**描述**
824
825获取画笔颜色的蓝色分量。
826
827**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
828
829**起始版本:** 20
830
831**参数:**
832
833| 参数项 | 描述 |
834| -- | -- |
835| const [OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)* pen | 表示指向[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)对象的指针。 |
836| float* b | 表示颜色中的蓝色分量,范围为0.0 ~ 1.0的浮点数。 |
837
838**返回:**
839
840| 类型 | 说明 |
841| -- | -- |
842| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数pen或b为NULL。 |
843
844
845
846