
HarmonyOS API:绘制组件
版本:v3.1 Beta
Polyline
更新时间: 2023-02-17 09:19
折线绘制组件。
说明
该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
子组件
无
接口
Polyline(value?: {width?: string | number, height?: string | number})
参数:
参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
width | string | number | 否 | 0 | 宽度。 |
height | string | number | 否 | 0 | 高度。 |
属性
除支持通用属性外,还支持以下属性:
名称 | 类型 | 默认值 | 描述 |
points | Array<Point> | [] | 折线经过坐标点列表。 |
fill | Color.Black | 设置填充区域颜色。 | |
fillOpacity | number | string | Resource | 1 | 设置填充区域透明度。 |
stroke | - | 设置线条颜色。 | |
strokeDashArray | Array<Length> | [] | 设置线条间隙。 |
strokeDashOffset | number | string | 0 | 线条绘制起点的偏移量。 |
strokeLineCap | LineCapStyle.Butt | 设置线条端点绘制样式。 | |
strokeLineJoin | LineJoinStyle.Miter | 设置线条拐角绘制样式。 | |
strokeMiterLimit | number | string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。 说明: 该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。 |
strokeOpacity | number | string | Resource | 1 | 设置线条透明度。 说明: 该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 |
strokeWidth | Length | 1 | 设置线条宽度。 |
antiAlias | boolean | true | 是否开启抗锯齿效果。 |
Point
点坐标类型。
名称 | 类型定义 | 描述 |
Point | [number, number] | 第一个参数为x轴坐标,第二个参数为y轴坐标(相对坐标)。 |
示例
Polygon
更新时间: 2023-02-17 09:19
多边形绘制组件。
说明
该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
子组件
无
接口
Polygon(value?: {width?: string | number, height?: string | number})
参数:
参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
width | string | number | 否 | 0 | 宽度。 |
height | string | number | 否 | 0 | 高度。 |
属性
除支持通用属性外,还支持以下属性:
名称 | 类型 | 默认值 | 描述 |
points | Array<Point> | [] | 多边形的顶点坐标列表。 |
fill | Color.Black | 设置填充区域颜色。 | |
fillOpacity | number | string | Resource | 1 | 设置填充区域透明度。 |
stroke | - | 设置边框颜色,不设置时,默认没有边框线条。 | |
strokeDashArray | Array<Length> | [] | 设置边框间隙。 |
strokeDashOffset | number | string | 0 | 边框绘制起点的偏移量。 |
strokeLineCap | LineCapStyle.Butt | 设置边框端点绘制样式。 | |
strokeLineJoin | LineJoinStyle.Miter | 设置边框拐角绘制样式。 | |
strokeMiterLimit | number | string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。 说明: 该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。 |
strokeOpacity | number | string | Resource | 1 | 设置边框透明度。 说明: 该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 |
strokeWidth | Length | 1 | 设置边框宽度。 |
antiAlias | boolean | true | 是否开启抗锯齿效果。 |
Point
点坐标类型。
名称 | 类型定义 | 描述 |
Point | [number, number] | 第一个参数为x轴坐标,第二个参数为y轴坐标(相对坐标)。 |
示例
Rect
更新时间: 2023-02-17 09:19
矩形绘制组件。
说明
该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
子组件
无
接口
Rect(value?: {width?: string | number,height?: string | number,radius?: string | number | Array<string | number>} |
{width?: string | number,height?: string | number,radiusWidth?: string | number,radiusHeight?: string | number})
参数:
参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
width | string | number | 否 | 0 | 宽度。 |
height | string | number | 否 | 0 | 高度。 |
radius | string | number | Array<string | number> | 否 | 0 | 圆角半径,支持分别设置四个角的圆角度数。 |
radiusWidth | string | number | 否 | 0 | 圆角宽度。 |
radiusHeight | string | number | 否 | 0 | 圆角高度。 |
属性
除支持通用属性外,还支持以下属性:
名称 | 类型 | 默认值 | 描述 |
radiusWidth | string | number | 0 | 圆角的宽度,仅设置宽时宽高一致。 |
radiusHeight | string | number | 0 | 圆角的高度,仅设置高时宽高一致。 |
radius | string | number | Array<string | number> | 0 | 圆角半径大小。 |
fill | Color.Black | 设置填充区域颜色。 | |
fillOpacity | number | string | Resource | 1 | 设置填充区域透明度。 |
stroke | - | 设置边框颜色,不设置时,默认没有边框。 | |
strokeDashArray | Array<Length> | [] | 设置边框间隙。 |
strokeDashOffset | number | string | 0 | 边框绘制起点的偏移量。 |
strokeLineCap | LineCapStyle.Butt | 设置边框端点绘制样式。 | |
strokeLineJoin | LineJoinStyle.Miter | 设置边框拐角绘制样式。 | |
strokeMiterLimit | number | string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。 说明: 该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。 |
strokeOpacity | number | string | Resource | 1 | 设置边框透明度。 说明: 该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 |
strokeWidth | Length | 1 | 设置边框宽度。 |
antiAlias | boolean | true | 是否开启抗锯齿效果。 |
示例
