animation - 需要 SVG 动画指导
问题描述
我今天阅读了这本 SVG 袖珍指南并从中学到了很多东西,但是……它不包括动画。我需要一些关于如何制作简单动画的指导。我不需要帧之间的任何过渡,我只想为第一帧定义形状,为第二帧定义形状等。
https://svgpocketguide.com/book/
<!-- https://svgpocketguide.com/book/#section-4 -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" width="1080" height="1080">
<!-- the doctype and svg need to be like this to render in Firefox -->
<rect width="1080" height="1080" fill="white"/>
<!-- delay frames by waiting 0.5 seconds between frames -->
<animation frame 1>
<line x1="75" y1="75" x2="10" y2="50" stroke="hsl(0,82%,56%)" stroke-width="3"/>
<line x1="75" y1="75" x2="175" y2="475" stroke="hsl(236,82%,56%)" stroke-width="3"/>
<circle cx="10" cy="50" r="5" fill="black" />
<circle cx="75" cy="75" r="5" fill="black" />
<circle cx="175" cy="475" r="5" fill="black" />
</animation frame 1>
<animation frame 2>
<line x1="75" y1="75" x2="10" y2="50" stroke="hsl(0,82%,56%)" stroke-width="3"/>
<line x1="75" y1="75" x2="175" y2="475" stroke="hsl(236,82%,56%)" stroke-width="3"/>
<circle cx="10" cy="50" r="5" fill="black" />
<circle cx="75" cy="75" r="5" fill="black" />
<circle cx="175" cy="475" r="5" fill="black" />
</animation frame 2>
</svg>
解决方案
这个问题展示了一种在 SVG 中进行基于帧的动画的方法。它使用 CSS 动画,但您可以使用 SMIL 实现相同的效果。但是,CSS 方式在 IMO 上更干净一些。
SIMPLE – 按顺序为多个 SVG 制作动画(如循环 GIF)
这是另一个答案,可能会有所帮助:SVG frame-based animation
推荐阅读
- excel - 在子中访问打开的工作簿有时会生成错误 1004“对象 '_Global' 的 'Sheets' 方法未失败”
- css - 使用 CSS 和 Bootstrap,如何设置屏幕大小为 1/3 的背景图片?
- python - 熊猫将函数列表应用于数据框
- java - 在 ASP 中加密字符串 在 Java 中解密
- javascript - Express + Passport 不同的多个“本地”同时登录
- aws-lambda - 单个 AWS Lambda 函数来响应 Alexa 技能请求,并返回一个 JSON 对象,具体取决于它的调用方式
- r - 使用 ggplot 在 MDS 上绘制向量
- c - 将表达式转换为后缀的程序
- sabre - 调用 Sabre CreatePassengerNameRecordRQ 时出错 - 使用的类别没有可组合票价
- oracle - 执行表三时出现此错误“指定的约束名称必须是唯一的。*操作:为约束指定唯一的约束名称