鸿蒙5.0开发进阶:JS组件-svg组件(animateTransform)

鸿蒙OpenHarmony【animateTransform】svg组件 支持animate属性和以下表格中的属性。 阅读详情

往期鸿蒙5.0全套实战文章必看:(文中附带全栈鸿蒙5.0学习资料)


animateTransform

说明

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

transform动效,支持的组件范围:

<circle>, <ellipse>, <line>, <path>, <polygon>, <polyline>, <rect>, <text>

权限列表

无

子组件

不支持。

属性

支持animate属性和以下表格中的属性。

名称类型默认值必填描述
type[translate | scale | rotate | skewX | skewY]-是设置transform动画的类型

示例

<!-- xxx.hml -->
<div class="container">
  <div class="back_container">
    <svg>
      <polygon points="60,30 90,90 30,90" fill="red">
        <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 120 140" to="360 360 420" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="red">
        <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0" to="360" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="green">
        <animateTransform attributeName="transform" attributeType="XML" type="scale" from="1" to="2" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="green">
        <animateTransform attributeName="transform" attributeType="XML" type="scale" from="1 1" to="2 4" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="#D2691E">
        <animateTransform attributeName="transform" attributeType="XML" type="skewX" from="10" to="100" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="#D2691E">
        <animateTransform attributeName="transform" attributeType="XML" type="skewY" from="10" to="100" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="#D2691E">
        <animateTransform attributeName="transform" attributeType="XML" type="skewX" from="10" to="100" dur="3s" repeatCount="indefinite"></animateTransform>
        <animateTransform attributeName="transform" attributeType="XML" type="skewY" from="10" to="100" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="blue">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="blue">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0 0" to="0 300" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="blue">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0 0" to="300 300" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
    </svg>
  </div>
</div>
/* xxx.css */
.container {
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  background-color: #f8f8ff;
}

.back_container {
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  height: 1000px;
  width: 1080px;
}

动画叠加

<!-- xxx.hml -->
<div class="container">
  <div class="back_container">
    <svg>
      <polygon points="60,30 90,90 30,90" fill="black">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 200 200; 400 0;
          600 200" keyTimes="0; 0.4; 0.8;1.0" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="green">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 200 200; 400 0;
          600 200" keyTimes="0; 0.4; 0.8;1.0" dur="3s" repeatCount="indefinite"></animateTransform>
        <animateTransform attributeName="transform" attributeType="XML" type="rotate" values="0; 5; 0; 10" keyTimes="0;
          0.4; 0.8; 1.0" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="blue">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 200 200; 400 0;
          600 200" keyTimes="0; 0.4; 0.8;1.0" dur="3s" repeatCount="indefinite"></animateTransform>
        <animateTransform attributeName="transform" attributeType="XML" type="scale" values="1; 1.2; 1; 1.2"
          keyTimes="0; 0.4; 0.8; 1.0" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <polygon points="60,30 90,90 30,90" fill="red">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 200 200; 400 0;
          600 200" keyTimes="0; 0.4; 0.8;1.0" dur="3s" repeatCount="indefinite"></animateTransform>
        <animateTransform attributeName="transform" attributeType="XML" type="scale" values="1; 1.2; 1; 1.2"
          keyTimes="0; 0.4; 0.8; 1.0" dur="3s" repeatCount="indefinite"></animateTransform>
        <animateTransform attributeName="transform" attributeType="XML" type="skewX" values="0; 10; 0; 10"
          keyTimes="0; 0.4; 0.8; 1.0" dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
    </svg>
  </div>
</div>
/* xxx.css */
.container {
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  background-color: #f8f8ff;
}
.back_container {
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  height: 1000px;
  width: 1080px;
}

涉及组件示例

