8 ms·
Nice things with SVG
- staindk 1y agoGreat article! On mobile I can't find anywhere to demo/see the animated content in action, not sure if it's desktop only or what.
- kmoser 1y agoThis taught me that SVGs can be animated with CSS. Cool! I wonder if anybody has recreated vector graphics games like Asteroids using SVGs and animation. You'd have to use JS to change the shape and direction of the asteroids when they're shot, but that would just require a bit of JS.
- deleted 1y ago[deleted]
- mkoryak 1y agoIt would be more performant to use canvas, but it might be kind of fun to do with svg
- hinkley 1y agoEasier to do a11y in SVG. And the oft overlooked synergy with aria work is test automation. Code that is hard to screen read is often also difficult to integration or E2E test accurately.
- hinkley 1y agoVideo I bookmarked when I was stuck in backend land because I knew I’d want to learn it some day: https://youtube.com/watch?v=wc8ovZZ78SY https://youtube.com/watch?v=wc8ovZZ78SY I discovered this shortly after introducing The Secret of Kells to a child and had terrible, beautiful ideas about overly ornate websites that I have since thought better of. Mostly.
- LegionMammal978 1y agoOne fun thing that can be done with SVG files: you can use entities in an inline DTD to define constants to be shared across different places in the file. You can see some great examples of this in the SVGs in David Ellsworth's "Squares in Squares" page [0]. The major browsers have no issues with this, though note that some tools like Inkscape won't parse the DTD nor expand the entities. [0] https://kingbird.myphotos.cc/packing/squares_in_squares.html https://kingbird.myphotos.cc/packing/squares_in_squares.html
- lenkite 1y agoMaybe I am missing something, but can't find any !doctype or !element that would represent a DTD on that page. If you are talking simply about SVG defs and use - that isn't a DTD.
- LegionMammal978 1y agoThey're all in the standalone files, e.g., look at the source of https://kingbird.myphotos.cc/packing/square-11.svg https://kingbird.myphotos.cc/packing/square-11.svg. It defines a bunch of entities to represent various lengths and angles, which obviously can't be <use>d. (CSS variables would be an alternative these days, but many non-browser tools such as librsvg will have trouble with those as well.)
- lenkite 1y agoAah thanks - these don't show up in the chrome inspector as by that time they are apparently already substituted.
- timewizard 1y agoYou can also extract different parts of an existing svg and use (clone) them elsewhere on the page. https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/use https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/E...
- 1y ago
- chentastic 1y agoWas always fascinated by SVG art. How good are LLMs in generating SVGs?
- krebby 1y agoGetting better! https://simonwillison.net/2024/Oct/25/pelicans-on-a-bicycle/ https://simonwillison.net/2024/Oct/25/pelicans-on-a-bicycle/
- jamesgpearce 1y agoPerhaps a generous definition of "better"... but some of those genuinely made me laugh!
- zero_shift 1y agoIn at least my limited experience, they're kind of bad. They can retrieve shapes that already exist, sometimes inaccurately, but they are less reliable at creating novel ones
- simpaticoder 1y agoRegular LLMs are quite bad at it (see simonwillison's blog post). However this paper [0] describes an apparently sound approach using Neural Radiance Fields (NeRFs), however their github repo [1] has been "code coming soon!" for months now, so you can't really use it. 0 - https://arxiv.org/pdf/2501.03992 https://arxiv.org/pdf/2501.03992 1 - https://github.com/SagiPolaczek/NeuralSVG https://github.com/SagiPolaczek/NeuralSVG
- flaviuspopan 1y agoIt's been released as of an hour ago!!! https://github.com/SagiPolaczek/NeuralSVG/pull/6 https://github.com/SagiPolaczek/NeuralSVG/pull/6 Oh boy oh boy oh boy
- pizza 1y agoI've gotten decent outputs with Claude with iteration (sending both text feedback and screenshot for context) and then tweaked the output in Inkscape.
- hinkley 1y agoI always thought transforms were an odd inclusion in SVG until I tried to make my own icons/logo with it. Those curves are challenging to get right. When I got done with the second logo I decided it looked flat and I needed to skew it 10°. The thought of rewriting all of those lines and curves suddenly made rotation seem like a much much better idea. Good thing too because it looked weird next to test and I changed the angle several more times to make the kerning look right.
- aiibe 1y agoSvg Tailwind combo makes hover animations easy and fun.
- mvdtnz 1y agoAny examples? This sounds interesting to me.
- srid 1y ago<svg class="w-16 h-16 text-blue-500 transition-all duration-300 ease-in-out transform hover:scale-125 hover:rotate-12 hover:text-purple-600" fill="currentColor" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" > <circle cx="50" cy="50" r="40" /> </svg> Preview: https://grok.com/share/bGVnYWN5_2a2dd030-8177-4fa0-aac5-17d259bab8c4 https://grok.com/share/bGVnYWN5_2a2dd030-8177-4fa0-aac5-17d2...
- rckt 1y agoSVG feels like a very underexplored and underused territory. You can do so many things with it. It really depends on your imagination. But you’ll possibly need to “hardcore” a lot of stuff, so yeah, depends on the use case as well.
- memhole 1y agoI agree. I’m sure there’s limitations, but svg feels more like a wysiwyg for web design than css
- wwweston 1y agoSeems like it hits limits really fast — management/legibility gets difficult without groups and layers and performance doesn’t seem to scale well.
- srid 1y agowithout groups and layers As distinct from `<g>`?
- WillAdams 1y agoTwo usages which I thought were interesting: - adding toolpath information so as to use Flash as the engine for a Computer Aided Manufacturing tool: https://github.com/Jack000/PartKAM https://github.com/Jack000/PartKAM - (this was my project along w/ Edward R. Ford) adding hyperlinks to part lists to highlight parts in an assembly diagram: https://github.com/shapeoko/Docs https://github.com/shapeoko/Docs --- unfortunately, that doesn't seem to work anymore.
- perilunar 1y agoOne thing i'd like to see is an entire site built with SVG and JS without any HTML at all. It's possible but i haven't seen anyone do it yet.
- eMPee584 1y agoso how can you know it's actually possible?
- CliffStoll 1y agoIs there any SVG extension which allows density of line? I have a plotter which can lift/lower a pen; it's driven from SVG files. It'd be sweet to allow the pen to lower while the line is being drawn (as we often do with handwriting). Oh - it's an Axidraw, from Evil Mad Scientist Labs - great device, wonderful people.
- WillAdams 1y agoProbably you would want to do that with G-code. I've been doing that sort of thing in: https://github.com/WillAdams/gcodepreview https://github.com/WillAdams/gcodepreview
- m-a-t-t-i 1y agoIt's pretty easy to store custom instructions in plain SVG files and interpret them in with your reader. For example I have a multi-purpose laser-cutter / plotter and I use opacity for laser power, stroke weight for movement speed, green channel for number of passes, blue channel for z-axis height and red channel for lowering the pen or turning of the laser etc.
- chrisweekly 1y agoEven tho it's 8y old, Sarah Drasner's famous "SVG Can Do That?" talk is still eye-opening for many. CSS has matured a ton since then (I'm less sure about SVG per se)... in any case it's HIGHLY recommended. Slides: https://slides.com/sdrasner/svg-can-do-that https://slides.com/sdrasner/svg-can-do-that Video: https://youtu.be/ADXX4fmWHbo?si=6YPZkopyEDc8PSte https://youtu.be/ADXX4fmWHbo?si=6YPZkopyEDc8PSte
- jamra 1y agoBig fan of her book as well though I don’t know if the recommended tools are still relevant.
- srid 1y agoWhich book are you referring to?
- technetist 1y agoProbably “SVG Animations” available through O’Reilly. It is from 2017. While many of the frameworks used have come and gone; there are a few stable concepts. If you can get it on sale, I’d recommend. Full price is a hard sell.
- deleted 1y ago[deleted]
- j45 1y agoAppreciate the intro to the book above - two additional useful SVG books. I think O'Reilly has a few more SVG titles SVG Essentials: https://www.oreilly.com/library/view/svg-essentials-2nd/9781491945308/ https://www.oreilly.com/library/view/svg-essentials-2nd/9781... SVG Text Layout: https://www.oreilly.com/library/view/svg-text-layout/9781491933817/ https://www.oreilly.com/library/view/svg-text-layout/9781491... The fact there’s a book on just text layout helped me learn how much depth there is in SVG.
- 1y ago
- baosoy 1y agoI worked on a project that did something fun with SVGs like this. It was built with React, and we had a series of still illustrations with an animated element, with its colour controlled by a CMS. The frontend would basically call an API that would return an SVG image with the right colour assigned and the animation done by hiding and showing svg elements. You can see an example here: https://web.archive.org/web/20221020133516im_/https://uncrowd.uk/illustrations/friction/bright_yellow.svg https://web.archive.org/web/20221020133516im_/https://uncrow...
- joshuaturner 1y ago"A Deep Dive Into SVG Path Commands" by Nanda Syahrasyad [0] is really great for understanding how SVG paths are composed. It's from almost 2 years ago now and really opened my eyes to all that SVGs can do and exactly how they're doing it. [0] https://www.nan.fyi/svg-paths https://www.nan.fyi/svg-paths
- AndrewSwift 1y agoI love what you have done here — it's very graceful. I was feeling great but now I think "I have a lot to learn — I'd better get going!" If you are interested in SVG animation, I wrote a program to do it from within Adobe Illustrator — see examples and how it works at https://svija.com/en/animation https://svija.com/en/animation
- exabrial 1y agoAll I want is a browser that executes WASM and displays SVG... get out out of JS/HTML hell.
- xyst 1y agosvg based games, wen?
- xerox13ster 1y agowasn't that flash player?
- flaviuspopan 1y agosoon
- nshkrcom 1y ago[dead]
- braebo 1y agoComplex animated SVG is fun to roll until you get into the weeds of SMIL and Safari bricks your phone for missing a leading 0 on a float or some random nonsense.
- hansvm 1y ago"bricks"?
- chrisweekly 1y agoIt's slang; picture a literal brick (akin to a rock or stone). Your device is "bricked" if something has rendered it useless.
- EE84M3i 1y agoI think GP is suggesting that the idea the GGP encountered an SVG that bricked their iPhone (without being a specifically crafted exploit payload) is an extraordinary claim that would require extraordinary evidence.
- lawik 1y agoAlso easy to interpret generously as hyperbole. Especially if you know how easy it can be to accidentally do something that works fine in other browsers but makes Safari kill the tab. Doesn't actually brick the device but a fairly hard failure in the browser.
- hansvm 1y agoGP was right. I was pretty sure your interpretation is correct, but I've seen enough things over the years that I was curious if there were any more details about actual bricking.
- knighthack 1y agoI've always thought the word 'bricked' as more akin to 'turning the phone into a useless brick'.
- intrasight 1y agoHaven't done much recently, but I do really like SVG. I did a fun project for a grid scale battery company in 2017. I generated graphical reports of battery status and health. I used a .Net extension in Sql Server to generate the graphics from the database.
- deivid 1y agoSVG+CSS is super powerful, a simple feature that I love is making diagrams respect dark/light mode, without any javascript. Check the diagrams here for example: https://blog.davidv.dev/posts/ipvs-lb/ https://blog.davidv.dev/posts/ipvs-lb/
- danielstocks 1y agoMade a small silly game recently just for fun, using mostly CSS animated SVG tiles for rendering: https://pipeline-panic.vercel.app/ https://pipeline-panic.vercel.app/
- perilunar 1y agoNice!
- two_handfuls 1y agoIt's a fun little game, thank you for sharing!
- danielstocks 1y agoSource code can be found here: https://github.com/danielstocks/pipeline-panic https://github.com/danielstocks/pipeline-panic
- chrisweekly 1y agoThis is a great little game! Thanks for sharing the source, too -- v nicely done.
- vunderba 1y agoNice. Reminds me of the board game Waterworks from the 70s. https://boardgamegeek.com/boardgame/333/waterworks https://boardgamegeek.com/boardgame/333/waterworks
- fitsumbelay 1y agoAwesome post, site design is dope as well For as long as SVG's been around its potential feels untapped. I can't think of any other element that can encapsulate functional HTML, CSS and JS -- basically an entirely different HTML document -- as easily
- snitty 1y ago>height="20" What fresh hell is this?
- perilunar 1y agoWhat's the issue? HTML attribute: height="20" CSS property: height: 20px; JS statement: element.style.height = "20px";
- benjanik 1y agoFor anyone who is using creatively using JS to create SVG dynamically and looking for work, DM me!
- all2 1y agoNot that guy, but just chiming in so you have some visibility.
- perilunar 1y agoCouple of (nice?) things I've built with SVG: Sun Clock: https://sunclock.net https://sunclock.net Degrees What?: https://degreeswhat.com https://degreeswhat.com
- slow_turtle3 1y agooh wow!!
- eMPee584 1y agoA lot of ecosystem vibe seems to go to Lottie at the moment though.. does SVG cover a matching feature set? is there hope for a conversion tool?
- Voultapher 1y ago> Unkey's landing page is a nice example. That landing page is a nauseatingly laggy experience on a very powerful M1 Pro laptop. And slow to load, all for some fancy lines? I'd take a product that focuses on substance over style as dev. Don't get me wrong, style is important and I like pretty things, but here it seems the tradeoff is not well done.
- RobotToaster 1y agoSounds like a problem with apple's implementation? I don't have any problem with firefox on an old 9th gen i5.
- leptons 1y ago> laggy experience on a very powerful M1 Pro laptop Apple's M series chips aren't really all that powerful, but they are very power efficient. There are far faster laptops out there than what Apple offers, though they do consume more power. My AMD-based laptop outperforms the M1 Pro by a wide margin, though it is a power hog. I had no problem viewing the Unkey website. If you're using Safari, that may also be a problem, because Safari honestly sucks.
- Voultapher 1y agoI'm on Chrome and the page was fine-ish after the first full scroll, but that first scroll was quite laggy. Note, I'm extra sensitive to this kind of stuff. > Apple's M series chips aren't really all that powerful, but they are very power efficient. In terms of single threaded performance, they are both. Especially the IPC is very impressive take a look at for example https://github.com/Voultapher/sort-research-rs/blob/main/writeup/lomcyc_partition/text.md#firestorm https://github.com/Voultapher/sort-research-rs/blob/main/wri... > Assuming the same instructions per cycle (IPC) and mapping of instructions to cycles, Zen 3 should be ~1.53x faster than Firestorm by virtue of clock frequency. Yet the micro-architecture released in the same year as Zen 3, goes from exceeding it to closely trailing it in terms of absolute throughput when the effects of branch misprediction are minimized. Their newest generation of P-cores is simply unmatched in terms of ST perf, an M4 core can do 4k points in Geekbench ST, AMD's best Desktop offering does ~3.5k at a much higher clock frequency. For web browsing ST perf is king.
- imhoguy 1y agoI really miss Macromedia Flash. There wasn't a single tech like Flash and SWF format which flourished with so many indie games and animated movies available without any extra downloads (other than Flash Player). Barier to entry was so low. Now, take SVG, it has potential to do everything what SWF could. But there is no editor like Flash and scene/object based coding solution like ActionScript. And each browser has own quirks so only simple SVG is guaranteed to be displayed everywhere.
- deleted 1y ago[deleted]
- 7952 1y agoWell it still exists as Adobe Animate which can export to html. Comparing SVG to Flash seems like an apples to oranges comparison anyway. The format does not have to do everything that Flash did but can rely on the other technologies in the browser.
- rchaud 1y agoAdobe Animate is a sad shell of Flash. It only supports 2D, where its ancient predecessor supported 3D 20 years ago. It is a largely dead product, although parts of the Flash spirit lives on in After Effects, which is a video-centric tool.
- jefozabuss 1y agoI think web assembly can be comparable, e.g. unity/unreal/godot can compile to the browser pretty easily. The problem is that each of these apps can be quite bloated and in the tens of MBs range not the usual single digit MB.
- mettamage 1y agoSounds like there is a startup opportunity here to recreate this
- gocsjess 1y agoOne nice thing about SVGs is that they can be connected to the dom, you can do css, and easier to debug than canvas. Performance is the only thing holding it back from making declarative code for plotting and mapping charts.
- notnullorvoid 1y agoWhat performance issues have you encountered? Perf was decent 10 years ago so long as you avoided filters, but even that has improved.
- defanor 1y agoSVG feels much like HTML to me, especially when animations are involved: on the first sight it is quite nice and simple, does its job well, can be handled by fairly basic viewers (as well as converters, editors) and generated easily. Then there are even more features with CSS and JS, which also look neat, but then simplicity goes away, along with it goes the wide support of full functionality, and compatibility (due to partial support, unexpected behaviors in different contexts). It still looks like a fine option when animations are needed, but I would rather avoid those in SVG when they are not necessary.
- paulryanrogers 1y agoFun to see how apparent boundaries can be pushed or broken with clever use of lesser known features. That said, most of this is probably better done with CSS today. My only professional exposure to SVG was when a pen tester found my predecessor's code had unintentionally allowed them, and that one can do injection attacks from the SVG itself. Of course this was around the time a client discovered SVG worked for them, so I had to make support official and defeat injection attacks. Good times.
- rjinman 1y agoI wrote a game of Tetris in JavaScript with SVG many years ago. It had nice graphics and was smoothly animated. I hadn’t heard of anyone else using SVG like that at the time. I also made a game called Pro Office Calculator (available on Steam), which includes a Doom-style 3D engine for which I used Inkscape as my map editor. Here’s an example of a map: https://github.com/robjinman/pro_office_calc/blob/develop/data/going_in_circles/map.svg https://github.com/robjinman/pro_office_calc/blob/develop/da...
- enduser 1y agoReminds me of Avara which used MacDraw as a level editor. Very cool!
- rorads 1y agoLove this! I think SVG is super underrated, particularly in the age of diffusion based image generation. I’ve written briefly about it here: https://rorads.github.io/technical/quick-ai-reflection-on-svgs/ https://rorads.github.io/technical/quick-ai-reflection-on-sv...
- soup10 1y agoi'll be a contrarian, that css and svg "hacks" like this are "impressive" are a symptom of a web-platform that is dogshit for multimedia. If a game did this nobody would even blink, the fact that it's another convoluted css hack makes it "notable".
- yowzadave 1y agoMaybe I'm in the minority, but I wish there were an similarly popular vector drawing format that did much much less than SVG. Any time you want to support vector drawings in a project, the obvious approach is to support SVG...which basically means you have to bring in the equivalent of a browser. What is the minimal alternative?