<style> .reveal section img { background: rgba(255, 255, 255, 1) } </style> ![](https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg =300x) ## Intro to fundamentals _Doug, 2020-03-29_ --- # SVG **S**calable **V**ector **G**raphics --- # A .png graphic ![](https://codi.kanthaus.online/uploads/upload_735a4671826f46a4f3894c324b64066f.png =300x) --- # A .svg graphic ![](https://codi.kanthaus.online/uploads/upload_63ff99ec3db862f4d686557275a8e343.svg =300x) --- # So what's the big deal? Those looked the same... :mag: <!-- Let's look a bit closer... Go back and download both images Zoom in, note fuzziness... --> --- # Scalability SVGs can be zoomed or shrank to any level without losing quality! ![](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Bitmap_VS_SVG.svg/500px-Bitmap_VS_SVG.svg.png =300x) <p class="fragment" data-fragment-index="1"> <b>How?</b> </p> --- # Raster graphics (e.g. .png, jpg, etc) ![](https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fs3.amazonaws.com%2Fimages.coplusk.net%2Fproject_images%2F150888%2Fimage%2F2013-03-30_17.14.57.jpg&f=1&nofb=1 =400x) <!-- From Latin, 'to rake' Each pixel defined Zooming/shrinking: algorithmic predictions --> --- # Vector graphics ![](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse3.mm.bing.net%2Fth%3Fid%3DOIP.6hqcRX1uCPqgY8kv4xlH8QAAAA%26pid%3DApi&f=1 ) <!-- Note file sizes Open up svg in notes viewer Add fill:red; and see desktop icon change Delete some random bit of the path --> --- # Vector > Raster - for 'designed' images - smaller file size - fully scalable without loss - easily modified - supported by 'all' web browsers... --- # SVG **S**calable **V**ector **G**raphics (Question break) --- # SVG history > SVG was developed by the W3C SVG Working Group starting in 1998, after six competing vector graphics submissions were received that year —[wikipedia](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) --- # [XKCD 927](https://xkcd.com/927/) ![](https://imgs.xkcd.com/comics/standards.png =700x) --- # SVG versions - [1.0](https://www.w3.org/TR/SVG10/), Sept 2001 - [1.1](https://www.w3.org/TR/SVG11/), Jan 2003 - ... - [2.0](https://svgwg.org/svg2-draft/), reached Candidate Recommendation stage Sept 2016. Last update Feb 2020! --- # Hands on! <!-- Open basic.svg with image viewer on left, geany on right Add fill red Add cx, then cy Add height, width --> --- # SVG editor - Because you might want to see what you're drawing - Inkscape seems to be the default FLOSS editor ![](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F4%2F4a%2FInkscape.logo.svg%2F480px-Inkscape.logo.svg.png&f=1&nofb=1 =200x) <!-- Make a smiley! --> --- ## Let's head to the web... Browser as SVG viewer <!-- Serve presentation directory --> --- # Inline --- # Inline ### Good - All in one - Can style everything! ### Bad - All in one - No caching --- # `<img>` --- # `<img>` ### Good - External - Familiar ### Bad - No styling :disappointed: --- # (Not recommended) - `iframe` (introduces page separation) - `background-image` (no interactivity) - `embed` (not actually part of x/html) - `object` (DOM separated) --- # 'SVG fragment identifiers' --- ## Fragment identifiers ### Good - External - Can style everything! - Can have all SVGs in one file (sprite) ### Bad - Not quite as slick as `<img>` - Requires id definition --- # Hands on! (question break) --- # Going further... viewport, viewBox & preserveAspectRatio --- # 2 Lands ### Vectorland An infinite coordinate plane where SVG is drawn ### Browserland Finite window space on finite device --- # Working backwards I have an SVG image I want to display it in my browser I want it to be 200 X 200 px
{"title":"SVG knowledge sharing","tags":"svg, web,","date":"2020-03-29T00:00:00.000Z","type":"slide"}