<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: leimapapa</title>
    <description>The latest articles on DEV Community by leimapapa (@leimapapa).</description>
    <link>https://dev.to/leimapapa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F877675%2Fe78eab5c-0ab5-4586-b905-49579c1964f6.png</url>
      <title>DEV Community: leimapapa</title>
      <link>https://dev.to/leimapapa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/leimapapa"/>
    <language>en</language>
    <item>
      <title>Wait, no. THIS is how to make an SVG fire effect</title>
      <dc:creator>leimapapa</dc:creator>
      <pubDate>Tue, 01 Jul 2025 23:40:15 +0000</pubDate>
      <link>https://dev.to/leimapapa/wait-no-this-is-how-to-make-an-svg-fire-effect-49b2</link>
      <guid>https://dev.to/leimapapa/wait-no-this-is-how-to-make-an-svg-fire-effect-49b2</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9td10hqw9klsrun8nba4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9td10hqw9klsrun8nba4.gif" alt="made fire"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I wrote &lt;a href="https://medium.com/@leimapapa/lets-make-fire-from-an-svg-bca1c47f0f27" rel="noopener noreferrer"&gt;an article explaining how to achieve a fire effect&lt;/a&gt; and it got somewhat… complex.&lt;/p&gt;

&lt;p&gt;Any time that you have to have some advanced knowledge of an SVG path’s d attribute to make an effect, you’re in baaad territory. That is to say, tedious, boring territory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhh61cym55b5s9895knjl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhh61cym55b5s9895knjl.gif" alt="confused"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(shapes + turbulence + displacement) = (headache + despair + violent rage)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;However, fear not! I, your SVG fire Sherpa am here at last with a way to avoid all that.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/leimapapa/lets-make-fire-from-an-svg-5gl1-temp-slug-6568029"&gt;the last article&lt;/a&gt;, I explained that applying a turbulence filter, animating a group containing the shape you want to be on fire up, while you animate the shape itself down creates a pretty solid fire effect.&lt;/p&gt;

&lt;p&gt;This is fine and perfectly easy for shapes like circles where you animate the cy up by 5000 and the y offset of the group down by 5000 using .&lt;/p&gt;

&lt;p&gt;However, it gets super silly once anything more complex like , , or god forbid, s get involved.&lt;/p&gt;

&lt;p&gt;In the case of s, you have to animate the d attribute itself, which requires all of the points to be relative to one another and not absolute (e.g. M0 0 h 100and not M 0 0 H 100) which requires converting the path itself using an external tool. Barf.&lt;/p&gt;

&lt;p&gt;All this trouble stems from the fact that having 2  components offset one another and the shape does not appear to move at all.&lt;/p&gt;

&lt;p&gt;So what we need is to animate the y position of a containing element down, and then use the  on the group containing that element to animate it up.&lt;/p&gt;

&lt;p&gt;So why not just have 2 group components, animate the y of one group up and the group inside use  down?&lt;/p&gt;

&lt;p&gt;Good question. You’re so smart. The fact of the matter is that the  element does not have a y attribute attached to it representing its y position in the svg... All is lost!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpobsikaiht4imzzc35gj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpobsikaiht4imzzc35gj.gif" alt="its over"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;It’s never been more over than it is right now&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Well not so fast Doomer McDoomerton, there certainly has to be another element that has a y attribute that we can put our set-me-on-fire path (or groups of paths) inside of so we don’t have to animate their paths.&lt;/p&gt;

&lt;p&gt;Enter ! Our savior!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbamauc2pfqknozgy95gv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbamauc2pfqknozgy95gv.gif" alt="we back"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;we are so back!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The  element lets you define a piece of SVG content &lt;strong&gt;once&lt;/strong&gt; , and then reuse it multiple times elsewhere in your SVG document using the  element. And guess what attribute the  has…&lt;/p&gt;

&lt;p&gt;Ding ding ding! That’s correct, it has a y attribute. Therefore, any thing we want to include inside of a  can be animated using the following format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;use href="mySymbol"&amp;gt;
  &amp;lt;animate attributeName="y" 
    values="0; 5000" 
    dur="100s" begin="0s" 
    repeatCount="indefinite" additive="sum" /&amp;gt;
