<?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: Andy Fitzsimon</title>
    <description>The latest articles on DEV Community by Andy Fitzsimon (@andyfitz).</description>
    <link>https://dev.to/andyfitz</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%2F603795%2F6de0e14f-7cdc-4d40-8071-7765d0c1d64e.jpeg</url>
      <title>DEV Community: Andy Fitzsimon</title>
      <link>https://dev.to/andyfitz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andyfitz"/>
    <language>en</language>
    <item>
      <title>Get individual SVG's back from IconFonts</title>
      <dc:creator>Andy Fitzsimon</dc:creator>
      <pubDate>Tue, 25 Jan 2022 09:58:09 +0000</pubDate>
      <link>https://dev.to/andyfitz/get-individual-svgs-back-from-iconfonts-2j8b</link>
      <guid>https://dev.to/andyfitz/get-individual-svgs-back-from-iconfonts-2j8b</guid>
      <description>&lt;p&gt;Originally posted &lt;a href="https://andyfitzsimon.com/posts/decompile-iconfonts/"&gt;on my blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial I'm going to show you how to decompile a big bloated icon font into a series of small, neat, and portable SVG files.  It's dead easy.&lt;/p&gt;

&lt;p&gt;First install &lt;a href="https://fontforge.org/"&gt;Fontforge&lt;/a&gt; on your system&lt;/p&gt;

&lt;p&gt;Fedora Linux&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo dnf install fontforge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;MacOS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install fontforge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just change the package manager for your distribution: &lt;br&gt;
eg Debian/Ubuntu with &lt;code&gt;sudo apt install fontforge&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Now for the magic one liner, just copy and paste this in your terminal and replace &lt;code&gt;youriconfont.woff&lt;/code&gt; with the path to your icon font file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
fontforge -lang=ff -c \\
'Open($1); SelectWorthOutputting(); \\
foreach Export("svg"); endloop;' \\
youriconfont.woff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll now have a standalone SVG file for every glyph in your icon font. If you don't care about naming feel free to head to the bonus round&lt;/p&gt;

&lt;h2&gt;
  
  
  But those filenames, they suck right?
&lt;/h2&gt;

