更新升级 专属应用 系统故障 硬件故障 电脑汽车 鸿蒙刷机 鸿蒙开发Linux教程 鸿蒙开发Linux命令
当前位置:HMXT之家 > 应用开发 > 鸿蒙HarmonyOS应用开发之Svg组件path体验,附实例代码

鸿蒙HarmonyOS应用开发之Svg组件path体验,附实例代码

更新时间:2022-01-27 14:53:06浏览次数:854+次

以下介绍鸿蒙HarmonyOS应用开发之Svg组件path体验,将给出属性及实例代码。

\

正文内容

一、说明

绘制路径。

说明:该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。

二、子组件

支持animate、animateMotion、animateTransform。

三、属性

支持Svg组件通用属性和以下属性:

名称

类型

默认值

必填

描述

id

string

-

组件的唯一标识。

d

string

-

设置路径的形状。包含一组字符指令,大写字母为绝对路径,小写字符为相对路径。

字母指令表示的意义如下:

M/m = moveto

L/l = lineto

H/h = horizontal lineto

V/v = vertical lineto

C/c = curveto

S/s = smooth curveto

Q/q = quadratic Belzier curve

T/t = smooth quadratic Belzier curveto

A/a = elliptical Arc

Z/z = closepath

四、案例代码

<div class="container">

    <svg width="400" height="200">

        <path d="M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z"

              stroke="blue" stroke-width="3" fill="red">

        </path>

    </svg>

    <svg width="400" height="400">

        <path d="M 100 90 A 10 20 -30 1 0 91.5 95

              A 10 20 -90 1 0 91.5 105

              A 10 20 -150 1 0 100 110

              A 10 20 150 1 0 108.5 105

              A 10 20 90 1 0 108.5 95

              A 10 20 30 1 0 100 90"

              stroke="blue" stroke-width="3" fill="red">

        </path>

    </svg>

</div>

五、所得效果说明及源代码地址

具体的效果可参考最上面的截图,完整代码地址为https://gitee.com/jltfcloudcn/jump_to/tree/master/path。