&amp;lt;/use&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, with a simple offset in the opposite direction, the fire effect is complete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;g filter="url(#fireTurbulence)"&amp;gt;
  &amp;lt;use href="mySymbol"&amp;gt;
    &amp;lt;animate attributeName="y" 
      values="0; 5000" 
      dur="100s" begin="0s" 
      repeatCount="indefinite" additive="sum" /&amp;gt;
  &amp;lt;/use&amp;gt;
  &amp;lt;animateTransform attributeName="transform" 
    attributeType="XML" type="translate" 
    values="0 0; 0 -5000" 
    dur="100s" begin="0s" 
    repeatCount="indefinite" additive="sum" /&amp;gt;
&amp;lt;/g&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now the symbol itself can include any number of erstwhile impossibly-complex shapes to which we want to add a fire effect. Like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;symbol id="star" viewBox="0 0 100 100"&amp;gt;
  &amp;lt;polygon 
    points="50,0 61,35 98,35 68,57 79,91 50,70 21,91 32,57 2,35 39,35"
    fill="gold" stroke="black" /&amp;gt;
&amp;lt;/symbol&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;giving us finally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;symbol id="star" viewBox="0 0 100 100"&amp;gt;
  &amp;lt;polygon 
    points="50,0 61,35 98,35 68,57 79,91 50,70 21,91 32,57 2,35 39,35"
    fill="gold" stroke="black" /&amp;gt;
&amp;lt;/symbol&amp;gt;
&amp;lt;g filter="url(#fireTurbulence)"&amp;gt;
  &amp;lt;use href="mySymbol"&amp;gt;
    &amp;lt;animate attributeName="y" 
      values="0; 5000" 
      dur="100s" begin="0s" 
      repeatCount="indefinite" additive="sum" /&amp;gt;
  &amp;lt;/use&amp;gt;
  &amp;lt;animateTransform attributeName="transform" 
    attributeType="XML" type="translate" 
    values="0 0; 0 -5000" 
    dur="100s" begin="0s" 
    repeatCount="indefinite" additive="sum" /&amp;gt;
&amp;lt;/g&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which, when we apply our fire turbulence filter (and a cool fire gradient instead of just gold fill), gives us something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl23abhf8903hvh082rg8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl23abhf8903hvh082rg8.gif" alt="star fire"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Star Fire!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;One quick note on the fire filter. When turbulence and displacement are applied, it will shift the shape to which you apply your filter down and to the right by ~25–33% of the displacement scale. There’s complex math involved in how the randomness of the turbulence is generated, but I won’t get into it here.&lt;/p&gt;

&lt;p&gt;For now, here is the turbulence filter used for my fire effect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;filter id="fireTurbulence" x="-100%" y="-100%" width="300%" height="300%"&amp;gt;
  &amp;lt;feTurbulence type="turbulence" seed="69"
    baseFrequency="0.05" numOctaves="2.5" 
    result="turbulence"/&amp;gt;
  &amp;lt;feDisplacementMap 
    in="SourceGraphic" in2="turbulence" 
    scale="30" 
    result="displacement" /&amp;gt;
  &amp;lt;!-- feOffset counteracts the scale of the displacement map --&amp;gt;
  &amp;lt;!-- this will re-center the shape to which it is applied --&amp;gt;
  &amp;lt;feOffset in="displacement" 
    dx="-10" dy="-10" 
    result="offset" /&amp;gt;
&amp;lt;/filter&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Aaaaand here’s the full code for our fiery star. Nestled safe inside of the  to which the fire filter is applied:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg viewBox="0 0 100 100"&amp;gt;
 &amp;lt;defs&amp;gt;
  &amp;lt;filter id="fireTurbulence" x="-100%" y="-100%" width="300%" height="300%"&amp;gt;
   &amp;lt;feTurbulence type="turbulence" seed="69" baseFrequency="0.05" numOctaves="2.5" result="turbulence" /&amp;gt;
   &amp;lt;feDisplacementMap in2="turbulence" in="SourceGraphic" scale="30" result="displacement" /&amp;gt;
   &amp;lt;feOffset in="displacement" dx="-10" dy="-10" result="offset" /&amp;gt;
  &amp;lt;/filter&amp;gt;
  &amp;lt;radialGradient id="fireGrad" cx="50%" cy="80%" fx="50%"&amp;gt;
   &amp;lt;stop offset="0%" stop-color="#aaf" /&amp;gt;
   &amp;lt;stop offset="20%" stop-color="#fff" /&amp;gt;
   &amp;lt;stop offset="60%" stop-color="gold" /&amp;gt;
   &amp;lt;stop offset="100%" stop-color="darkorange" /&amp;gt;
  &amp;lt;/radialGradient&amp;gt;
  &amp;lt;symbol id="star" viewBox="0 0 100 100"&amp;gt;
   &amp;lt;polygon points="50,0 61,35 98,35 68,57 79,91 50,70 21,91 32,57 2,35 39,35" fill="url(#fireGrad)" /&amp;gt;
  &amp;lt;/symbol&amp;gt;
 &amp;lt;/defs&amp;gt;
 &amp;lt;g filter="url(#fireTurbulence)"&amp;gt;
  &amp;lt;use href="#star"&amp;gt;
   &amp;lt;animate attributeName="y" values="0; 5000" dur="100s" begin="0s" repeatCount="indefinite" additive="sum" /&amp;gt;
  &amp;lt;/use&amp;gt;
  &amp;lt;animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 0 -5000" dur="100s" begin="0s" repeatCount="indefinite" additive="sum" /&amp;gt;
 &amp;lt;/g&amp;gt;