<!-- xxx.hml -->
<div class="container">
  <div class="back_container">
    <svg>
      <svg fill="white" width="600" height="600" viewBox="0 0 50 50">
        <path stroke="black" fill="none" stroke-linejoin="miter" stroke-miterlimit="1" id="p2"
          d="M1,19 l7,-3 l7,3 m2,0 l3.5,-3 l3.5 ,3 m2,0 l2 ,-3 l2 ,3 m2,0 l0.75,-3 l0.75,3 m2,0 l0.5 ,-3 l0.5,3">
          <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="25"
            dur="3s" repeatCount="indefinite"></animateTransform>
        </path>
      </svg>
      <polygon points="60,20 90,80 30,80" fill="black">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300"
          dur="3s" repeatCount="indefinite"></animateTransform>
      </polygon>
      <circle cx="60" cy="130" r="40" stroke-width="4" fill="white" stroke="blue">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300"
          dur="3s" repeatCount="indefinite"></animateTransform>
      </circle>
      <line x1="10" x2="300" y1="280" y2="280" stroke-width="10" stroke="black" stroke-linecap="square">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300"
          dur="3s" repeatCount="indefinite"></animateTransform>
      </line>
      <polyline points="10,380 50,335 50,385 100,310" fill="white" stroke="black">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300"
          dur="3s" repeatCount="indefinite"></animateTransform>
      </polyline>
      <ellipse cx="100" cy="450" rx="70" ry="50" fill="blue">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300"
          dur="3s" repeatCount="indefinite"></animateTransform>
      </ellipse>
      <rect width="100" height="100" x="50" y="540" stroke-width="10" stroke="red" rx="10" ry="10"
        stroke-dasharray="5 3" stroke-dashoffset="3">
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300"
          dur="3s" repeatCount="indefinite"></animateTransform>
      </rect>
      <text x="20" y="700" fill="#D2691E" font-size="40">
        animate-transform
        <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300"
          dur="3s" repeatCount="indefinite"></animateTransform>
      </text>
    </svg>
  </div>
</div>
/* xxx.css */
.container {
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  background-color: #f8f8ff;
}
.back_container {
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  height: 1000px;
  width: 1080px;
}

鸿蒙5.0版开发:UI框架JS组件-svg组件(animateTransform) transform动效.......... 阅读详情

相关推荐

第五节 Amesim《直动型溢流阀HCD建模》HCD5 学习资料

利用HCD原则创建直动型溢流阀的界面。这可能包括图形化表示直动型溢流阀的工作原理、操作方式和调节方法。这样的界面应当直观且易于理解,使用户能够轻松了解阀门的功能和使用方法。

m0_58052642的博客 1330

28. animateTransform标签实现动画

这个标签用于在SVG元素上应用变换动画,如旋转、缩放、移动等。

一名全栈开发工程师 1359

VASP计算层错能(SFE)全攻略2

本文介绍了使用VASP计算纯镍(Ni)层错能(SFE)的具体步骤。首先构建Ni的FCC单胞并扩展为超胞,通过修改原子位置引入堆垛层错;随后分别计算完美晶体和含层错结构的能量;最后通过能量差与层错面积之比求得SFE值。计算需注意k点网格、截断能和超胞尺寸的收敛性测试,并推荐使用PAW赝势和ASE等工具辅助结构构建。

weixin_50519490的博客 1992

SVG 动画(animate、animateTransform、animateMotion)

参考 MDN开发文档 https://developer.mozilla.org/en-US/docs/Web/SVG/SVG_animation_with_SMILSMIL As of Chrome 45.0, SMIL animations are deprecated in favor of CSS animations and Web animations. Gecko 2.0

司马懿的西山居 3万+

海康威视SADP SDK实战:5分钟搞定局域网设备搜索(附C++代码示例)

本文详细解析了海康威视SADP SDK在局域网设备搜索中的高效应用,通过C++代码示例展示如何快速实现设备发现与信息获取。SADP协议支持全面设备信息采集和实时状态更新,适用于智能安防和物联网管理场景,帮助开发者5分钟内完成设备搜索功能集成。

rum55的博客 880

智能Agent如何重塑企业流程

在当今数字化时代,企业流程的效率和敏捷性至关重要。传统企业流程往往受限于人工操作,效率低下、成本高昂,难以适应快速变化的市场环境。智能Agent作为一种新兴技术,凭借其强大的智能化能力,正在逐渐改变企业流程的运作模式,为企业带来新的机遇和挑战。智能Agent是一种能够感知环境、自主决策、执行任务的软件实体。它可以模拟人类的智能行为,例如学习、推理、规划和沟通。通过将智能Agent嵌入到企业流程中,可以实现流程的自动化、优化和智能化,从而提高效率、降低成本、提升客户体验。8.1 研究成果总结。