&lt;p&gt;Because the font file knows nothing about what each shape is called, the filenames take the unicode value for each character represented like so you'd think you're stuck with filenames like :  &lt;strong&gt;&lt;code&gt;uniE9AF_youriconfont.svg&lt;/code&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Good news, your existing CSS should have something like this (but probably bigger):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.icon-pacman:before {
  content: "\e916";
} 
.icon-leaf:before {
  content: "\e9a4";
}
.icon-airplane:before {
  content: "\e9af";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Yarr, thar be useful names' &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What I do is a bulk find and delete on the common CSS markup so that we're left with 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;icon-pacman,e916 
icon-leaf,e9a4 
icon-airplane,e9af 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As my SED and AWK skills are terrible, I just opened that output as a CSV in a spreadsheet, converted the unicode column to uppercase (if you need to), flipped the columns order, and was left with new CSV output 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;E916,icon-pacman 
E9A4,icon-leaf 
E9AF,icon-airplane 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I dutifully do another 3 find and replace commands:&lt;/p&gt;

&lt;p&gt;replace first line with &lt;code&gt;mv uni&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;replace all commas with &lt;code&gt;_youriconfont.svg&lt;/code&gt; (trailing space)&lt;/p&gt;

&lt;p&gt;replace linebreak with &lt;code&gt;.svg&lt;/code&gt; followed by a line break&lt;/p&gt;

&lt;p&gt;The output now looks 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;mv uniE916_youriconfont.svg pacman.svg 
mv uniE9A4F_youriconfont.svg leaf.svg
mv uniE9AF_youriconfont.svg airplane.svg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I run that and rejoice&lt;/p&gt;

&lt;p&gt;This finally replaces all filenames with the sane names given to them by the CSS.&lt;/p&gt;

&lt;p&gt;I'm sure I can script this reconciliation part but I do like doing it manually as all CSS is crafted slightly differently so it's good to be eyes-on in case there is some rogue CSS to clean up.&lt;/p&gt;

&lt;p&gt;You probably only need to do this once. &lt;br&gt;
If you're doing this every day well... then you might be a competitor of my employer, so shoo shoo 👀&lt;/p&gt;
&lt;h1&gt;
  
  
  Bonus round
&lt;/h1&gt;
&lt;h3&gt;
  
  
  install SVGO on your system
&lt;/h3&gt;

&lt;p&gt;(I prefer to use NPM as it works on linux and mac hosts alike)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g svgo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can simply enter the directory and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;svgo *.svg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;Your files will have &lt;code&gt;fill="currentcolor"&lt;/code&gt; applied to them so when you inline the SVG inside markup they will adhere to your CSS &lt;code&gt;color:&lt;/code&gt; value just like the good-ol days.&lt;/p&gt;

&lt;h1&gt;
  
  
  A little history
&lt;/h1&gt;

&lt;p&gt;I'll cover why you would you ever need or want to do this. Icon Fonts were once an answer to easy web design. &lt;br&gt;
They exploded on the scene once &lt;a href="https://caniuse.com/fontface"&gt;&lt;code&gt;@fontface&lt;/code&gt;&lt;/a&gt; was supported by major browsers.&lt;br&gt;&lt;br&gt;
iconfonts gave us all the icons you could need within a single HTTP-request - which was great if you had a lightning fast CDN and agressive caching.  You used them usually with CSS pseudo elements and custom character ranges. That's where things get hairy for our a11y friends.&lt;/p&gt;

&lt;p&gt;Remember image sprites? Iconfonts as a technique came after image sprites for single-payload single-color icon sets. Before frameworks like react or powerful site generators it made sense to align your icons and marks with your typographic layout - browsers werent always so nice so this kept things on 'some' guardrails. &lt;br&gt;
Plus services like &lt;a href="https://icomoon.io"&gt;IcoMoon&lt;/a&gt; emerged which made creating custom icon sets easy. &lt;/p&gt;

&lt;p&gt;But of course like I mentioned the accessibility was terrible. &lt;br&gt;
Worse, some text layout engines mutilated iconsfonts.  Think of the carnage the CSS &lt;code&gt;text-rendering: optimizeSpeed;&lt;/code&gt;   would do to your illustrations.&lt;/p&gt;

&lt;h3&gt;
  
  
  We now live in the future
&lt;/h3&gt;

&lt;p&gt;With the advent of modern frameworks and the popularity of best practices like &lt;a href="https://css-tricks.com/accessible-svg-icons/"&gt;ARIA atrributes&lt;/a&gt;. Icon fonts just arent the most suitable technique anymore; not by a long shot.&lt;/p&gt;

&lt;p&gt;But much of the internet is still littered with websites and apps that depend on iconfonts.  And for those poor buggers, it's not without effort to climb into modern times. &lt;/p&gt;

&lt;p&gt;We see this often at &lt;a href="http://outfit.io"&gt;outfit.io&lt;/a&gt; whenever we have a new client with only a website to ingest their existing brand assets from.&lt;/p&gt;

&lt;p&gt;Once we have the clean illustrations (that were often lost) back in a malleable and minimal format, our web developer counterparts can shed hundreds of kilobytes of frontend bottleneck from their sites and apps.&lt;/p&gt;

&lt;p&gt;I hope this helps you&lt;/p&gt;

</description>
      <category>iconfonts</category>
      <category>svg</category>
      <category>conversion</category>
    </item>
    <item>
      <title>Generative art with vanilla JS</title>
      <dc:creator>Andy Fitzsimon</dc:creator>
      <pubDate>Mon, 19 Apr 2021 10:25:30 +0000</pubDate>
      <link>https://dev.to/andyfitz/generative-art-with-vanilla-js-bn5</link>
      <guid>https://dev.to/andyfitz/generative-art-with-vanilla-js-bn5</guid>
      <description>&lt;p&gt;Random computational artwork doesn't have to be hard or heavy&lt;/p&gt;

&lt;p&gt;This article was &lt;a href="https://andyfitzsimon.com/posts/generative-design/"&gt;written with interactive images&lt;/a&gt; on my blog.&lt;br&gt;
It might still hold up without the visuals&lt;/p&gt;



&lt;p&gt;Why design a single piece when you can design a visual system with countless unique permutations?&lt;/p&gt;

&lt;p&gt;In this tutorial I'm going to show you how to make dynamic artwork using very simple vanilla javascript and SVG.&lt;/p&gt;

&lt;p&gt;For generative art there are some great frameworks like &lt;a href="https://p5js.org/"&gt;P5.js&lt;/a&gt;,&lt;a href="https://threejs.org/"&gt;Three.js&lt;/a&gt;, all the way up to the mind bending &lt;a href="https://en.wikipedia.org/wiki/Generative_adversarial_network"&gt;Generative Adversarial Networks&lt;/a&gt; like &lt;a href="https://github.com/NVlabs/stylegan"&gt;styleGAN&lt;/a&gt; and so many more.  This space is exploding with digital artists and art directors chasing never seen before aesthetics that blur the lines between human and machine made creations.&lt;/p&gt;

&lt;p&gt;This isn't new either. For decades many brands with expansive portfolios have gone down the dynamic brand route with their visual architecture. We're lucky to have a few of them as customers at Outfit.io . Traditionally however, permutations were created by central tooling. Often created on the desktop of an art director in a brand team. A render produced once per-need - manually looked over, then distributed as static assets. Nowadays, we can keep the systems alive by leveraging our web native technology and respond to new input &lt;/p&gt;

&lt;p&gt;One of the many benefits in using web formats for design, is that it's very easy to produce artwork that is unique every time. An awesome perk for end users of your visual system.&lt;br&gt;
Plus, unlike choosing a specific tool, you have all the aesthetic potential of the web. &lt;/p&gt;

&lt;p&gt;This can make for a far more engaging and dynamic aesthetic on large builds like events or media.&lt;/p&gt;
&lt;h1&gt;
  
  
  Setting the stage
&lt;/h1&gt;

&lt;p&gt;First, we're going to create something without any javascript at all. &lt;br&gt;
This helps us to creatively set the stage by mocking up at least some of the look and feel you'd like to create.  &lt;/p&gt;

&lt;p&gt;The benefits of this approach means you discover your answers to the most beautiful of questions:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What must &lt;strong&gt;stay the same&lt;/strong&gt; so that&lt;br&gt;everything else can change?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The answer is what frees us up to explore new horizons:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Observe what is constant,&lt;br&gt;discover what can &lt;strong&gt;constantly change&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If we get a sense of what we like, we'll also get a sense of what variables we can bend or break.&lt;/p&gt;

&lt;p&gt;In this case we're going to use &lt;code&gt;SVG&lt;/code&gt;,  but you could just as easily use plain ol HTML and &lt;code&gt;div&lt;/code&gt;'s.&lt;br&gt;
I'm not going to use &lt;code&gt;canvas&lt;/code&gt; or even Filters because at the end I want a nice vector PDF poster and not a heavy rasterized asset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt;
  &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"stage"&lt;/span&gt; 
  &lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;"0 0 100 100"&lt;/span&gt; 
  &lt;span class="na"&gt;preserveAspectRatio=&lt;/span&gt;&lt;span class="s"&gt;"xMidYMid slice"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- cool stuff will go here --&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;preserveAspectRatio="xMidYMid slice"&lt;/code&gt; will center-crop our artwork if we display it at non square. Think of it as &lt;code&gt;background-size: cover; background-position: 50% 50%;&lt;/code&gt; but for SVG contents within a &lt;code&gt;viewBox&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We should probably add some CSS to make sure we're full page too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;overflow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;
&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;svg&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;100vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, lets think about what we could create.&lt;/p&gt;

&lt;p&gt;A few random-ishly placed circles might do the trick.&lt;/p&gt;



&lt;p&gt;Not really that random... I just placed the X and Y axis in increments of 20 and the radius in sizes between 2-8.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"80"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"4"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"80"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"40"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"4"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"40"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"40"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"40"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"80"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"60"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"60"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"6"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"60"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"6"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"60"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"80"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What must stay the same ?
&lt;/h2&gt;

&lt;p&gt;We're going to apply some CSS and attributes to lock in the look we want.  In this case, pink circles with double thick lines and no fill.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;stroke&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;DeepPink&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   
  &lt;span class="py"&gt;stroke-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;p&gt;Okay that was fun, but we need more of these, and I'd go mad placing circles manually. Time to let the computers take over.&lt;/p&gt;

&lt;h1&gt;
  
  
  Enter Vanilla Javascript
&lt;/h1&gt;

&lt;p&gt;For this demo, we be messing with the three attributes of each SVG &lt;code&gt;circle&lt;/code&gt; element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the circle X position&lt;/li&gt;
&lt;li&gt;the circle Y position&lt;/li&gt;
&lt;li&gt;the radius of the circle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also want the option of changing how many circles we play with. &lt;/p&gt;

&lt;p&gt;So to accommodate this, we're going to say bye-bye to the manually crafted circles and hello to Javascript generated ones.&lt;/p&gt;

&lt;p&gt;I'm going to leave them in the DOM just incase someone is using &lt;code&gt;noscript&lt;/code&gt;. But there's no need to do this if we were generating this server-side. &lt;br&gt;
I also want a &lt;code&gt;removeAll&lt;/code&gt; function for easily testing new variations.&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="c1"&gt;// clearing the stage&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;removeAll&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stage&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;
&lt;span class="nx"&gt;removeAll&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we're going to create entirely new circles on the stage with a function called &lt;code&gt;drawCircles&lt;/code&gt;&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="c1"&gt;// calling my state svg&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;svg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stage&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;drawCircles&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// how many circles to draw &lt;/span&gt;
  &lt;span class="c1"&gt;// I started with 8 but now I think 15 is the magic number&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// because circle isnt a html element I need to specify the SVG namespace &lt;/span&gt;
    &lt;span class="nx"&gt;circle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElementNS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://www.w3.org/2000/svg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// maximum 14, minimum 2 and in increments of 2 &lt;/span&gt;
    &lt;span class="nx"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;r&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// minimum 20 maximum 80, incremements of 20 &lt;/span&gt;
    &lt;span class="c1"&gt;// (so either 20 , 40, 60, 80 )&lt;/span&gt;
    &lt;span class="nx"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cx&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// add these elements to my stage&lt;/span&gt;
    &lt;span class="nx"&gt;svg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;drawCircles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mess with the values, it's super fun to see your design going off-plan.  Watching your rules bend and break can give you new ideas. &lt;/p&gt;

&lt;h2&gt;
  
  
  Testing and regenerating
&lt;/h2&gt;

&lt;p&gt;We're going to make testing easy with a timer that changes permutation every 4 seconds.&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;var&lt;/span&gt; &lt;span class="nx"&gt;reGenTimer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;removeAll&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;drawCircles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Actually, I'm super impatient so we're also going to add a click event listener so that I can just click for a new generation.&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="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;removeAll&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;drawCircles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS for some more flair
&lt;/h2&gt;

&lt;p&gt;What's awesome about generating random elements is that you already have them in a random sequence.  So you can add very sequential CSS rules using the &lt;code&gt;:nth&lt;/code&gt; selectors and still get away with looking random - no need to put this stuff in your JS.&lt;/p&gt;

&lt;p&gt;Below, I just make every 2nd, 3rd, 4th and 5th circle a different stroke color.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;circle&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;2&lt;/span&gt;&lt;span class="nt"&gt;n&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="py"&gt;stroke&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#6ac&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;circle&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;3&lt;/span&gt;&lt;span class="nt"&gt;n&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="py"&gt;stroke&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#678&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;circle&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;4&lt;/span&gt;&lt;span class="nt"&gt;n&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="py"&gt;stroke&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#345&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;circle&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;5&lt;/span&gt;&lt;span class="nt"&gt;n&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="py"&gt;stroke&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#9ab&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click below to refresh faster&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/andyfitz/pen/KKaxgvw" rel="noreferer"&gt;Play with it on Codepen&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And there you have it,  we've made generative artwork. &lt;br&gt;
Random but within constraints. Every iteration looks different but also like they belong together. The rules you set – and how wild you go, is entirely up to your vision. &lt;/p&gt;

&lt;p&gt;The whole dance of this technique is to ensure every permutation is a &lt;em&gt;hit&lt;/em&gt;  and looks like something you'd be happy with. That's easier said than done when you can't push pixels, but trust me it's super rewarding knowing you have created a living system rather than a static piece.&lt;/p&gt;

&lt;h2&gt;
  
  
  What about that poster?
&lt;/h2&gt;

&lt;p&gt;Remember I said we were going to make this a nice vector PDF poster?&lt;br&gt;&lt;br&gt;
Thanks to Make.cm we can, and &lt;a href="https://api.make.cm/make/t/ad146027-af14-4644-92e8-b13f1209bfda/k/17915c24-7159-4b2a-9552-a50f296fa3d6.c0e9241f95e4c5bbbf17b447538274b7/sync?size=A4&amp;amp;format=pdf&amp;amp;data%5Bempty%5D=nodata"&gt;every single download&lt;/a&gt; will be generated uniquely.&lt;/p&gt;

&lt;p&gt;Checkout the GET request below for an A3 version&lt;br&gt;
&lt;a href="https://api.make.cm/make/t/ad146027-af14-4644-92e8-b13f1209bfda/k/17915c24-7159-4b2a-9552-a50f296fa3d6.c0e9241f95e4c5bbbf17b447538274b7/sync?size=A3&amp;amp;format=pdf&amp;amp;data%5Bblank%5D=nodata"&gt; &lt;/a&gt;&lt;a href="https://api.make.cm/make/t/ad146027-af14-4644-92e8-b13f1209bfda/k/17915c24-7159-4b2a-9552-a50f296fa3d6.c0e9241f95e4c5bbbf17b447538274b7/sync?size=A3&amp;amp;format=pdf&amp;amp;data%5Bblank%5D=nodata"&gt;https://api.make.cm/make/t/ad146027-af14-4644-92e8-b13f1209bfda/k/17915c24-7159-4b2a-9552-a50f296fa3d6.c0e9241f95e4c5bbbf17b447538274b7/sync?size=A3&amp;amp;format=pdf&amp;amp;data[blank]=nodata&lt;/a&gt; &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Essential SVG tools</title>
      <dc:creator>Andy Fitzsimon</dc:creator>
      <pubDate>Thu, 15 Apr 2021 11:41:30 +0000</pubDate>
      <link>https://dev.to/andyfitz/essential-svg-tools-41k5</link>
      <guid>https://dev.to/andyfitz/essential-svg-tools-41k5</guid>
      <description>&lt;p&gt;We all could use a little help making SVG the leanest and meanest.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://andyfitzsimon.com/posts/essential-svg-tools/"&gt;Posted with images on my blog&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;This article contains SVG tools I reach for depending on need. &lt;br&gt;
As the rifleman's creed goes: &lt;em&gt;“there are many like it but this one is mine”&lt;/em&gt;.&lt;br&gt;&lt;br&gt;
I like this list. &lt;/p&gt;
&lt;h2&gt;
  
  
  Preamble
&lt;/h2&gt;

&lt;p&gt;My affair with SVG began back when Adobe offered &lt;a href="https://www.w3.org/TR/1998/NOTE-PGML" rel="noreferrer"&gt;PGML&lt;/a&gt;. I loved flash, but figured open standards would win the browser wars . You can read about&lt;a href="https://www.w3.org/Graphics/SVG/WG/wiki/Secret_Origin_of_SVG" rel="noreferrer"&gt; SVG's origins&lt;/a&gt; here.&lt;/p&gt;

&lt;p&gt;Once W3C released the SVG draft: I figured it would own the web and be supported by all major browsers within months (it took years). Nevertheless, my courtship began.&lt;/p&gt;

&lt;p&gt;Fortunately SVG was more useful than just internet use. &lt;br&gt;
By 2003, I had toyed with SVG in my studies. &lt;br&gt;
By 2005, I had finally used SVG commercially thanks to &lt;a href="https://redhat.com"&gt;Red Hat&lt;/a&gt; (and UTF-8). &lt;/p&gt;

&lt;p&gt;SVG assists me in many tasks – from websites, to presentations, to apps, to toolchains.&lt;br&gt;&lt;br&gt;
Here's what I use today:  Some are online tools, some are scripts, some are desktop apps, some are libraries. All incredibly powerful (and/or fun) for the right situation. &lt;br&gt;
So here goes, get your bookmark tool of choice fired up:&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://jakearchibald.github.io/svgomg/"&gt;SVGOMG&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://jakearchibald.github.io/svgomg/" rel="noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The webinterface to SVGO is so handy, I also use SVGO directly in apps and on the commandline.  Everybody should have local access to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g svgo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you use &lt;a href="https://webpack.js.org/"&gt;webpack&lt;/a&gt;, &lt;a href="https://wwwz.snowpack.dev/"&gt;snowpack&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/vite-plugin-svg"&gt;vite-svg-plugin&lt;/a&gt; etc you likely use it too.&lt;br&gt;
The plugins are fascinating and have bailed me out many times.&lt;/p&gt;

&lt;p&gt;There's also &lt;a href="https://github.com/RazrFalcon/svgcleaner"&gt;SVG Cleaner&lt;/a&gt; which has some compelling benefits over SVGO.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://yqnn.github.io/svg-path-editor/"&gt;SVG Path Editor&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://yqnn.github.io/svg-path-editor/" rel="noreferrer"&gt;   &lt;/a&gt;&lt;br&gt;
I use this now more than even &lt;a href="http://www.inkscape.org/"&gt;Inkscape&lt;/a&gt; for simple illustrations, and I really wish the preview would let me add my CSS. But still, this thing is pure GOLD!&lt;br&gt;
When finishing an illustration I often return to this tool and go path by path to reduce unnessecary coordinates and operators. Stealing a few decimals here and there, replacing cubic bezier path operators with more optimal ones like quadratics or arcs.   &lt;/p&gt;

&lt;p&gt;SVG path editor will dramatically improve your understanding of the SVG path system.&lt;br&gt;
Also try out this &lt;a href="https://svg-path-visualizer.netlify.app/#M5%208.5l3-4c2-3-3-4-3-1%200-3-5-2-3%201z"&gt;SVG path visualizer&lt;/a&gt;  I put the heart from this article in it's URL param - very handy when teaching SVG.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://svgcrop.com/"&gt;SVG Crop&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://svgcrop.com/" rel="noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remove the extra margin from around your SVG content so the file is easy to work with.&lt;br&gt;
SVGcrop.com resizes the SVG artboard by changing the &lt;code&gt;viewBox="..&lt;/code&gt; attribute&lt;br&gt;
It's not 100% bulletproof (invisible shapes like clippaths will affect the viewBox) but handy all the same.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://yoksel.github.io/url-encoder/"&gt;SVG URL Encoder&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Inline SVG into CSS - hey it's a gnarly technique but I still find myself throwing SVG into pseudo elements all the time. Think of the saved HTTP request! &lt;br&gt;
This tool from Yoksel makes it super easy!&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://yoksel.github.io/relative-clip-path/"&gt;Relative clip-path &lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;For turning SVG paths into CSS-friendly &lt;code&gt;clip-path&lt;/code&gt; coordinates. Super handy.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://svgfilters.com/"&gt;SVG Fitler Builder&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://svgfilters.com/" rel="noreferrer"&gt;&lt;/a&gt;&lt;br&gt;
Creating complex SVG Filters is incredibly hard, Thankfully we have this brilliant tool.&lt;br&gt;
There's an alternative &lt;a href="https://yoksel.github.io/svg-filters/#/"&gt;SVG Filter Constructor&lt;/a&gt; by &lt;a href="https://yoksel.github.io"&gt;Yoksel&lt;/a&gt; with a less intimidating interface that's worth a look.&lt;br&gt;
Actually &lt;a href="https://boxy-svg.com/app"&gt;Boxy SVG editor&lt;/a&gt; has a great compositing editor which is easy to use too.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://yoksel.github.io/svg-gradient-map/#/"&gt;SVG Gradient Map Builder&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Who doesn't love Duotone effects?  SVG Gradient Map filters make them achievable native on the web. &lt;br&gt;
There's just one annoying catch.  when you are coding these you need to convert your R G and B into separate channels and divide by 255 then place them your R G and B numbers for different colours next to eachother - it feels kind of unnatural.&lt;br&gt;
This tool makes creating a custom filter easy.&lt;/p&gt;

&lt;p&gt;If you want to automate this, I also &lt;a href="https://codepen.io/andyfitz/pen/KKagbqe"&gt;wrote a CodePen&lt;/a&gt; that converts any array into swatches and a duotone effect.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://inkscape.org/"&gt;Inkscape&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://inkscape.org" rel="noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Isn't the evolution of open source desktop applications awesome? &lt;br&gt;
&lt;a href="https://wiki.inkscape.org/wiki/index.php/InkscapeHistory"&gt;Gill &amp;gt; Sodipodi &amp;gt; Inkscape&lt;/a&gt;&lt;br&gt;
I've loved this journey and especially love where it is now.&lt;br&gt;
Run it on your linux machine, your mac .. its brilliant for creative exploration, and especially illustration.&lt;br&gt;
I've used Inkscape since it's inception. Demoed it around the planet and pleaded for top designers to consider it. I could go on and on but let me just say it's &lt;strong&gt;the very best tool for illustration of complex paths&lt;/strong&gt;. and leave the rest up to your imagination.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://penpot.app/"&gt;Penpot&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://penpot.app/" rel="noreferrer"&gt;&lt;/a&gt;&lt;br&gt;
Early days to call this a Figma killer - But I do find it does most of what I want out of Figma (for free and freedom). Super impressed and excited to see where this project goes.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://app.rawgraphs.io/"&gt;RawGraphs &lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://app.rawgraphs.io" rel="noreferrer"&gt;RAWGraphs&lt;/a&gt;&lt;br&gt;
Brilliant way to pre-render beautiful data graphics, create the layout in rawgraphs then style with your own CSS. &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://boxy-svg.com/app"&gt;Boxy Editor&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://boxy-svg.com/app" rel="noreferrer"&gt;&lt;/a&gt;&lt;br&gt;
At first sight, boxy looks like yet another svg-edit clone. But open up the panels and start editing (start using the i and o keys) and you'll see why it's fantastic for small projects.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://gitlab.gnome.org/GNOME/librsvg"&gt;librSVG&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://gitlab.gnome.org/GNOME/librsvg" rel="noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a blazingly fast library to work with SVG files (used in ImageMagick and heaps more). If you are a performance-driven developer, &lt;a href="https://gitlab.gnome.org/GNOME/librsvg/-/blob/master/src/bin/rsvg-convert.rs"&gt;RSVG convert&lt;/a&gt; in particular will blow your mind. Also you should follow &lt;a href="https://people.gnome.org/~federico/blog/tag/librsvg.html"&gt;Federico Mena-Quintero&lt;/a&gt; Who is dragging RSVG into the future with Rust.&lt;/p&gt;

&lt;p&gt;Worthy mention goes to &lt;a href="https://github.com/RazrFalcon/resvg"&gt;reSVG&lt;/a&gt; which is a super performant and powerful alternative to rSVG.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://github.com/jankovicsandras/imagetracerjs"&gt;Imagetracer JS&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;There are many bitmap to vector tracers like &lt;a href="http://potrace.sourceforge.net/"&gt;potrace&lt;/a&gt;, autotrace etc. Imagetracer is the most promising for web developers and has a few tricks up it's sleeve.&lt;br&gt;
Handy to have on the CLI too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;imagetracerjs/nodecli&amp;gt;node nodecli ../in.png outfilename out.svg scale 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;a href="https://gitlab.com/inkscape/lib2geom"&gt;2geom&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://gitlab.com/inkscape/lib2geom" rel="noreferrer"&gt;&lt;/a&gt;&lt;br&gt;
If you're building an app that needs to perform fast and accurate 2d computational geometry (boolean operations and way way more) you'll end up grateful for &lt;a href="http://njhurst.com/"&gt;Nathan Hurst&lt;/a&gt; and all other contributors who made lib2geom possible.&lt;br&gt;
Fun fact, Inkscape uses 2geom under the hood and also powers the amazing live path effects etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Single-purpose SVG generator tools
&lt;/h2&gt;

&lt;p&gt;  &lt;br&gt;
&lt;a href="https://www.blobmaker.app/"&gt;Blob Maker&lt;/a&gt; and &lt;a href="https://getwaves.io/"&gt;Wave Maker&lt;/a&gt; - both part of the super cool &lt;a href="https://app.haikei.app/"&gt;haikei app&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/georgedoescode/full/dyNVNjG"&gt;Noise maker&lt;/a&gt; nice patterns of directional lines or dots&lt;br&gt;
&lt;a href="https://yoksel.github.io/wave-maker/"&gt;Arc Wave Maker&lt;/a&gt; nifty example of repeating arc paths&lt;br&gt;
&lt;a href="https://www.misha.studio/snowflaker/"&gt;Snowflakes&lt;/a&gt; Random snowflakes &lt;br&gt;
&lt;a href="https://yoksel.github.io/snowflake/"&gt;Snowflake Painter&lt;/a&gt; Design a snowflake with lines&lt;/p&gt;

&lt;h2&gt;
  
  
  What else?
&lt;/h2&gt;

&lt;p&gt;Well there's lots of nifty things I havent personally climbed into. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/gliffy/canvas2svg"&gt;Canvas2SVG &lt;/a&gt; - I have a feeling I'll get to know this library well someday.&lt;br&gt;
&lt;a href="https://xmlgraphics.apache.org/batik/"&gt;Apache Batik&lt;/a&gt;  - I used it quite a bit in the early days but it never took root in my toolchain.&lt;br&gt;&lt;br&gt;
&lt;a href="https://svgjs.com/docs/3.0/"&gt;SVGJS&lt;/a&gt; It offers compelling shortcuts, I'm just a fan of vanilla JS. This also goes for &lt;a href="http://snapsvg.io/"&gt;SNAP SVG&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Thank you SVG
&lt;/h1&gt;



&lt;p&gt;So there you have it, the best tools to help you with SVG.&lt;br&gt;
By the way, &lt;a href="http://andyfitzsimon.com/posts/essential-svg-tools/"&gt;all the images in this article&lt;/a&gt; were super-tiny inlined SVG - open web inspector and see for yourself.&lt;/p&gt;

&lt;p&gt;On a personal note:&lt;br&gt;
There are heroes I'd like to recognise; friends who moved SVG forward directly or indirectly - at least in my universe: &lt;br&gt;
&lt;a href="https://mcc.id.au/"&gt;Cam Mcormack&lt;/a&gt;, &lt;a href="https://raphlinus.github.io/"&gt;Raph Levien&lt;/a&gt;, &lt;a href="https://svgees.us/"&gt;Chris Lilley&lt;/a&gt;, &lt;a href="https://cworth.org/"&gt;Carl Worth&lt;/a&gt;, &lt;a href="https://www.w3.org/People/Quin/"&gt;Liam Quinn&lt;/a&gt;, &lt;a href="http://njhurst.com/"&gt;Nathan Hurst&lt;/a&gt;, Peter Moulder, &lt;a href="http://tavmjong.free.fr/"&gt;Tavmjong Bah&lt;/a&gt;, &lt;a href="https://twitter.com/bryceharrington"&gt;Bryce Harrington&lt;/a&gt;, &lt;a href="https://www.ekips.org/"&gt;Aaron Spike&lt;/a&gt;, Jon Cruz, Bulia Byak, &lt;a href="https://gould.cx/ted/"&gt;Ted Gould&lt;/a&gt;, &lt;a href="http://schepers.cc/"&gt;Doug Schepers&lt;/a&gt;, &lt;a href="https://twitter.com/domlachowicz"&gt;Dom Lachowicz&lt;/a&gt;, &lt;a href="https://twitter.com/dodjiseketeli"&gt;Dodji Seketeli&lt;/a&gt;, &lt;a href="https://blog.fishsoup.net/"&gt;Owen Taylor&lt;/a&gt; and so many more. &lt;/p&gt;

</description>
      <category>svg</category>
      <category>performance</category>
      <category>webdev</category>
      <category>design</category>
    </item>
    <item>
      <title>The smallest SVG possible</title>
      <dc:creator>Andy Fitzsimon</dc:creator>
      <pubDate>Thu, 15 Apr 2021 11:32:21 +0000</pubDate>
      <link>https://dev.to/andyfitz/the-smallest-svg-possible-2lml</link>
      <guid>https://dev.to/andyfitz/the-smallest-svg-possible-2lml</guid>
      <description>&lt;p&gt;How would you make &lt;a href="http://andyfitzsimon.com/posts/small-svg/" rel="noopener noreferrer"&gt;my site favicon&lt;/a&gt; from a bitmap into an SVG? &lt;em&gt;(don’t cheat with web inspector)&lt;/em&gt;&lt;/p&gt;



&lt;p&gt;The lazy me would just software trace using my favourite illustration tool. (&lt;a href="https://inkscape.org" rel="noopener noreferrer"&gt;Inkscape&lt;/a&gt;)&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fandyfitzsimon.com%2Fimg%2Fsmall-svg%2Ff.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fandyfitzsimon.com%2Fimg%2Fsmall-svg%2Ff.webp" alt="inkscape with an autotraced shape"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But yuck, look at those node coordinates, and the shape is kind of melted when you look up close.&lt;/p&gt;

&lt;p&gt;In better news, the resulting filesize is an affordable &lt;strong&gt;2kb&lt;/strong&gt;, much smaller than a decent resolution png or jpeg – but files over two thousand bytes are rookie numbers! &lt;br&gt;
We're a long way from optimal SVG sizes.&lt;/p&gt;

&lt;p&gt;So maybe we should roll up our sleeves and manually redraw it with the pen tool — being careful about where to place nodes, and when to use straight lines vs beziers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fandyfitzsimon.com%2Fimg%2Fsmall-svg%2Ff-manual.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fandyfitzsimon.com%2Fimg%2Fsmall-svg%2Ff-manual.png" alt="manually placed cubic beziers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Woohoo we're now at &lt;strong&gt;800 bytes&lt;/strong&gt; - less than half the original size.&lt;/p&gt;

&lt;p&gt;At this point, I'd urge you to go one step further and optimise with &lt;a href="https://github.com/svg/svgo" rel="noopener noreferrer"&gt;SVGO&lt;/a&gt; or manually with &lt;a href="https://jakearchibald.github.io/svgomg/" rel="noopener noreferrer"&gt;SVGOMG&lt;/a&gt; — being sure not to melt the shape with precision settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fandyfitzsimon.com%2Fimg%2Fsmall-svg%2Ff-omg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fandyfitzsimon.com%2Fimg%2Fsmall-svg%2Ff-omg.png" alt="SVGO optimising an SVG file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wow, that worked great — We're now at around &lt;strong&gt;236 bytes&lt;/strong&gt; which is excellent.  The shape is even closer to the original than tracing. This is usually as good as it gets, an 88% reduction from automatic tracing. IMO this was worth the effort.&lt;/p&gt;
&lt;h2&gt;
  
  
  What if we went deeper?
&lt;/h2&gt;

&lt;p&gt;I managed to get the image down to &lt;strong&gt;127 bytes&lt;/strong&gt;, 46% smaller than our best 236 byte image. All with full-fidelity by using a &lt;code&gt;stroke-linecap:round&lt;/code&gt; hack.&lt;br&gt;
Here's the full SVG:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; 
&lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;".5 .5 3 4"&lt;/span&gt; 
&lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt; 
&lt;span class="na"&gt;stroke=&lt;/span&gt;&lt;span class="s"&gt;"#20b2a"&lt;/span&gt; 
&lt;span class="na"&gt;stroke-linecap=&lt;/span&gt;&lt;span class="s"&gt;"round"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"
M1 4h-.001
V1h2v.001
M1 2.6
h1v.001"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First I stroke the lines so I save on doubling coordnates, then I exploit the &lt;code&gt;v&lt;/code&gt;and &lt;code&gt;h&lt;/code&gt; relative operators at tiny offsets. &lt;/p&gt;

&lt;p&gt;See the values with &lt;code&gt;h.001&lt;/code&gt; and &lt;code&gt;v.001&lt;/code&gt; and &lt;code&gt;h-.001&lt;/code&gt;  ?&lt;br&gt;&lt;br&gt;
That's how I hacked the directional rounded corners.&lt;/p&gt;

&lt;p&gt;Normally &lt;code&gt;stroke-linecap:round&lt;/code&gt; is just round. Nothing you can do about it. &lt;br&gt;
But when you change direction &lt;em&gt;REALLY&lt;/em&gt; close to the edge coordinate, the cusp squares off on one side only, and you can control which side with negative or positive relative values.&lt;/p&gt;

&lt;p&gt;Neat huh? We're just getting started...&lt;/p&gt;
&lt;h1&gt;
  
  
  The Outfit logo
&lt;/h1&gt;

&lt;p&gt;A while back, I created &lt;a href="https://codepen.io/andyfitz/full/gOwzMwV?editors=1000" rel="noopener noreferrer"&gt;this interactive demo&lt;/a&gt; of the Outfit logo to teach some of the fundamentals of plotting and styling SVG path coordinates.  There's no fill here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/andyfitz/full/gOwzMwV?editors=1000" rel="noopener noreferrer"&gt;https://codepen.io/andyfitz/full/gOwzMwV?editors=1000&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  History of the mark
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://rowanhogan.com/" rel="nofollow noopener noreferrer"&gt;Rowan Hogan&lt;/a&gt; originally designed the Outfit logo. No doubt without regard specifically for SVG format optimisation. Don’t let the medium become the message as they say. &lt;/p&gt;

&lt;p&gt;The design evolved with minor optical updates and when it came time to make this demo, it had optimisation amenities stacked against it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An optical overshoot (round coords non-exact to a grid)&lt;/li&gt;
&lt;li&gt;Non-perfect curves (the f and the u are bent differently)&lt;/li&gt;
&lt;li&gt;Non 1:1 grid rhythm (1:1.3 spacing of stems) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thankfully the solution above is full-fidelity to the intended mark. &lt;/p&gt;

&lt;p&gt;It got even smaller as a one-liner:  &lt;strong&gt;253 bytes&lt;/strong&gt;, styled and uncompressed (not bad for so many letters)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;"0 0 19 8.5"&lt;/span&gt; 
&lt;span class="na"&gt;stroke=&lt;/span&gt;&lt;span class="s"&gt;"#e40046"&lt;/span&gt; &lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"2.36"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"6.12"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"1.68"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M5.35 4
v2.5A1.02 1 0 008 6.5v-2h10.68
M10.2 8.2v-6
m2.3 6V2a1.3 1.2 10 012-1
m.3 7.2V4.5
m2.3 3.7v-6"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M14.8 2.8v0"&lt;/span&gt;
&lt;span class="na"&gt;stroke-linecap=&lt;/span&gt;&lt;span class="s"&gt;"round"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Rules to SVG by
&lt;/h1&gt;

&lt;p&gt;This list is by no means comperehensive but it does serve as a rough guide&lt;/p&gt;

&lt;h2&gt;
  
  
  Small Artboards
&lt;/h2&gt;

&lt;p&gt;Ensure coodinate precision by keeping your &lt;code&gt;viewBox&lt;/code&gt; under 10 or 100 - from zero&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;"0 0 10 10"&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It makes sense to factor up by 10 for more intricate shapes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;"0 0 100 100"&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;   

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both scales work depending on the complexity of your image. The point here is we dont want every coordinate to be in the thousands, we also want to avoid unnessecary decimal coordinates. Every byte counts.&lt;br&gt;
If every coordinate has a decimal place, go up by 10. If only a few do, try to round up.&lt;/p&gt;
&lt;h2&gt;
  
  
  Stroke if you can
&lt;/h2&gt;

&lt;p&gt;Every shape you can pull off as a stroke that would otherwise be a filled path saves you 2-3x bloat in coordinate. This is fairly easy to visualise as a stroke only has an inner line that can be expanded wheras a filled shape has two outer lines to create a zone.&lt;/p&gt;
&lt;h2&gt;
  
  
  Know when to capital or lowercase path coordinates
&lt;/h2&gt;

&lt;p&gt;Don't know the difference?&lt;br&gt;
Uppercase Letters like &lt;code&gt;M&lt;/code&gt; &lt;code&gt;C&lt;/code&gt; &lt;code&gt;L&lt;/code&gt;  &lt;code&gt;A&lt;/code&gt; &lt;code&gt;H&lt;/code&gt; &lt;code&gt;V&lt;/code&gt; &lt;code&gt;Q&lt;/code&gt; &lt;code&gt;T&lt;/code&gt; etc all start an operation relative to the viewBox&lt;br&gt;
Lowercase letters (same as above) &lt;code&gt;m&lt;/code&gt; &lt;code&gt;c&lt;/code&gt; &lt;code&gt;l&lt;/code&gt; &lt;code&gt;a&lt;/code&gt; &lt;code&gt;h&lt;/code&gt; &lt;code&gt;v&lt;/code&gt; &lt;code&gt;q&lt;/code&gt; &lt;code&gt;t&lt;/code&gt; etc start from the last coordinate you did&lt;/p&gt;

&lt;p&gt;Relative or absolute positioned coordinates make a huge difference. Sometimes optimisation tools like SVGO can select which one is best, but not always.&lt;/p&gt;
&lt;h2&gt;
  
  
  Chose your operator wisely
&lt;/h2&gt;

&lt;p&gt;Using a horizontal &lt;code&gt;H&lt;/code&gt; or vertical &lt;code&gt;V&lt;/code&gt; operator is great because you only need one coodinate it saves you tryping both X and Y,  you only need one coordinate so that halves what would otherwise be redundant axis data with the line-to &lt;code&gt;L&lt;/code&gt; operator.&lt;/p&gt;

&lt;p&gt;Arc paths, quadratics and cubic splines all have their own benefits and problems. &lt;/p&gt;
&lt;h2&gt;
  
  
  Dirty Path Tricks
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Circle with single arc operators
&lt;/h3&gt;

&lt;p&gt;You can draw 'pretty much' a perfect circle with a single SVG path arc operator. &lt;/p&gt;

&lt;p&gt;If you're already working in a &lt;code&gt;path d=""&lt;/code&gt; element, there's no need for a new element.&lt;br&gt;
This saves you 10 bytes per circle in that context. So we can do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;M5 0a5 5 0 10.001 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs having to go create a new element which could get messy for your CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"5"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"5"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"5"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Dots with stroke-linecap="round"
&lt;/h3&gt;

&lt;p&gt;if you're doing a line icon with linecap-round you can make a dot the exact width of your stroke just by doing a very short relative horizontal or vertical line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M 5 5 h.001"&lt;/span&gt; &lt;span class="na"&gt;stroke-linecap=&lt;/span&gt;&lt;span class="s"&gt;"round"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>svg</category>
      <category>optimisation</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