&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/leimapapa/embed/ogXRxoa?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This opens up all sorts of possibilities beyond just fire. You could, for example, generate turbulence against lines so that they look like electricity:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/leimapapa/embed/gbpqBXw?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Or you could scale the values way back and apply them in the x direction to create a waving flag effect:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/leimapapa/embed/xbGNVJJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The world is your fiery oyster.&lt;/p&gt;

&lt;p&gt;Now go forth armed with this knowledge and set the world on fire! Metaphorically of course…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03bo7t0kn4d1783gfovj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03bo7t0kn4d1783gfovj.gif" alt="set fires"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Legally: “in Minecraft”&lt;/em&gt;&lt;/p&gt;

</description>
      <category>svganimation</category>
      <category>webdev</category>
      <category>svg</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Rocket SVG Cursor</title>
      <dc:creator>leimapapa</dc:creator>
      <pubDate>Wed, 21 May 2025 21:43:39 +0000</pubDate>
      <link>https://dev.to/leimapapa/rocket-svg-cursor-5a0j</link>
      <guid>https://dev.to/leimapapa/rocket-svg-cursor-5a0j</guid>
      <description>&lt;p&gt;SVG implementation of a cool cursor canvas widget, edited to be a rocket&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/leimapapa/embed/WNWbbrG?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>codepen</category>
      <category>svg</category>
      <category>html</category>
    </item>
    <item>
      <title>Let’s Make Fire from an SVG</title>
      <dc:creator>leimapapa</dc:creator>
      <pubDate>Wed, 21 May 2025 19:43:11 +0000</pubDate>
      <link>https://dev.to/leimapapa/lets-make-fire-from-an-svg-250l</link>
      <guid>https://dev.to/leimapapa/lets-make-fire-from-an-svg-250l</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fevoehe1oxkr7sld5d1ug.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fevoehe1oxkr7sld5d1ug.gif" alt="fire sale"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The “sale” refers to our savings on file size&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let’s make a realistic fire effect from an SVG!&lt;/p&gt;

&lt;p&gt;Impossible you say? How dare you. You and I don’t even know each other and you’re coming at me all hostile like that? Super rude of you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvptadmuvepx5add98zik.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvptadmuvepx5add98zik.gif" alt="sobbing"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;It’s okay, I’m okay.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Anyways, here’s the effect we’re going for:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8z9x00htyjsvhpfgxtzs.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8z9x00htyjsvhpfgxtzs.gif" alt="fire"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fiya!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now I know what you’re thinking, that’s impossibly complex and learning how to make it probably causes brain cancer or something.&lt;/p&gt;

&lt;p&gt;Wrong again bucko.&lt;/p&gt;

&lt;p&gt;This specific fire effect is as simple as applying a turbulence effect to a shape and animating the shape downward while animating the surrounding area up at the same speed.&lt;/p&gt;

