<?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: Pratik Singh</title>
    <description>The latest articles on DEV Community by Pratik Singh (@pratik_singh_tomar).</description>
    <link>https://dev.to/pratik_singh_tomar</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2611357%2F468fcdf1-60a2-47a5-8035-21e9badbeea5.png</url>
      <title>DEV Community: Pratik Singh</title>
      <link>https://dev.to/pratik_singh_tomar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pratik_singh_tomar"/>
    <language>en</language>
    <item>
      <title>I extracted the SVG animation engine from my project and open-sourced it</title>
      <dc:creator>Pratik Singh</dc:creator>
      <pubDate>Sat, 19 Sep 2026 17:59:35 +0000</pubDate>
      <link>https://dev.to/pratik_singh_tomar/i-extracted-the-svg-animation-engine-from-my-project-and-open-sourced-it-1hkm</link>
      <guid>https://dev.to/pratik_singh_tomar/i-extracted-the-svg-animation-engine-from-my-project-and-open-sourced-it-1hkm</guid>
      <description>&lt;p&gt;I had a small problem that kept getting more annoying.&lt;/p&gt;

&lt;p&gt;I wanted SVG diagrams to draw themselves.&lt;/p&gt;

&lt;p&gt;Not just fade in. Not just appear. I wanted the strokes to progressively draw, followed by the fills and labels.&lt;/p&gt;

&lt;p&gt;I initially used &lt;strong&gt;Vivus&lt;/strong&gt; for the stroke animation. It does that part well.&lt;/p&gt;

&lt;p&gt;But the SVGs I was working with weren't particularly clean. They contained strokes, fills, text, and diagram elements. I also wanted to control the animation from a timeline and eventually export the animation as a video.&lt;/p&gt;

&lt;p&gt;At some point, I realized the code had become useful enough to pull out of the &lt;a href="https://usepenwell.com/" rel="noopener noreferrer"&gt;original project&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So I turned it into &lt;code&gt;@penwell/draw-on&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;The basic API is intentionally small:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;drawing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createDrawing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;svg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nx"&gt;drawing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But you can also control the animation yourself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;drawing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProgress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;drawing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProgress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;drawing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProgress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.75&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That makes it possible to connect the animation to things like scroll position, a custom timeline, or another animation system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Strokes, fills and labels
&lt;/h2&gt;

&lt;p&gt;One thing I wanted that wasn't part of my original Vivus setup was a better reveal sequence for normal diagrams.&lt;/p&gt;

&lt;p&gt;The idea is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;draw the strokes
       ↓
reveal fills
       ↓
reveal labels
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That makes diagrams feel a little less like they're simply being rendered onto the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  React
&lt;/h2&gt;

&lt;p&gt;There is a React API as well, while the core package stays framework-agnostic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;containerRef&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;play&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setProgress&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSketchDraw&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;svgMarkup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Recording
&lt;/h2&gt;

&lt;p&gt;Another reason I extracted it was recording.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;draw-on&lt;/code&gt; can render the animation to WebM in the browser, so there doesn't need to be a video-generation server sitting behind it.&lt;/p&gt;

&lt;p&gt;That's useful for applications that want to turn generated diagrams into short clips.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo gifs
&lt;/h2&gt;




&lt;h3&gt;
  
  
  Annotate Documents
&lt;/h3&gt;

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

&lt;h3&gt;
  
  
  Draw Diagrams
&lt;/h3&gt;

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

&lt;h3&gt;
  
  
  Notebook Animation
&lt;/h3&gt;

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

&lt;h2&gt;
  
  
  Why open source it?
&lt;/h2&gt;

&lt;p&gt;Honestly, mostly because I think the package is more useful if people can try it against SVGs I haven't seen.&lt;/p&gt;

&lt;p&gt;It's currently 0.1.4, and I'm sure there are SVG edge cases waiting to be discovered.&lt;/p&gt;

&lt;p&gt;If you use Mermaid, Figma exports, Excalidraw or other SVG-heavy workflows, I'd be particularly interested in hearing what happens when you throw those files at it.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/penwell-app/draw-on" rel="noopener noreferrer"&gt;penwell/draw-on&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;npm: &lt;a href="https://www.npmjs.com/package/@penwell/draw-on" rel="noopener noreferrer"&gt;@penwell/draw-on on npm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's MIT licensed, and contributions are welcome.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>webdev</category>
      <category>react</category>
    </item>
  </channel>
</rss>