AGI×大数据,开启智能时代的认知跃迁;解码AGI,赋能数据驱动的智能革命。 875

animateTransform SVG动画(三)

animateTransform元素可以设置目标元素上的一个变形属性,从而允许动画控制转换、缩放、旋转或斜切。animateTransform: 实现transform变换动画效果(

黄彪博客 1140

PreScan快速入门到精通第二十一讲驾驶员模型之驾驶员在环

请注意,操纵杆的输出角度是以度为单位的,而方向盘执行器希望其输入是以弧度为单位的。当选择一个支持的方向盘时,PreScan会自动将按钮映射到正确的功能上(如换挡),并设置轴的正确范围(如转向角度)。该系统中的所有其他组件都是为了提供正确的按钮映射,并为所选的方向盘设置正确的范围。对于每一个额外连接的控制器,它们的ID会增加一个,例如第二个控制器的设备ID为1,第三个控制器的设备ID为2,等等。由于所有的方向盘最初放在编译表上的设备ID都是0,所以用户应该先进行正确的调整,将每个控制器设置为正确的设备ID。.

小明师兄的博客 1426

SVG_6_矢量图_transform_animateTransform_豚_鼠?

​PS:补一下SVG_6,本来6是另一个功能介绍,素材没整理好,算是错过,后面再介绍。 知识点: 一,transform,这不是控件,只是一个属性,但功能强大,支持位移、缩放、旋转。 二,animateTransform标签,这是一个控件。 使用时,最好用<g>标签单独控制想要是用动画的控件,否则会使整个画布都动画起来。 一般用法: 旋转属性就像:rotation(t...

知识搬运工,资料任你拿,包括书籍、电影、电视剧、网站、软件等,VX公人人人号:向前书局 835

大模型——Ollama简明教程

在这篇文章中,我们将了解如何使用 Ollama、如何在 Ollama 中创建自己的模型 以及如何使用 Ollama 构建聊天机器人。这是深入研究 Ollama 的第一部分,以及我所学到的有关本地 LLM 的知识以及如何将它们用于基于推理的应用程序。在这篇文章中,你将了解——

1701

超越防抖:索尼CXD5254GG芯片如何重新定义电子影像稳定

索尼CXD5254GG芯片通过融合6轴IMU与图像传感器数据,重新定义了电子影像稳定技术。其核心突破在于实时地平线校正、抑制果冻效应和镜头畸变校正,并搭载智能画质控制器提升画面细节。该芯片适用于广播制作、体育娱乐、安防监控和机器人视觉导航等专业领域,提供开箱即用的优化参数配置,大幅缩短开发周期。CXD5254GG不仅实现稳定成像,更通过姿态感知与智能优化,为专业影像应用提供了完整的稳定解决方案。

致力于lidar应用开发 118

【鸿蒙next开发】JS组件:svg组件(animateTransform)

本文详解HarmonyOSNext中animateTransform组件的使用方法.........

m0_73088370的博客 444

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

【鸿蒙next开发】JS组件:svg组件(path)

本文详细介绍了HarmonyOS Next中Path组件的核心用法.......

m0_73088370的博客 287

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

【鸿蒙next开发】JS组件:svg组件(polyline)

本文介绍了鸿蒙5.0中polyline组件的使用方法和属性配置。

m0_73088370的博客 340

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

【HarmonyOS Next之旅】基于ArkTS开发(三) -> 兼容JS的类Web开发(六) -> CSS动画

在关键帧(Keyframes)中动态设置父组件的width和height,实现组件变大缩小。子组件设置scale属性使父子组件同时缩放,再设置opacity实现父子组件的显示与隐藏。

枫叶丹4的博客 2202

SVG基本使用(四、动画、动画常用属性、复合动画/往返动画/形变动画/路径动画、脚本编程

一、动画1.SVG动画在SVG中提供了三种常用动画标记animate:基础动画animateTransform:形变动画animateMotion:路径动画2.SVG动画属性attributeType: CSS/XML 规定的属性值的名称空间attributeName: 规定元素的哪个属性会产生动画效果from/to: 从哪到哪dur: 动画时长fill: 动画结束之后的状态 保持freeze结束状态/remove恢复初始状态(默认值)3.SVG动画使用方式。

coldriversnow的专栏 9786

SVG_11_动画专题之标签:animateTransform

写在前面: 动画是最直观的表达方式,比文字能够给人更大的冲击性。也是人们最容易查看、记忆最深刻,最过目不忘的友好表达方式,从本篇为第二篇文章,其他还有两篇讲述动画,共计三篇动画文档,满足动画你对动画渴求。 上一篇:SVG_10_动画专题之标签:animate 这个animateTransform标签,其实之前有一篇文章有讲过,但站的角度不同,想查阅的,点击跳转查看:SVG_8_CSS-...

知识搬运工,资料任你拿,包括书籍、电影、电视剧、网站、软件等,VX公人人人号:向前书局 1435

SVG_8_CSS-animation_SVG-animateTransform标签_动画解析

知识点: CSS中使用animation控制动画效果; SVG中使用animateTransform标签控制动画效果; PS:虽然两者写法上稍微有点区别,但原理上是一致的; 一,先来说说CSS中的控制方法。 <style> #svg { width: 1500px; height: 400px; background: url...

知识搬运工,资料任你拿,包括书籍、电影、电视剧、网站、软件等,VX公人人人号:向前书局 1483

transform和animation的区别

2. transform属性是静态属性,需要配合transition和animation才能展现出动画效果。你可以把它看成是跟left、top等属性一样,只是一个静态样式而已。transform:1. transform 属性向元素应用 2D 或 3D 转换。区别: 1. transition是css中检测指定属性变化进行自动补间动画的属性。2. animate是先指定好动画过程中的关键帧属性,进行动画的属性。animation:一个css3的动画属性,需要配合@keyframes 使用。

subsistent的博客 613

SVG动画.animateTransform

1、来自于:SVG之Animation - 前端学习笔记 - SegmentFault.html(https://segmentfault.com/a/1190000009371194) 2、AnimateTransform.html(UTF8)   ZC:下面的属性(type="scale" from="1" to="4 2"),实际等价于(type="scale" from="1 1" t...

weixin_30602505的博客 1139

transition、transform、animate的区别?

1、transition、transform、animate的区别?transition:过渡效果,它有4个属性:transition: property duration timing-function delay;property :css属性的名称duration :多长时间完成timing-function:转速曲线delay:开始的时候。transform: 应用于元素的2D或3D转换。...

沿华的博客 2297

svg 缩放_深入探讨:可缩放矢量图形(SVG)动画

今天,我们将继续有关可缩放矢量图形(SVG)的讨论,而这次我们将与SVG Animation一起使用 。 不过不要害怕,SVG Animation相对容易,实际上,在这篇文章中,我们将从基础知识开始。 推荐读物: 可扩展矢量图形概览 基本实施 SVG中的动画可以通过<animate>元素完成; <svg> <rect width="200" hei...

cune1359的博客 1315

svg 动画

值之间的过渡方式受。

weixin_54188159的博客 2290

transform、 animation、 transition、 translate之间的区别

animation:animation属性可以创建复杂动画效果,可以设置关键帧、动画持续时间、动画方式、动画延迟等属性。使用animation属性可以实现更丰富的动画效果,包括连续的动画、循环的动画、交错的动画等。transform:transform属性可以对元素进行旋转、缩放、平移、扭曲等变形操作,可以通过translate、scale、rotate、skew等子属性来实现各种不同的变形效果。transition作用于元素的某些CSS属性,如颜色、大小、位置等,当这些属性发生变化时就会触发过渡效果。

zzx262625的博客 1757

Animate与transform的使用

Animate是用css给前端加载动画的效果: 网址:https://daneden.github.io/animate.css/ <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="static/css/Animate.css"> ...

weixin_33754913的博客 753
上一篇: 鸿蒙5.0开发进阶:JS组件-svg组件(animateMotion)
下一篇: 鸿蒙5.0开发进阶:JS组件-自定义组件(自定义组件的基本用法)
懂你的大海
博客等级 码龄6年 9049粉丝 1381原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值