&lt;p&gt;In fact, here’s the entire code for the fire above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"&amp;gt;
 &amp;lt;defs&amp;gt;
  &amp;lt;!-- turbulence filter --&amp;gt;
  &amp;lt;filter id="turb" x="-100%" y="-100%" width="300%" height="300%"&amp;gt;
   &amp;lt;feTurbulence type="turbulence" baseFrequency="0.06" numOctaves="2.5" result="turbulence" seed="69" /&amp;gt;
   &amp;lt;feDisplacementMap in2="turbulence" in="SourceGraphic" scale="35" /&amp;gt;
  &amp;lt;/filter&amp;gt;
  &amp;lt;!-- fire gradient --&amp;gt;
  &amp;lt;radialGradient id="grad" cx="50%" cy="100%"&amp;gt;
      &amp;lt;stop offset="0%" stop-color="blue" /&amp;gt;
      &amp;lt;stop offset="20%" stop-color="gold" /&amp;gt;
      &amp;lt;stop offset="60%" stop-color="gold" /&amp;gt;
      &amp;lt;stop offset="100%" stop-color="red" /&amp;gt;
 &amp;lt;/radialGradient&amp;gt;
 &amp;lt;/defs&amp;gt;
 &amp;lt;g&amp;gt;
  &amp;lt;!-- triangle shape with turbulence applied --&amp;gt;
  &amp;lt;path d="M70 200 h60 l-30 -90z" filter="url(#turb)" fill="url(#grad)"&amp;gt;
   &amp;lt;!-- triangle shape moving down --&amp;gt;
   &amp;lt;animate attributeName="d" values="M70 200 h60 l-30 -90z; M70 7200 h60 l-30 -90z" dur="100s" begin="0s" repeatCount="indefinite" /&amp;gt;
  &amp;lt;/path&amp;gt;
  &amp;lt;!-- group container moving up --&amp;gt;
  &amp;lt;animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 0 -7000" dur="100s" begin="0s" repeatCount="indefinite" /&amp;gt;
 &amp;lt;/g&amp;gt;
&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dead simple, right? Now you can probably figure out what’s going on from here, but allow me to explain it piece by piece for the SVG nerds among us.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff5o0jj2ewwsjo1hf5whv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff5o0jj2ewwsjo1hf5whv.gif" alt="dozens of us"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;SVG nerds assemble!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;First off, the turbulence filter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- turbulence filter --&amp;gt;
  &amp;lt;filter id="turb" x="-100%" y="-100%" width="300%" height="300%"&amp;gt;
   &amp;lt;feTurbulence type="turbulence" baseFrequency="0.06" numOctaves="2.5" result="turbulence" seed="69" /&amp;gt;
   &amp;lt;feDisplacementMap in2="turbulence" in="SourceGraphic" scale="35" /&amp;gt;
  &amp;lt;/filter&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where we set the waviness of the fire effect. I massaged the turbulence numbers to make it appear more fire-y, but you could mess with the baseFrequency, numOctaves, and displacement scale to see different styles.&lt;/p&gt;

&lt;p&gt;Next, the color gradient of the fire:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- fire gradient --&amp;gt;
  &amp;lt;radialGradient id="grad" cx="50%" cy="100%"&amp;gt;
      &amp;lt;stop offset="0%" stop-color="blue" /&amp;gt;
      &amp;lt;stop offset="20%" stop-color="gold" /&amp;gt;
      &amp;lt;stop offset="60%" stop-color="gold" /&amp;gt;
      &amp;lt;stop offset="100%" stop-color="red" /&amp;gt;
 &amp;lt;/radialGradient&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I used a radial gradient because it seemed to mimic a fire a little better than a linear gradient.&lt;/p&gt;

&lt;p&gt;I also added a little bit of blue at the bottom, but some might argue it looks better without it. Not me though, I like the blue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1nkusw1f9x72w2vb76bi.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1nkusw1f9x72w2vb76bi.gif" alt="blued"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;#backtheblue&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now the most complex part, the path animation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- group to animate downward --&amp;gt;
&amp;lt;g&amp;gt;
  &amp;lt;!-- triangle shape with turbulence applied and the gradient fill --&amp;gt;
  &amp;lt;path d="M70 200 h60 l-30 -90z" filter="url(#turb)" fill="url(#grad)"&amp;gt;
   &amp;lt;!-- triangle shape moving down by animating its path value --&amp;gt;
   &amp;lt;animate attributeName="d" values="M70 200 h60 l-30 -90z; M70 7200 h60 l-30 -90z" dur="100s" begin="0s" repeatCount="indefinite" /&amp;gt;
  &amp;lt;/path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The path has a default value of &lt;strong&gt;M70 200 h60 l-30 -90z&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Broken down, this path starts at &lt;strong&gt;M70 200&lt;/strong&gt; (x position 70 and y position 200).&lt;/p&gt;

&lt;p&gt;It then goes horizontally relative to its starting position by 60 with &lt;strong&gt;h60&lt;/strong&gt; (lowercase &lt;strong&gt;h&lt;/strong&gt; is relative).&lt;/p&gt;

&lt;p&gt;Lastly, it goes back left by 30 and up by 90 ( &lt;strong&gt;l-30 -90&lt;/strong&gt; ) before closing with a  &lt;strong&gt;z&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr4mig3g04u9xn0a91y0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr4mig3g04u9xn0a91y0.png" alt="triangle"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Here’s the original path (just a simple triangle)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now the animation part. The animation we apply to its &lt;strong&gt;d&lt;/strong&gt; attribute will make use of the relative movements and therefore we only need to animate to a different starting position.&lt;/p&gt;

