javascript - SVG animation on path like the snail -
i have following svg , draw circles pixel pixel on path after moveing. it's when snail goes let streak behind him. question how draw light red circles?
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewbox="0 0 1000 200" id="svgbox" style="background-color:#e4e4e4"> <path d="m3.858,58.607 c16.784-5.985,33.921-10.518,51.695-12.99c50.522-7.028,101.982,0.51,151.892,8.283c17.83,2.777,35.632,5.711,53.437,8.628 c51.69,8.469,103.241,11.438,155.3,3.794c53.714-7.887,106.383-20.968,159.374-32.228c11.166-2.373,27.644-7.155,39.231-4.449l10,10" stroke="grey" stroke-width="1" fill="none" id="animatemotion"/> <circle cx="" cy="" r="5" fill="red"> <animatemotion dur="6s" repeatcount="0"> <mpath xlink:href="#animatemotion"/> </animatemotion> </circle> </svg>
you can instance:
.path { stroke-dasharray: 1230; stroke-dashoffset: 1230; animation: snail 6s linear forwards; } @keyframes snail { { stroke-dashoffset: 0; } }
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewbox="0 0 1000 200" id="svgbox" style="background-color:#e4e4e4"> <path class="path" d="m3.858,58.607 c16.784-5.985,33.921-10.518,51.695-12.99c50.522-7.028,101.982,0.51,151.892,8.283c17.83,2.777,35.632,5.711,53.437,8.628 c51.69,8.469,103.241,11.438,155.3,3.794c53.714-7.887,106.383-20.968,159.374-32.228c11.166-2.373,27.644-7.155,39.231-4.449l10,10" stroke="pink" stroke-width="12" fill="none" id="animatemotion"/> <circle cx="" cy="" r="5" fill="red"> <animatemotion dur="6s" repeatcount="0"> <mpath xlink:href="#animatemotion"/> </animatemotion> </circle> </svg>
Comments
Post a Comment