svg animated a diamond path "d" - html
I wanted to animated this dash line diamond but since it path d and I don't know how to make that work... I basically search some stuff like this one. https://codepen.io/MyXoToD/pen/xxrGdR?editors=1100 that I found in article in svg path d but I don't know how it works...Also my problem is just simple.
<svg width="119" height="30" viewBox="0 0 119 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M119 0V25H10.7735L6 29.7735L0.226501 24L6 18.2265L10.7735 23H117V0H119Z" fill="black"/>
</svg>
When it hovers it will animated from creating the diamond to the edge of line... and then it will stays there unless it unhover. Thats it.
Is this what you mean?
The existing path is a filled shape that incorporates the diamond. I had to separate the diamond out into its own path. Then change the rest of the path to a line.
Then when you hover, we apply an animation to the diamond. It gets moved along the line and up to the top right corner.
svg:hover .diamond {
animation: move 0.5s ease-in forwards;
}
#keyframes move {
0% {
transform: translate(0,0);
}
82% {
transform: translate(112px,0);
}
100% {
transform: translate(112px,-24px);
}
}
<svg width="119" height="30" viewBox="0 -6 124 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<!-- the L-shaped path -->
<path fill-rule="evenodd" clip-rule="evenodd" d="M 118,0 V 24 H 6" fill="none" stroke="black" stroke-width="2"/>
<!-- the moving diamond -->
<path fill-rule="evenodd" clip-rule="evenodd" d="M 11.7735,24 L 6,29.7735 L 0.2265,24 L 6,18.2265 L 11.7735,24Z" fill="black" class="diamond"/>
</svg>
Related
How to change the click area of an SVG shape so that two of them next to each other don't ovelap each other?
I have drawn a dashed line showing the boundaries of the black shape which is on top of the other shape. My problem is that where it overlaps the blue one, I want to click that blue shape and not the black one. So I want to be able to click each of them exacly where they are visible. I have been trying to solve this for hours, but couldn't make it work. Here is the code I have: .rotate { transform: rotate(180deg); position: relative; margin-left: -71px; top: 1px; } <svg viewBox="0 0 133 67" width="133" height="67" fill="white" xmlns="http://www.w3.org/2000/svg" pointer-events="visiblePainted"> <path d="M66.5 1.5L1.5 66.5H131.5L66.5 1.5Z" fill="#000eee" stroke="black" cursor="pointer" pointer-events="visiblePainted" id="shape1"/> </svg> <svg class="rotate" viewBox="0 0 133 67" width="133" height="67" fill="white" xmlns="http://www.w3.org/2000/svg" pointer-events="visiblePainted"> <path d="M66.5 1.5L1.5 66.5H131.5L66.5 1.5Z" fill="currentColor" stroke="black" cursor="pointer" pointer-events="visiblePainted" id="shape2"/> </svg>
Animate tag in svg doesn't trigger animation like expected
I'm trying to animate an svg path for about 3 days now.. When i use the <animate> tag, the transition happens however it does so without any animation just from position A to position B. I'd like to have a transition in between both so that is appears smoothly. What should I do ? <div class="container"> <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 167 1888.69"> <defs> <style> .cls-1 { fill: #f2f2f2; } .cls-2 { fill: #65bec0; } .cls-3 { fill: #88d3cd; } .cls-4 { fill: #60b9bc; } </style> </defs> <path id="glass" class="cls-1" d="M927.2,52.82c16.15,0,30.77,5.53,41.37,14.51s17.13,21.38,17.13,35.08l.3,1620.4c0,27.38-26.19,49.6-58.49,49.6-16.15,0-30.77-5.53-41.37-14.51S869,1736.52,869,1722.83l-.3-1620.4C868.71,75,894.9,52.83,927.2,52.82Z" transform="translate(-819 -52.82)"/> <path class="cls-2" d="M881.46,1086.43h.09l-.09.06Z" transform="translate(-819 -52.82)"/> <path id="back-liquid" class="cls-3" d="M925.15,1767.18c27.63.11,50.13-21.59,50.23-48.44L977,1285.27l.51-294.54s-26.11-2.52-49.22-16.49c-12.79-7.73-48.11,12.32-55.73,15.79l3.75,449.17,0,289.36a48.12,48.12,0,0,0,13.45,24.25A50.6,50.6,0,0,0,925.15,1767.18Z" transform="translate(-819 -52.82)"/> <g id="front-liquid"> <path class="cls-4" transform="translate(-819 -52.82)"> <animate id="poi_front_1" attributeName="d" values="M929.78,1765.31c-29.07.12-52.74-21.56-52.87-48.42l-2-433.46-.74-294.54s28.27,1.81,51-14.37c14.77-10.5,47,4.34,53.86,15.48l1.87,447.29.17,289.36A47.56,47.56,0,0,1,967,1750.91,54.74,54.74,0,0,1,929.78,1765.31Z; m 929.78,1765.31 c -29.07,0.12 -52.74,-21.56 -52.87,-48.42 l -2,-433.46 -2.35,-293.4 c 0,0 29.04531,-29.79622 50.10593,-17.59673 31.46382,10.78462 34.47963,16.02568 55.52938,6.71575 L 980.9,1437.29 l 0.17,289.36 c -2.14495,9.3171 -7.04817,17.7714 -14.07,24.26 -10.15255,9.3127 -23.4433,14.4547 -37.22,14.4Z" begin="0s; poi_front_2.end" dur="1s" /> <animate id="poi_front_2" attributeName="d" values="m 929.78,1765.31 c -29.07,0.12 -52.74,-21.56 -52.87,-48.42 l -2,-433.46 -2.35,-293.4 c 0,0 29.04531,-29.79622 50.10593,-17.59673 31.46382,10.78462 34.47963,16.02568 55.52938,6.71575 L 980.9,1437.29 l 0.17,289.36 c -2.14495,9.3171 -7.04817,17.7714 -14.07,24.26 -10.15255,9.3127 -23.4433,14.4547 -37.22,14.4 z; M929.78,1765.31c-29.07.12-52.74-21.56-52.87-48.42l-2-433.46-.74-294.54s28.27,1.81,51-14.37c14.77-10.5,47,4.34,53.86,15.48l1.87,447.29.17,289.36A47.56,47.56,0,0,1,967,1750.91,54.74,54.74,0,0,1,929.78,1765.31Z" begin="poi_front_1.end" dur="1.5s" /> </path> </g> </svg> </div> html,body {width:100%; height:100%;} .container{ width: 80%; height: 80vh; margin:auto; } svg { width: 60%; height:80vh; margin: auto; } Here is a codepen demo of my svg : https://codepen.io/knudsem/pen/oNxoxrB edit: i tried to reorganize the values, but still no luck. I don't get it, what am I missing?
Two observations: You don't need 2 animations. You can use instead a list of 3 values for the animation: values ="v1;v2;v1" This together with repeatCount="indefinite" will do the trick. Secondly: in this case the paths should be identical except the C and the S command in the middle. You need to keep the same commands in the same order, changing only the y value for the control points of the curves. Also since I've changed the d attribute manually I've transformed it to all absolute using this converter: https://codepen.io/leaverou/pen/RmwzKv <svg viewBox="0 850 167 1888.69"> <g id="front-liquid"> <path transform="translate(-819 -52.82)" stroke="red" stroke-width="5" fill="none" d=" M929.78,1765.31 C900.71,1765.43,877.04,1743.75,876.91,1716.89 L874.91,990.03 C872.5,990 901.6,950.2,922.7,972.4 S957.1,988.4,978.2,979.1 L980.9,1726.65 C978.925,1735.9671,974.022,1744.42,967,1750.91 C956.847,1760.2227,943.56,1765.3647,929.78,1765.31 Z"> <animate attributeName="d" values="M929.78,1765.31 C900.71,1765.43,877.04,1743.75,876.91,1716.89 L874.91,990.03 C872.5,990 901.6,988.2 922.7,972.4 S957.1,960 978.2,979.1 L980.9,1726.65 C978.925,1735.9671,974.022,1744.42,967,1750.91 C956.847,1760.2227,943.56,1765.3647,929.78,1765.31 Z; M929.78,1765.31 C900.71,1765.43,877.04,1743.75,876.91,1716.89 L874.91,990.03 C872.5,990 901.6,950.2,922.7,972.4 S957.1,988.4,978.2,979.1 L980.9,1726.65 C978.925,1735.9671,974.022,1744.42,967,1750.91 C956.847,1760.2227,943.56,1765.3647,929.78,1765.31 Z; M929.78,1765.31 C900.71,1765.43,877.04,1743.75,876.91,1716.89 L874.91,990.03 C872.5,990 901.6,988.2 922.7,972.4 S957.1,960 978.2,979.1 L980.9,1726.65 C978.925,1735.9671,974.022,1744.42,967,1750.91 C956.847,1760.2227,943.56,1765.3647,929.78,1765.31 Z" begin="0s;" dur="1s" repeatCount="indefinite" /> </path> </g> </svg> I've removed the non animated paths and I've changed the viewBox value so that I'd be able to see the relevant part of the shape. You can change back to what you had,
How to change the background color and text color of SVG using css?
I have SVG and what I am doing is I have to change the color of the SVG using css. I tried below code but it's only changing the background color I also want to change the text color. This is my actual SVG. My expected output. I am getting the output. Is it possible? .mylogo2 { fill: yellow; color: red } <div class="mylogo2"> <svg xmlns="http://www.w3.org/2000/svg" width="187.684" height="58.885" viewBox="0 0 187.684 58.885"> <g id="Sample_Logo" data-name="Sample Logo" transform="translate(-475 -511)"> <path id="Path_1" data-name="Path 1" d="M0,19.038,187.684,0V39.848L0,58.885Z" transform="translate(475 511)"/> <path id="Path_2" data-name="Path 2" d="M6.888-8.456-.56-19.824H4.872l4.2,7.42,4.452-7.42H18.7L11.256-8.456V0H6.888ZM19.1-9.912a11.2,11.2,0,0,1,.8-4.312,9.457,9.457,0,0,1,2.226-3.29A9.807,9.807,0,0,1,25.508-19.6a12.213,12.213,0,0,1,4.284-.728,12.213,12.213,0,0,1,4.284.728,9.807,9.807,0,0,1,3.388,2.086,9.457,9.457,0,0,1,2.226,3.29,11.2,11.2,0,0,1,.8,4.312,11.2,11.2,0,0,1-.8,4.312,9.457,9.457,0,0,1-2.226,3.29A9.807,9.807,0,0,1,34.076-.224,12.213,12.213,0,0,1,29.792.5a12.213,12.213,0,0,1-4.284-.728A9.807,9.807,0,0,1,22.12-2.31,9.457,9.457,0,0,1,19.894-5.6,11.2,11.2,0,0,1,19.1-9.912Zm4.536,0a7.271,7.271,0,0,0,.434,2.562,5.868,5.868,0,0,0,1.246,2.016A5.687,5.687,0,0,0,27.258-4a6.488,6.488,0,0,0,2.534.476A6.488,6.488,0,0,0,32.326-4a5.687,5.687,0,0,0,1.946-1.33A5.868,5.868,0,0,0,35.518-7.35a7.271,7.271,0,0,0,.434-2.562,7.3,7.3,0,0,0-.434-2.548,5.842,5.842,0,0,0-1.246-2.03,5.687,5.687,0,0,0-1.946-1.33,6.488,6.488,0,0,0-2.534-.476,6.488,6.488,0,0,0-2.534.476,5.687,5.687,0,0,0-1.946,1.33,5.842,5.842,0,0,0-1.246,2.03A7.3,7.3,0,0,0,23.632-9.912Zm36.54,2.268A9.561,9.561,0,0,1,59.64-4.4,7.147,7.147,0,0,1,58.058-1.82,7.247,7.247,0,0,1,55.44-.112,9.83,9.83,0,0,1,51.828.5a9.914,9.914,0,0,1-3.64-.616A7.247,7.247,0,0,1,45.57-1.82,7.147,7.147,0,0,1,43.988-4.4a9.561,9.561,0,0,1-.532-3.248v-12.18h4.368V-7.812A4.827,4.827,0,0,0,48.118-6.1a4.081,4.081,0,0,0,.826,1.358,3.751,3.751,0,0,0,1.274.9,4,4,0,0,0,1.61.322,3.9,3.9,0,0,0,1.6-.322,3.787,3.787,0,0,0,1.26-.9A4.081,4.081,0,0,0,55.51-6.1,4.827,4.827,0,0,0,55.8-7.812V-19.824h4.368ZM64.2-19.824h7.672a13.537,13.537,0,0,1,2.87.294,6.809,6.809,0,0,1,2.38.98A4.883,4.883,0,0,1,78.75-16.7a6.258,6.258,0,0,1,.6,2.9,5.818,5.818,0,0,1-1.092,3.57,4.916,4.916,0,0,1-3.192,1.862L80.108,0H74.872L70.728-7.924H68.572V0H64.2Zm4.368,8.2h2.576q.588,0,1.246-.042a3.9,3.9,0,0,0,1.19-.252,2.058,2.058,0,0,0,.882-.658,2,2,0,0,0,.35-1.26,2.092,2.092,0,0,0-.308-1.2,2.053,2.053,0,0,0-.784-.686,3.478,3.478,0,0,0-1.092-.322,8.908,8.908,0,0,0-1.2-.084H68.572Zm22.232-8.2h4.368V-4.032h8.092V0H90.8Zm13.8,9.912a11.2,11.2,0,0,1,.8-4.312,9.457,9.457,0,0,1,2.226-3.29A9.807,9.807,0,0,1,111.02-19.6a12.213,12.213,0,0,1,4.284-.728,12.213,12.213,0,0,1,4.284.728,9.807,9.807,0,0,1,3.388,2.086,9.457,9.457,0,0,1,2.226,3.29,11.2,11.2,0,0,1,.8,4.312,11.2,11.2,0,0,1-.8,4.312,9.457,9.457,0,0,1-2.226,3.29,9.807,9.807,0,0,1-3.388,2.086A12.213,12.213,0,0,1,115.3.5a12.213,12.213,0,0,1-4.284-.728,9.807,9.807,0,0,1-3.388-2.086,9.457,9.457,0,0,1-2.226-3.29A11.2,11.2,0,0,1,104.608-9.912Zm4.536,0a7.271,7.271,0,0,0,.434,2.562,5.868,5.868,0,0,0,1.246,2.016A5.687,5.687,0,0,0,112.77-4a6.488,6.488,0,0,0,2.534.476A6.488,6.488,0,0,0,117.838-4a5.687,5.687,0,0,0,1.946-1.33A5.868,5.868,0,0,0,121.03-7.35a7.271,7.271,0,0,0,.434-2.562,7.3,7.3,0,0,0-.434-2.548,5.842,5.842,0,0,0-1.246-2.03,5.687,5.687,0,0,0-1.946-1.33A6.488,6.488,0,0,0,115.3-16.3a6.488,6.488,0,0,0-2.534.476,5.687,5.687,0,0,0-1.946,1.33,5.842,5.842,0,0,0-1.246,2.03A7.3,7.3,0,0,0,109.144-9.912ZM146.916-1.4A15.812,15.812,0,0,1,142.884.056,20.476,20.476,0,0,1,138.6.5a12.213,12.213,0,0,1-4.284-.728,9.807,9.807,0,0,1-3.388-2.086A9.457,9.457,0,0,1,128.7-5.6a11.2,11.2,0,0,1-.8-4.312,11.2,11.2,0,0,1,.8-4.312,9.457,9.457,0,0,1,2.226-3.29,9.806,9.806,0,0,1,3.388-2.086,12.213,12.213,0,0,1,4.284-.728,15.855,15.855,0,0,1,4.382.574A8.58,8.58,0,0,1,146.5-17.78l-3.08,3.36a6.137,6.137,0,0,0-2.016-1.4,7.184,7.184,0,0,0-2.8-.476,6.487,6.487,0,0,0-2.534.476,5.687,5.687,0,0,0-1.946,1.33,5.842,5.842,0,0,0-1.246,2.03,7.3,7.3,0,0,0-.434,2.548,7.271,7.271,0,0,0,.434,2.562,5.868,5.868,0,0,0,1.246,2.016A5.687,5.687,0,0,0,136.066-4a6.488,6.488,0,0,0,2.534.476,8.349,8.349,0,0,0,2.464-.322,9.3,9.3,0,0,0,1.652-.658v-3.22H139.16V-11.76h7.756Zm2.772-8.512a11.2,11.2,0,0,1,.8-4.312,9.457,9.457,0,0,1,2.226-3.29A9.807,9.807,0,0,1,156.1-19.6a12.213,12.213,0,0,1,4.284-.728,12.213,12.213,0,0,1,4.284.728,9.807,9.807,0,0,1,3.388,2.086,9.457,9.457,0,0,1,2.226,3.29,11.2,11.2,0,0,1,.8,4.312,11.2,11.2,0,0,1-.8,4.312,9.457,9.457,0,0,1-2.226,3.29,9.807,9.807,0,0,1-3.388,2.086A12.213,12.213,0,0,1,160.384.5,12.213,12.213,0,0,1,156.1-.224a9.807,9.807,0,0,1-3.388-2.086,9.457,9.457,0,0,1-2.226-3.29A11.2,11.2,0,0,1,149.688-9.912Zm4.536,0a7.271,7.271,0,0,0,.434,2.562A5.868,5.868,0,0,0,155.9-5.334,5.687,5.687,0,0,0,157.85-4a6.488,6.488,0,0,0,2.534.476A6.488,6.488,0,0,0,162.918-4a5.687,5.687,0,0,0,1.946-1.33A5.868,5.868,0,0,0,166.11-7.35a7.271,7.271,0,0,0,.434-2.562,7.3,7.3,0,0,0-.434-2.548,5.842,5.842,0,0,0-1.246-2.03,5.687,5.687,0,0,0-1.946-1.33,6.488,6.488,0,0,0-2.534-.476,6.487,6.487,0,0,0-2.534.476,5.687,5.687,0,0,0-1.946,1.33,5.842,5.842,0,0,0-1.246,2.03A7.3,7.3,0,0,0,154.224-9.912Z" transform="matrix(0.995, -0.105, 0.105, 0.995, 484.921, 558.826)" fill="#fff"/> </g> </svg> </div>
You need to change the fill of the second path: .mylogo2 { fill: yellow; } #Path_2 { fill: red; } <div class="mylogo2"> <svg xmlns="http://www.w3.org/2000/svg" width="187.684" height="58.885" viewBox="0 0 187.684 58.885"> <g id="Sample_Logo" data-name="Sample Logo" transform="translate(-475 -511)"> <path id="Path_1" data-name="Path 1" d="M0,19.038,187.684,0V39.848L0,58.885Z" transform="translate(475 511)"/> <path id="Path_2" data-name="Path 2" d="M6.888-8.456-.56-19.824H4.872l4.2,7.42,4.452-7.42H18.7L11.256-8.456V0H6.888ZM19.1-9.912a11.2,11.2,0,0,1,.8-4.312,9.457,9.457,0,0,1,2.226-3.29A9.807,9.807,0,0,1,25.508-19.6a12.213,12.213,0,0,1,4.284-.728,12.213,12.213,0,0,1,4.284.728,9.807,9.807,0,0,1,3.388,2.086,9.457,9.457,0,0,1,2.226,3.29,11.2,11.2,0,0,1,.8,4.312,11.2,11.2,0,0,1-.8,4.312,9.457,9.457,0,0,1-2.226,3.29A9.807,9.807,0,0,1,34.076-.224,12.213,12.213,0,0,1,29.792.5a12.213,12.213,0,0,1-4.284-.728A9.807,9.807,0,0,1,22.12-2.31,9.457,9.457,0,0,1,19.894-5.6,11.2,11.2,0,0,1,19.1-9.912Zm4.536,0a7.271,7.271,0,0,0,.434,2.562,5.868,5.868,0,0,0,1.246,2.016A5.687,5.687,0,0,0,27.258-4a6.488,6.488,0,0,0,2.534.476A6.488,6.488,0,0,0,32.326-4a5.687,5.687,0,0,0,1.946-1.33A5.868,5.868,0,0,0,35.518-7.35a7.271,7.271,0,0,0,.434-2.562,7.3,7.3,0,0,0-.434-2.548,5.842,5.842,0,0,0-1.246-2.03,5.687,5.687,0,0,0-1.946-1.33,6.488,6.488,0,0,0-2.534-.476,6.488,6.488,0,0,0-2.534.476,5.687,5.687,0,0,0-1.946,1.33,5.842,5.842,0,0,0-1.246,2.03A7.3,7.3,0,0,0,23.632-9.912Zm36.54,2.268A9.561,9.561,0,0,1,59.64-4.4,7.147,7.147,0,0,1,58.058-1.82,7.247,7.247,0,0,1,55.44-.112,9.83,9.83,0,0,1,51.828.5a9.914,9.914,0,0,1-3.64-.616A7.247,7.247,0,0,1,45.57-1.82,7.147,7.147,0,0,1,43.988-4.4a9.561,9.561,0,0,1-.532-3.248v-12.18h4.368V-7.812A4.827,4.827,0,0,0,48.118-6.1a4.081,4.081,0,0,0,.826,1.358,3.751,3.751,0,0,0,1.274.9,4,4,0,0,0,1.61.322,3.9,3.9,0,0,0,1.6-.322,3.787,3.787,0,0,0,1.26-.9A4.081,4.081,0,0,0,55.51-6.1,4.827,4.827,0,0,0,55.8-7.812V-19.824h4.368ZM64.2-19.824h7.672a13.537,13.537,0,0,1,2.87.294,6.809,6.809,0,0,1,2.38.98A4.883,4.883,0,0,1,78.75-16.7a6.258,6.258,0,0,1,.6,2.9,5.818,5.818,0,0,1-1.092,3.57,4.916,4.916,0,0,1-3.192,1.862L80.108,0H74.872L70.728-7.924H68.572V0H64.2Zm4.368,8.2h2.576q.588,0,1.246-.042a3.9,3.9,0,0,0,1.19-.252,2.058,2.058,0,0,0,.882-.658,2,2,0,0,0,.35-1.26,2.092,2.092,0,0,0-.308-1.2,2.053,2.053,0,0,0-.784-.686,3.478,3.478,0,0,0-1.092-.322,8.908,8.908,0,0,0-1.2-.084H68.572Zm22.232-8.2h4.368V-4.032h8.092V0H90.8Zm13.8,9.912a11.2,11.2,0,0,1,.8-4.312,9.457,9.457,0,0,1,2.226-3.29A9.807,9.807,0,0,1,111.02-19.6a12.213,12.213,0,0,1,4.284-.728,12.213,12.213,0,0,1,4.284.728,9.807,9.807,0,0,1,3.388,2.086,9.457,9.457,0,0,1,2.226,3.29,11.2,11.2,0,0,1,.8,4.312,11.2,11.2,0,0,1-.8,4.312,9.457,9.457,0,0,1-2.226,3.29,9.807,9.807,0,0,1-3.388,2.086A12.213,12.213,0,0,1,115.3.5a12.213,12.213,0,0,1-4.284-.728,9.807,9.807,0,0,1-3.388-2.086,9.457,9.457,0,0,1-2.226-3.29A11.2,11.2,0,0,1,104.608-9.912Zm4.536,0a7.271,7.271,0,0,0,.434,2.562,5.868,5.868,0,0,0,1.246,2.016A5.687,5.687,0,0,0,112.77-4a6.488,6.488,0,0,0,2.534.476A6.488,6.488,0,0,0,117.838-4a5.687,5.687,0,0,0,1.946-1.33A5.868,5.868,0,0,0,121.03-7.35a7.271,7.271,0,0,0,.434-2.562,7.3,7.3,0,0,0-.434-2.548,5.842,5.842,0,0,0-1.246-2.03,5.687,5.687,0,0,0-1.946-1.33A6.488,6.488,0,0,0,115.3-16.3a6.488,6.488,0,0,0-2.534.476,5.687,5.687,0,0,0-1.946,1.33,5.842,5.842,0,0,0-1.246,2.03A7.3,7.3,0,0,0,109.144-9.912ZM146.916-1.4A15.812,15.812,0,0,1,142.884.056,20.476,20.476,0,0,1,138.6.5a12.213,12.213,0,0,1-4.284-.728,9.807,9.807,0,0,1-3.388-2.086A9.457,9.457,0,0,1,128.7-5.6a11.2,11.2,0,0,1-.8-4.312,11.2,11.2,0,0,1,.8-4.312,9.457,9.457,0,0,1,2.226-3.29,9.806,9.806,0,0,1,3.388-2.086,12.213,12.213,0,0,1,4.284-.728,15.855,15.855,0,0,1,4.382.574A8.58,8.58,0,0,1,146.5-17.78l-3.08,3.36a6.137,6.137,0,0,0-2.016-1.4,7.184,7.184,0,0,0-2.8-.476,6.487,6.487,0,0,0-2.534.476,5.687,5.687,0,0,0-1.946,1.33,5.842,5.842,0,0,0-1.246,2.03,7.3,7.3,0,0,0-.434,2.548,7.271,7.271,0,0,0,.434,2.562,5.868,5.868,0,0,0,1.246,2.016A5.687,5.687,0,0,0,136.066-4a6.488,6.488,0,0,0,2.534.476,8.349,8.349,0,0,0,2.464-.322,9.3,9.3,0,0,0,1.652-.658v-3.22H139.16V-11.76h7.756Zm2.772-8.512a11.2,11.2,0,0,1,.8-4.312,9.457,9.457,0,0,1,2.226-3.29A9.807,9.807,0,0,1,156.1-19.6a12.213,12.213,0,0,1,4.284-.728,12.213,12.213,0,0,1,4.284.728,9.807,9.807,0,0,1,3.388,2.086,9.457,9.457,0,0,1,2.226,3.29,11.2,11.2,0,0,1,.8,4.312,11.2,11.2,0,0,1-.8,4.312,9.457,9.457,0,0,1-2.226,3.29,9.807,9.807,0,0,1-3.388,2.086A12.213,12.213,0,0,1,160.384.5,12.213,12.213,0,0,1,156.1-.224a9.807,9.807,0,0,1-3.388-2.086,9.457,9.457,0,0,1-2.226-3.29A11.2,11.2,0,0,1,149.688-9.912Zm4.536,0a7.271,7.271,0,0,0,.434,2.562A5.868,5.868,0,0,0,155.9-5.334,5.687,5.687,0,0,0,157.85-4a6.488,6.488,0,0,0,2.534.476A6.488,6.488,0,0,0,162.918-4a5.687,5.687,0,0,0,1.946-1.33A5.868,5.868,0,0,0,166.11-7.35a7.271,7.271,0,0,0,.434-2.562,7.3,7.3,0,0,0-.434-2.548,5.842,5.842,0,0,0-1.246-2.03,5.687,5.687,0,0,0-1.946-1.33,6.488,6.488,0,0,0-2.534-.476,6.487,6.487,0,0,0-2.534.476,5.687,5.687,0,0,0-1.946,1.33,5.842,5.842,0,0,0-1.246,2.03A7.3,7.3,0,0,0,154.224-9.912Z" transform="matrix(0.995, -0.105, 0.105, 0.995, 484.921, 558.826)" fill="#fff"/> </g> </svg> </div>
How can I make the SVG animation seamless and smooth?
I have animated the SVG, to give a handwriting effect, I want to make the animation more seamless, as the letter "W" appears in the animation, it makes the other part of the letter appear as well, and I can't decrease the stroke-width as the rest of the part of the letter will not appear completely, please guide me along on what can be done. As I cant upload the code here its SVG and exceeding more than 35,000 characters, so please do check the CodePen. HTML Code <defs> <clipPath id="clip-path" transform="translate(0 0)"> <path id="w" d="M47.205,44.721c-.1.062-.191.119-.262.169a1.172,1.172,0,0,0-.192.17,1.237,1.237,0,0,0-.155.208,1.71,1.71,0,0,0-.13.285L42.677,55.6q-.354-.956-.708-1.9-.307-.8-.655-1.694t-.623-1.6L38.8,55.6Q37.7,52.9,36.825,50.73q-.37-.925-.739-1.818c-.247-.6-.467-1.134-.662-1.618s-.357-.883-.485-1.2-.2-.508-.223-.57a1.835,1.835,0,0,0-.293-.47,1.326,1.326,0,0,0-.539-.332H36.7a.519.519,0,0,0-.355.4.832.832,0,0,0,.093.539l2.836,7.18,1.077-3.3q-.215-.57-.493-1.247t-.532-1.279c-.17-.4-.313-.747-.432-1.04s-.187-.464-.208-.516a1.529,1.529,0,0,0-.223-.409,1.143,1.143,0,0,0-.532-.332h2.711a.5.5,0,0,0-.315.4,1.016,1.016,0,0,0,.07.539l.817,2.033.8-2.2a.886.886,0,0,0,.068-.479q-.039-.2-.347-.293h1.633a2.841,2.841,0,0,0-.254.17,1.007,1.007,0,0,0-.169.161,1.148,1.148,0,0,0-.124.185,2.582,2.582,0,0,0-.116.254l-1.155,3.034,1.556,4.313L45.652,45.6a1.01,1.01,0,0,0,.062-.533.513.513,0,0,0-.355-.346h1.849Z" style="fill: none" /> </clipPath> </defs> <g id="w-grp"> <g style="clip-path: url(#clip-path)"> <polyline class="logo-path m-1" id="w-path" points="35.084 43.989 39.663 55.599 38.796 55.599 38.609 55.136 42.916 43.989 38.968 43.989 43.484 55.599 42.677 55.597 42.474 55.101 46.67 43.989" style="fill: none;stroke: #191717;stroke-miterlimit: 10;stroke-width: 3px" /> </g> </g> CodePen: https://codepen.io/ToxifiedM/pen/MWKeERr Linked Question 1: A JQuery Function For SVG, To Execute 2nd Animation As Soon As, 1st Animation Completes? Linked Question 2: To Control SVG CSS Based Animation Using Jquery? Linked Question 3: To Control The Speed Of Multiple SVG Elements Using Jquery?
This is how I would do it: I'm using a polyline element that I am clipping with a V like path. In order to make the W I'm using the clipped polyline twice. I am animating the stroke-dashoffset of the use elements, the second element with a 1s delay svg{width:300px;border:solid} use{ stroke-dasharray: 255; stroke-dashoffset: 255; animation: dash 1s linear forwards; } use:nth-of-type(2){ animation-delay:1s } #keyframes dash { to { stroke-dashoffset: 0; } } <svg viewBox="30 80 250 150"> <defs> <clipPath id="clip"> <path id="V" xmlns="http://www.w3.org/2000/svg" d="M52,90L103,210 110,210 160,90 152,90 110,190 66,90 52,90" stroke="black" fill="none" /> </clipPath> <polyline id="poly" points="58,85 107,203 156,85" stroke="red" fill="none" stroke-width="19" clip-path="url(#clip)" /> </defs> <use xlink:href="#poly" x="0" /> <use xlink:href="#poly" x="50" /> </svg>
Rotating SVG with CSS from bottom of group
I am trying create some kind of gauge animation. I added two simple gauges inside a rectangel . When I try to rotate a needle it doesn't rotate around its bottom part. Instead it rotates around another point even though I state to rotate around bottom center. What should I do to rotate the needle from bottom? Thanks. EDIT: Here is the animation I am trying to achieve <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <style> #Gaugaetip2 { animation: dance 2s infinite alternate; } #keyframes dance { 100% { transform-origin: bottom center; transform: rotate(-25deg); } } </style> </head> <body> <svg width="135px" height="135px" viewBox="0 0 135 135" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>test</title> <defs> <path d="M17.6298701,13.9630295 L17.6298701,4.43831169 L15.6298701,4.43831169 L15.6298701,13.9630295 C14.6733943,14.3565661 14,15.2976952 14,16.3961039 C14,17.8485411 15.177433,19.025974 16.6298701,19.025974 C18.0823073,19.025974 19.2597403,17.8485411 19.2597403,16.3961039 C19.2597403,15.2976952 18.5863459,14.3565661 17.6298701,13.9630295 L17.6298701,13.9630295 Z" id="path-1"></path> <path d="M18.91403,13.9099151 L18.91403,4.38519729 L16.91403,4.38519729 L16.91403,13.9099151 C15.9575542,14.3034517 15.2841598,15.2445808 15.2841598,16.3429895 C15.2841598,17.7954267 16.4615928,18.9728596 17.91403,18.9728596 C19.3664671,18.9728596 20.5439001,17.7954267 20.5439001,16.3429895 C20.5439001,15.2445808 19.8705058,14.3034517 18.91403,13.9099151 L18.91403,13.9099151 Z" id="path-3"></path> </defs> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="test" transform="translate(-30.000000, -30.000000)"> <g transform="translate(30.000000, 30.000000)"> <rect id="background" fill="#4BBCE9" x="0" y="0" width="135" height="135" rx="8"></rect> <g id="Gauge" transform="translate(5.136364, 8.642857)"> <g id="Group-3" transform="translate(0.149351, 0.383117)"> <ellipse id="Oval-3" stroke="#D8D8D8" fill="#FFFFFF" cx="16.6298701" cy="16.3961039" rx="15.7792208" ry="15.7792208"></ellipse> <mask id="mask-2" fill="white"> <use xlink:href="#path-1"></use> </mask> <use id="Gaugaetip2" fill="#D8D8D8" xlink:href="#path-1"></use> </g> </g> <g id="Gauge-Copy-3" transform="translate(95.551948, 9.642857)"> <ellipse id="Oval-3" stroke="#D8D8D8" fill="#FFFFFF" cx="15.7792208" cy="15.7792208" rx="15.7792208" ry="15.7792208"></ellipse> <mask id="mask-4" fill="white"> <use xlink:href="#path-3"></use> </mask> <use id="Gaugetip" fill="#D8D8D8" transform="translate(17.914030, 11.679028) rotate(25.000000) translate(-17.914030, -11.679028) " xlink:href="#path-3"></use> </g> </g> </g> </g> </svg> </body> </html>
Try adding the transform-origin to the element itself. As this is a fixed property that does not change over time, it shouldn't be part of the keyframes. #Gaugaetip2 { animation: dance 2s infinite alternate; transform-origin: center 84%; transform-box: fill-box; } #keyframes dance { 100% { transform: rotate(-25deg); } } I also adjusted the origin position a little to stay centered on the round part. Result: https://jsfiddle.net/dowm6eff/