&lt;p&gt;In my example, I chose 7000 units down. This is because I wanted mine not to visibly repeat itself anytime soon, so I have my repeat value set to repeat at 100 seconds.&lt;/p&gt;

&lt;p&gt;And for the fire to appear to whip in a fire-y way, 7000 seemed right. A smaller number (over the course of the 100 seconds animation duration) would make the fire appear to whip faster.&lt;/p&gt;

&lt;p&gt;We’re basically just animating the starting point from &lt;strong&gt;M70 200&lt;/strong&gt; to &lt;strong&gt;M70 7200&lt;/strong&gt; and leaving everything else the same:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- triangle shape moving down by animating its path value --&amp;gt;
&amp;lt;animate attributeName="d" 
values="
M70 200 h60 l-30 -90z; 
M70 7200 h60 l-30 -90z" 
dur="100s" 
begin="0s" 
repeatCount="indefinite" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, inside the surrounding group ( &lt;strong&gt;&lt;/strong&gt; component) we add a &lt;strong&gt;animateTransform&lt;/strong&gt; to keep the fire inside of the viewBox (so the triangle doesn’t just run away off the screen).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;g&amp;gt;
  &amp;lt;!-- triangle shape moving down --&amp;gt;
  &amp;lt;path ...&amp;gt;&amp;lt;animate .../&amp;gt;&amp;lt;/path&amp;gt;
  &amp;lt;!-- group container moving up --&amp;gt;
  &amp;lt;animateTransform attributeName="transform" 
    attributeType="XML" 
    type="translate" 
    values="0 0; 0 -7000" 
    dur="100s" 
    begin="0s" 
    repeatCount="indefinite" /&amp;gt;
 &amp;lt;/g&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This one is a simple transform in the opposite direction by the same amount (7000) and over the same amount of time (100 seconds).&lt;/p&gt;

&lt;p&gt;Now, I know what you’re thinking yet again. Can’t you just animate the &lt;strong&gt;&lt;/strong&gt; with it’s own &amp;lt; &lt;strong&gt;animateTransform&amp;gt;&lt;/strong&gt; instead of having to deal with all that complicated path nonsense? Something like this?:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;g&amp;gt;
  &amp;lt;!-- triangle shape moving down --&amp;gt;
  &amp;lt;path ...&amp;gt;
    &amp;lt;animateTransform attributeName="transform" 
    attributeType="XML" 
    type="translate" 
    values="0 0; 0 7000" 
    dur="100s" 
    begin="0s" 
    repeatCount="indefinite" /&amp;gt;
  &amp;lt;/path&amp;gt;
  &amp;lt;!-- group container moving up --&amp;gt;
  &amp;lt;animateTransform attributeName="transform" 
    attributeType="XML" 
    type="translate" 
    values="0 0; 0 -7000" 
    dur="100s" 
    begin="0s" 
    repeatCount="indefinite" /&amp;gt;
 &amp;lt;/g&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is an excellent question. Here’s the answer:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhtw7ow43vyax0totvw0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhtw7ow43vyax0totvw0.gif" alt="nope"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;no. already tried it, just no.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you do it that way, the turbulence filter doesn’t change as the two &amp;lt; &lt;strong&gt;animateTransform&amp;gt;&lt;/strong&gt; s cancel each other out and the turbulence of the fire appears fixed and not like an animated fire. Which was kinda the whole goal…&lt;/p&gt;

&lt;p&gt;But here’s the good news, it doesn’t have to be a path triangle where you have to worry about the relative paths and animating between them. You can also use the &lt;strong&gt;y&lt;/strong&gt; attribute of a  component or the &lt;strong&gt;cy&lt;/strong&gt; attribute of a  or :&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- ellipse example --&amp;gt;
&amp;lt;svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"&amp;gt;
 &amp;lt;defs&amp;gt;
  &amp;lt;!-- same as before --&amp;gt;
 &amp;lt;/defs&amp;gt;
 &amp;lt;g&amp;gt;
  &amp;lt;!-- ellipse shape with turbulence applied --&amp;gt;
  &amp;lt;ellipse cx="100" cy="100" rx="33" ry="50" filter="url(#turb)" fill="url(#grad)"&amp;gt;
   &amp;lt;animate attributeName="cy" values="100; 7100" dur="100s" begin="0s" repeatCount="indefinite" /&amp;gt;
  &amp;lt;/ellipse&amp;gt;
  &amp;lt;animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 0 -7000" dur="100s" begin="0s" repeatCount="indefinite" /&amp;gt;
 &amp;lt;/g&amp;gt;
