This commit is contained in:
2025-09-09 07:13:16 +08:00
parent b8775ae2cb
commit 813eaeb432
4 changed files with 117 additions and 7 deletions

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file with editors other than draw.io -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background: transparent; background-color: transparent; color-scheme: light dark;" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="241px" height="61px" viewBox="-0.5 -0.5 241 61" content="&lt;mxfile host=&quot;Electron&quot; agent=&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/28.1.2 Chrome/138.0.7204.243 Electron/37.4.0 Safari/537.36&quot; version=&quot;28.1.2&quot; scale=&quot;1&quot; border=&quot;0&quot;&gt;&#10; &lt;diagram name=&quot;第 1 页&quot; id=&quot;Ju8HBPQ0NuOidMe9okl8&quot;&gt;&#10; &lt;mxGraphModel dx=&quot;1426&quot; dy=&quot;841&quot; grid=&quot;1&quot; gridSize=&quot;10&quot; guides=&quot;1&quot; tooltips=&quot;1&quot; connect=&quot;1&quot; arrows=&quot;1&quot; fold=&quot;1&quot; page=&quot;1&quot; pageScale=&quot;1&quot; pageWidth=&quot;827&quot; pageHeight=&quot;1169&quot; math=&quot;0&quot; shadow=&quot;0&quot;&gt;&#10; &lt;root&gt;&#10; &lt;mxCell id=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;1&quot; parent=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;5g9AZhaBOiL0pv-xpRXJ-1&quot; value=&quot;&quot; style=&quot;html=1;shadow=0;dashed=0;align=center;verticalAlign=middle;shape=mxgraph.arrows2.stylisedArrow;dy=0.6;dx=66;notch=0;feather=0.27;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;140&quot; y=&quot;390&quot; width=&quot;240&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;/root&gt;&#10; &lt;/mxGraphModel&gt;&#10; &lt;/diagram&gt;&#10;&lt;/mxfile&gt;&#10;"><defs/><g><g data-cell-id="0"><g data-cell-id="1"><g data-cell-id="5g9AZhaBOiL0pv-xpRXJ-1"><g><path d="M 0 8.1 L 174 18 L 164 0 L 240 30 L 164 60 L 174 42 L 0 51.9 L 0 30 Z" fill="#ffffff" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>箭头填充动画</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
}
.container {
text-align: center;
}
button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
}
button:hover {
background-color: #45a049;
}
button:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
</style>
</head>
<body>
<div class="container">
<h1>箭头填充动画演示</h1>
<!-- 使用clipPath实现真正的内部填充动画 -->
<svg xmlns="http://www.w3.org/2000/svg" width="241px" height="61px" viewBox="-0.5 -0.5 241 61">
<!-- 定义裁剪路径,用于限制填充区域为箭头形状 -->
<defs>
<clipPath id="arrowClipPath">
<path d="M 0 8.1 L 174 18 L 164 0 L 240 30 L 164 60 L 174 42 L 0 51.9 L 0 30 Z" />
</clipPath>
</defs>
<!-- 背景箭头轮廓 - 保持不变 -->
<path id="outlineArrow"
d="M 0 8.1 L 174 18 L 164 0 L 240 30 L 164 60 L 174 42 L 0 51.9 L 0 30 Z"
fill="white"
stroke="black"
stroke-width="2"/>
<!-- 填充层 - 使用裁剪路径限制填充范围 -->
<rect id="fillAnimation"
x="0" y="0" width="0" height="61"
fill="red"
clip-path="url(#arrowClipPath)"/>
</svg>
<button id="startButton">开始填充</button>
</div>
<script>
// 获取DOM元素
const fillAnimation = document.getElementById('fillAnimation');
const startButton = document.getElementById('startButton');
let animationId = null;
let isAnimating = false;
// 开始填充动画
function startFillAnimation() {
if (isAnimating) return;
isAnimating = true;
startButton.disabled = true;
startButton.textContent = "填充中...";
const duration = 2000; // 动画持续时间(毫秒)
const startTime = performance.now();
const startWidth = 0;
const endWidth = 241; // 箭头的总宽度
function animate(currentTime) {
const elapsedTime = currentTime - startTime;
const progress = Math.min(elapsedTime / duration, 1);
// 计算当前的填充宽度从0逐渐变为241
const currentWidth = startWidth + (endWidth - startWidth) * progress;
fillAnimation.setAttribute('width', currentWidth);
if (progress < 1) {
animationId = requestAnimationFrame(animate);
} else {
// 动画完成
isAnimating = false;
startButton.disabled = false;
startButton.textContent = "重新填充";
}
}
animationId = requestAnimationFrame(animate);
}
// 绑定按钮点击事件
startButton.addEventListener('click', startFillAnimation);
</script>
</body>
</html>

View File

@@ -1,6 +0,0 @@
<svg width="800" height="600" xmlns="http://www.w3.org/2000/svg">
<g id="Layer_1">
<title>Layer 1</title>
<path id="svg_1" d="m216.91503,274.91109c0.26021,-11.6278 -0.1665,-23.27113 2.13988,-34.87848c56.67197,3.81831 112.67554,10.06601 168.39255,15.68451c2.99113,-5.70158 1.58328,-10.4311 4.18213,-15.70261c35.79493,11.0927 71.2671,22.34337 105.28547,34.12978c-32.63733,13.36985 -70.07352,24.98065 -106.82583,36.87022c-1.19012,-5.5368 -2.38046,-11.07356 -3.5706,-16.61037c-54.1675,5.3566 -111.45142,10.8948 -165.96914,15.79176c-3.70747,-11.29953 -3.5985,-23.60505 -3.63446,-35.28482z" stroke="#000" fill="#CE7975"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 633 B

View File

@@ -1 +0,0 @@
https://editor.method.ac/