This post will document a method to produce a self contained animated SVG. An illustration should be robust, like a JPEG or a PNG - and in this instance if we imagine an SVG that illustrates a mechanical process - we want that illustration to stand alone and not be dependent on any external files. Animated icons or illustrations in a RSS feed. Sign me up fam 🔥
I'm digging svg symbols at the minute, so let's use one of those. Here we have a symbol called hydrogen
which contains a three circles: one for our proton
, another to represent the electrons orbit
and one to represent the electron
. At this point we can inject this SVG into some html and the electron will orbit the proton.
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;" xml:space="preserve">
<symbol id="hydrogen" viewBox="0 0 200 200">
<circle id="proton" stroke="none" fill="rgb(252, 75, 133)" cx="100" cy="100" r="29" />
<circle id="orbit" stroke="rgb(0, 183, 255)" stroke-width="1" stroke-miterlimit="10" fill="none" cx="100" cy="100" r="65" />
<circle id="electron" stroke="rgb(0, 183, 255)" stroke-width="20" stroke-linecap="round" stroke-miterlimit="10" stroke-dasharray="0,401" stroke-dashoffset="0" fill="none" cx="100" cy="100" r="65">
<animate attributeName="stroke-dashoffset" from="0" to="401" dur="4s" repeatCount="indefinite" />
</circle>
</symbol>
</svg>
You can attach an animate
tag to any element in an svg. Here, we've targeted the dash-offset and used it to push a single dash around a circle
to render our animation. Note the circle
element with the animate tag has a closing </circle>
rather than closing inline like: .../>
.
<animate attributeName="stroke-dashoffset" from="0" to="401" dur="4s" repeatCount="indefinite" />
Make sure you declare a viewbox - this will define the aspect ratio your illustration will render at. This could be important in the case of a mechanical diagram or less so if you are depicting something like a line chart. There's further reading on the specification for outlying scenarios like making an svg only scale in the x-axis.
They have worked for the likes of Nike, Vodafone, Sky, Disney and Pearsons, won awards from Promax, BAFTAs, the Appys and The Drum. Spoken at The Waldorf and Southampton University - despite swearing like a sailor. Available for hire to draw pretty curves and code clever things.
POSSE: Reclaiming social media in a fragmented world
Supreme Commander - Graphics Study
Vim - Inserting inline dates shortcut
Crypto and ‘TradFi’: a friendship of convenience
The mysterious rise of the Chinese e-commerce giant behind Temu
Oumuamua, Our first interstellar visitor
How a 27-year-old busted the myth of Bitcoin’s anonymity
The future is probably federated
Integrated Tech Solutions: Aesop Rock
No, we didn't forget any zeros
Tupac Shakur murder: video released of suspect’s arrest for 1996 murder
"How we fit an NES game into 40 Kilobytes"
Saving the sounds of Afghanistan
Fuck around and find out award: Antoinette Sandbach
The long drawn out implosion of NFTs
How palette and lighting works in The Settlers II
Hidari: The Stop-Motion Samurai Film
Babylon 5: The Road Home. Official Trailer
The secret Babylon 5 project is...an animated movie
Panic enters the Mastodon arena
Adobe is collecting all of its customers' pictures into a machine learning training set.
UK Treasury joins chat app Discord and is met with torrent of abuse
Another recruit joins the Walkman ranks
ProleteR: Curses from Past Times
Financial Times's Gideon Rachman on the Ukraine Conflict
Why African fashion is having its moment
DJ Cable: Throw Back Thursdays
Web3.0: A Libertarian Dystopia
Edited latecomer's guide to crypto
Aesop Rock x Blockhead. Garbology
Moving files around for Crayon Munchers
One Man’s Amazing Journey to the Center of the Bowling Ball
The Oral History of the Chelsea Hotel
Good developers know how, great ones know why
"Fuck the bread, the bread is over"
The Promise and Perils of Insect Farming
Why bumblebees love cats, or, why everything is a system.
"This time, damn it, we’re going to get to the surface"
Designing 2D graphics in the Japanese industry
Bad launch leads to real world relativistic math
Slaughter at the bridge: Uncovering a colossal Bronze Age battle
Behind the Accidentally Resilient Design of Athens Apartments
Unreleased De La Soul Acapellas
You're designing for the web wrong: Part 1
A newspaper made from RSS feeds
Swift: Google's bet on differentiable programming
Two up, Two down in London Town