1 Star 0 Fork 5.3K

OpenHarmony-build / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ts-drawing-components-polygon.md 10.02 KB
一键复制 编辑 原始数据 按行查看 历史
zengyawen 提交于 2021-11-10 20:02 . add arkui

Polygon

多边形绘制组件。

子组件

接口

Polygon(value:{options?: {width: Lenght, height: Length}})

  • 参数

    参数名

    参数类型

    必填

    默认值

    参数描述

    options

    Object

    -

    options参数说明

  • options参数说明

    参数名

    参数类型

    必填

    默认值

    参数描述

    width

    Length

    -

    宽度。

    height

    Length

    -

    高度。

属性

参数名称

参数类型

默认值

必填

参数描述

width

Length

0

多边形所在矩形的宽度。

height

Length

0

多边形所在矩形的高度。

points

Array<Point>

-

多边形的顶点坐标列表。

示例

@Entry
@Component
struct PolygonExample {
  build() {
    Column({ space: 5 }) {
      Flex({ justifyContent: FlexAlign.SpaceAround }) {
        // 在 100 * 100 的矩形框中绘制一个三角形,起点(0, 0),经过(50, 100),终点(100, 0)
        Polygon({ width: 100, height: 100 }).points([[0, 0], [50, 100], [100, 0]])
        // 在 100 * 100 的矩形框中绘制一个四边形,起点(0, 0),经过(0, 100)和(100, 100),终点(100, 0)
        Polygon().width(100).height(100).points([[0, 0], [0, 100], [100, 100], [100, 0]])
        // 在 100 * 100 的矩形框中绘制一个五边形,起点(50, 0),依次经过(0, 50)、(20, 100)和(80, 100),终点(100, 50)
        Polygon().width(100).height(100).points([[50, 0], [0, 50], [20, 100], [80, 100], [100, 50]])
      }.width('100%')
    }.margin({ top: 5 })
  }
}

1
https://gitee.com/openharmony-build/docs.git
git@gitee.com:openharmony-build/docs.git
openharmony-build
docs
docs
master

搜索帮助