&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Which gives us this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fle52zcacqnn4w6trjo5a.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fle52zcacqnn4w6trjo5a.gif" alt="fiya"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Huzzah for simplicity!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjvwqqrar8iigs6gke87.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjvwqqrar8iigs6gke87.gif" alt="huzzah"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;and again I say huzzah!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is the SVG fire effect in a CodePen to play around with:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/leimapapa/embed/oNRbNJP?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;And that’s pretty much it. A computationally cheap and small file size SVG fire… so… um… yeah… See ya.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56lav91xdmkf49fddus8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56lav91xdmkf49fddus8.gif" alt="uh bye"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>svg</category>
      <category>svganimation</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Let’s Make a Bouncing DVD Loading Screen with only SVG</title>
      <dc:creator>leimapapa</dc:creator>
      <pubDate>Thu, 22 Sep 2022 22:57:13 +0000</pubDate>
      <link>https://dev.to/leimapapa/lets-make-a-bouncing-dvd-loading-screen-with-only-svg-571e</link>
      <guid>https://dev.to/leimapapa/lets-make-a-bouncing-dvd-loading-screen-with-only-svg-571e</guid>
      <description>&lt;p&gt;Let’s make stuff with SVG shaaaall we. But no! you say. SVG is weird and complicated. Well, true, but it’s basically a superpower once we start to understand all the things it can do.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff03teoj4s0raqa70o1xa.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff03teoj4s0raqa70o1xa.gif" alt="DVD image" width="500" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;bouncy trouncy pouncy flouncy, fun fun fun fun fun!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;First off, let’s go grab an SVG version of a DVD logo to animate through. Wikipedia has our back with this bad boy: &lt;a href="https://upload.wikimedia.org/wikipedia/commons/9/9b/DVD_logo.svg" rel="noopener noreferrer"&gt;https://commons.wikimedia.org/wiki/File:DVD_logo.svg&lt;/a&gt;, but there’s some weirdness…&lt;/p&gt;

