【发布时间】:2022-01-11 03:24:01
【问题描述】:
我是画布和 svg 的新手。我想在特定坐标之间制作画布或 svg 线 例如,我有两个矩形,我必须在它们之间画一条线(在这种情况下,我必须使这条线成为两个矩形的中心)
我尝试过的: 像这样的 SVG 代码:
HTML:
<svg version="1.1" id="line_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="15px" xml:space="preserve">
<path class="path2" fill="#01a09e" stroke-width="5" stroke="#01a09e" d="M0 0 l890 0"/>
</svg>
CSS:
.path2 {
stroke-dasharray: 1120;
/* stroke-dashoffset: 800; */
animation: draw1 5s linear alternate;
}
@keyframes draw1 {
from {
stroke-dashoffset: 1120;
}
to {
stroke-dashoffset: 2240;
}
}
【问题讨论】:
-
github.com/steveruizok/perfect-arrows 你可能会感兴趣...
标签: javascript html css svg canvas