←back to thread

An SVG is all you need

(jon.recoil.org)
258 points sadiq | 3 comments | | HN request time: 0.515s | source
1. WorldPeas ◴[] No.46235993[source]
all we need is keyboard input and audio output and we have (most of) flash back. I may have to look into this in my idle hours
replies(2): >>46236509 #>>46236631 #
2. fragmede ◴[] No.46236509[source]
JavaScript to catch keypress events and edit the SVG in situ maybe?
3. zamadatix ◴[] No.46236631[source]
The magic here is happening via the <script> tags, where you have access to the browser APIs like you would an <canvas> instead of <svg>. E.g. here's a sample I forked following the mouse using <svg> with <script> inside https://codepen.io/zamadatix/pen/emZXZKx?css-preprocessor=sc...

Libraries like three.js had SVG rendering as an option but it got deprecated as <canvas> with more direct GPU APIs was a lot more efficient and flexible.