&lt;p&gt;When we inspect (&lt;em&gt;right-click &amp;gt; Inspect&lt;/em&gt;) on the logo itself, we see it’s comprised of 2  elements with a bunch of scary-looking numbers and whatnot. So let’s copy the big ol’ values of the d property for both of these path elements into &lt;a href="https://yqnn.github.io/svg-path-editor/" rel="noopener noreferrer"&gt;this handy SVG path editor tool&lt;/a&gt; and see what it looks like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftu59rbh4sbvyubrgfma9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftu59rbh4sbvyubrgfma9.png" alt="Path Editor" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can mess around with how it looks if we want. I went ahead and scaled it down and rounded it to 1 decimal to make it look a little better inside my &lt;em&gt;1000 x 1000&lt;/em&gt; viewBox: viewBox="0 0 1000 1000".&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I like simple base 10 viewBoxes. Don’t judge me!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here’s the combined path d value I ended up using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;M 91.2 12.7 C 91.2 12.7 80.2 26.3 80.8 27.1 C 81.6 26.3 76.8 12.5 76.8 12.5 S 75.8 9.7 72.8 0.1 H 13.8 L 11.8 8.9 H 30.8 C 40.8 8.9 46.8 13.1 45.2 20.3 C 43.4 28.3 34.8 31.7 25.4 31.7 H 22 L 26.4 12.3 H 11 L 4.4 40.5 H 26.4 C 42.8 40.5 58.6 31.7 61.4 20.3 C 61.8 18.3 61.8 12.9 60.6 9.9 C 60.4 9.5 60.2 8.9 60.6 8.9 C 60.8 8.9 61 9.1 61 9.1 L 75.2 49.9 L 110.8 8.9 H 129.4 C 139.4 8.9 145.4 13.1 143.8 20.3 C 142 28.3 133.2 31.7 124 31.7 H 120.4 L 124.8 12.5 H 109.4 L 102.8 40.7 H 124.8 C 141.2 40.7 157 31.9 159.6 20.5 C 162.2 9.1 150.8 0.3 134 0.3 H 101.2 C 92.8 10.7 91.2 12.7 91.2 12.7 L 91.2 12.7 Z M 75.6 50.3 C 33.8 50.3 0 55.3 0 61.3 C 0 67.3 33.8 72.3 75.6 72.3 C 117.4 72.3 151.2 67.5 151.2 61.3 C 151.2 55.3 117.4 50.3 75.6 50.3 Z M 72.8 65.1 C 63.2 65.1 55.6 63.5 55.6 61.5 C 55.6 59.5 63.2 57.9 72.8 57.9 C 82.4 57.9 90 59.5 90 61.5 C 90 63.5 82.4 65.1 72.8 65.1 Z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to make use of an SVG trick where we can animate the x and y position of an inner SVG inside of an outer one based on percentages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg class="outerSVG" xmlns="[http://www.w3.org/2000/svg](http://www.w3.org/2000/svg)" viewBox="0 0 1000 1000"&amp;gt;
 &amp;lt;rect id="tvBackground" height="100%" width="100%" fill="#222" rx="10" /&amp;gt;
 &amp;lt;svg id="innerSVG" height="100%" width="100%" fill="#0ff"&amp;gt;
  &amp;lt;path id="dvdLogo" fill="inherit" d="MY-SCALED-DOWN-PATH" /&amp;gt;
  &amp;lt;!-- animation elements--&amp;gt;
  .........
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will animate the inner SVG relative to the outer one. Then we stagger the timing of the x and y animations so the inner SVG hits one edge first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;animate attributeName="x" dur="9" values="0%;84%;0%" repeatCount="indefinite" /&amp;gt;
&amp;lt;animate attributeName="y" dur="10" values="0%;92%;0%" repeatCount="indefinite" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I dialed in the above edge values so that there’s no overflow. So for the y value, instead of animating the DVD logo from &lt;em&gt;0%&lt;/em&gt; to &lt;em&gt;100%&lt;/em&gt; and then back to &lt;em&gt;0%&lt;/em&gt;, we animate from &lt;em&gt;0%&lt;/em&gt; &lt;strong&gt;&amp;gt;&lt;/strong&gt; &lt;em&gt;92%&lt;/em&gt; &lt;strong&gt;&amp;gt;&lt;/strong&gt; &lt;em&gt;0%&lt;/em&gt; so that the logo doesn’t briefly disappear off the bottom of the SVG when it reaches the bottom edge.&lt;/p&gt;

&lt;h4&gt;
  
  
  Change color on bounce
&lt;/h4&gt;

&lt;p&gt;On to the color changing. We could always use JavaScript, but let’s not do that! We’re gonna keep everything nice and compact inside of 1 SVG file.&lt;/p&gt;

&lt;p&gt;To achieve this, we’re gonna need to get a little (more) hackey. Since the bouncing happens whenever we hit the edge of the X or Y axis, we can time a color change animation to the repeatEvent of the x and y animations.&lt;/p&gt;

&lt;p&gt;But this will only change the color 2 times; when we hit the top and the left. So we need to add 2 empty animation events that are timed to the middle of the initial x and y animations. These will trigger 2 additional color changes linked to their repeatEvents so that the color changes when we hit each wall.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- empty animations for triggering color changes --&amp;gt;
&amp;lt;animate id="xx" begin="-4.5s" repeatCount="indefinite" dur="9s" /&amp;gt;
&amp;lt;animate id="yy" begin="-5s" repeatCount="indefinite" dur="10s" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All of the animations together will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;animate id="xAnim" attributeName="x" dur="9" values="84%;0%;84%" repeatCount="indefinite" /&amp;gt;
  &amp;lt;animate id="yAnim" attributeName="y" dur="10" values="0%;92%;0%" repeatCount="indefinite" /&amp;gt;
  &amp;lt;animate attributeName="fill" values="#ff0" begin="xAnim.repeatEvent" repeatCount="indefinite" dur="0s" /&amp;gt;
  &amp;lt;animate attributeName="fill" values="#0ff" begin="yAnim.repeatEvent" repeatCount="indefinite" dur="0s" /&amp;gt;
  &amp;lt;animate attributeName="fill" values="#00f" begin="xx.repeatEvent" repeatCount="indefinite" dur="0s" /&amp;gt;
  &amp;lt;animate attributeName="fill" values="#0f0" begin="yy.repeatEvent" repeatCount="indefinite" dur="0s" /&amp;gt;
  &amp;lt;!-- empty animations for triggering color changes --&amp;gt;
  &amp;lt;animate id="xx" begin="-4.5s" repeatCount="indefinite" dur="9s" /&amp;gt;
  &amp;lt;animate id="yy" begin="-5s" repeatCount="indefinite" dur="10s" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So our final SVG will look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg class="svg" xmlns="[http://www.w3.org/2000/svg](http://www.w3.org/2000/svg)" viewBox="0 0 1000 1000"&amp;gt;
 &amp;lt;rect height="100%" width="100%" fill="#222" rx="10" /&amp;gt;
 &amp;lt;svg id="dvd" height="100%" width="100%" fill="#0ff"&amp;gt;
  &amp;lt;path fill="inherit" d="M 91.2 12.7 C 91.2 12.7 80.2 26.3 80.8 27.1 C 81.6 26.3 76.8 12.5 76.8 12.5 S 75.8 9.7 72.8 0.1 H 13.8 L 11.8 8.9 H 30.8 C 40.8 8.9 46.8 13.1 45.2 20.3 C 43.4 28.3 34.8 31.7 25.4 31.7 H 22 L 26.4 12.3 H 11 L 4.4 40.5 H 26.4 C 42.8 40.5 58.6 31.7 61.4 20.3 C 61.8 18.3 61.8 12.9 60.6 9.9 C 60.4 9.5 60.2 8.9 60.6 8.9 C 60.8 8.9 61 9.1 61 9.1 L 75.2 49.9 L 110.8 8.9 H 129.4 C 139.4 8.9 145.4 13.1 143.8 20.3 C 142 28.3 133.2 31.7 124 31.7 H 120.4 L 124.8 12.5 H 109.4 L 102.8 40.7 H 124.8 C 141.2 40.7 157 31.9 159.6 20.5 C 162.2 9.1 150.8 0.3 134 0.3 H 101.2 C 92.8 10.7 91.2 12.7 91.2 12.7 L 91.2 12.7 Z M 75.6 50.3 C 33.8 50.3 0 55.3 0 61.3 C 0 67.3 33.8 72.3 75.6 72.3 C 117.4 72.3 151.2 67.5 151.2 61.3 C 151.2 55.3 117.4 50.3 75.6 50.3 Z M 72.8 65.1 C 63.2 65.1 55.6 63.5 55.6 61.5 C 55.6 59.5 63.2 57.9 72.8 57.9 C 82.4 57.9 90 59.5 90 61.5 C 90 63.5 82.4 65.1 72.8 65.1 Z" /&amp;gt;
  &amp;lt;animate id="xAnim" attributeName="x" dur="9" values="0%;84%;0%" repeatCount="indefinite" /&amp;gt;
  &amp;lt;animate id="yAnim" attributeName="y" dur="10" values="0%;92%;0%" repeatCount="indefinite" /&amp;gt;
  &amp;lt;animate attributeName="fill" values="#ff0" begin="xAnim.repeatEvent" repeatCount="indefinite" dur="0s" /&amp;gt;
  &amp;lt;animate attributeName="fill" values="#0ff" begin="yAnim.repeatEvent" repeatCount="indefinite" dur="0s" /&amp;gt;
  &amp;lt;animate attributeName="fill" values="#00f" begin="xx.repeatEvent" repeatCount="indefinite" dur="0s" /&amp;gt;
  &amp;lt;animate attributeName="fill" values="#0f0" begin="yy.repeatEvent" repeatCount="indefinite" dur="0s" /&amp;gt;
&amp;lt;!-- empty animations for triggering color changes --&amp;gt;
  &amp;lt;animate id="xx" begin="-4.5s" repeatCount="indefinite" dur="9s" /&amp;gt;
  &amp;lt;animate id="yy" begin="-5s" repeatCount="indefinite" dur="10s" /&amp;gt;
 &amp;lt;/svg&amp;gt;
&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s a working example on CodePen.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/leimapapa/embed/rNpPGZo?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;So that’s it. A bouncing DVD menu with just SVG and no external libraries or nothin’. Pretty neat, huh?&lt;/p&gt;

</description>
      <category>svganimation</category>
      <category>svg</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Turin Horse - Hadi</title>
      <dc:creator>leimapapa</dc:creator>
      <pubDate>Wed, 15 Jun 2022 16:57:54 +0000</pubDate>
      <link>https://dev.to/leimapapa/the-turin-horse-hadi-h60</link>
      <guid>https://dev.to/leimapapa/the-turin-horse-hadi-h60</guid>
      <description>&lt;p&gt;SVG implementation of Hadi's super cool Dribbble shot: &lt;a href="https://dribbble.com/shots/18288950-The-Turin-Horse" rel="noopener noreferrer"&gt;https://dribbble.com/shots/18288950-The-Turin-Horse&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/leimapapa/embed/GRQGzOZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>webdev</category>
      <category>svg</category>
      <category>html</category>
    </item>
  </channel>
</rss>
