--- theme: ./theme class: text-center highlighter: prism lineNumbers: true info: | ## Slides for Intro to SVG L&L drawings: persist: false download: true layout: intro title: Intro to SVG --- # Intro to SVG
Let's start
--- layout: presenter presenterImage: 'https://pbs.twimg.com/profile_images/1441783883456942080/vV37mSqv_400x400.jpg' --- # Estee Tey - 💻 Grad Software Developer at Thoughtworks - ✏ Writes about Web Dev, UI, Dev growth - 🎨 Experienced in creating mockups & graphics
lyqht
estee_tey
--- # Expectations

No Prerequisites

expect(target_audience).toBeAny()

Your time to be worth it

expect(🍚⏱).toYield(✅)

Learn something

expect(🧠).toIncrease();

Have fun thinking

expect(🤔).andThen(😄)
--- # Table of Contents 1. What is SVG? 2. Why do we use SVG? 3. How do we get SVG? 4. How to use SVG? --- layout: center class: text-center --- # What is SVG? --- layout: center class: text-center --- # Images
Story Time!
---
---
--- ---
--- --- # Raster vs Vector Images ![raster vs vector images](https://vector-conversions.com/images/vector_vs_raster.jpg) --- # Image File Types | File Extension | Description | | --------------------------------------- | ---------------------------------------------------------------- | | .gif | Graphics Interchange Format | | .png | Portable Network Graphic | | .jpg / .jpeg | Image format by Joint Photographic Experts Group | | .webp | A superior image format of .png & .jpg | | .svg | Scalable Vector Graphics | --- # Image File Types | File Extension | Color Modes | Compression | Usage | | --------------------------------------- | ------------------------------------------------------ | --------------------------- | ---------------------------------------------------------------- | | .gif | Indexed Color | Lossless | Animated images | | .png | Greyscale, True Color, Alpha | Lossless (better than .GIF) | Static Line art, iconic graphics where transparency matters. | | .jpg / .jpeg | True Color | Lossy | Photographs, realistic images of people, venues etc. | | .webp | Depends on compression | Lossless / Lossy | A superior image format of .png & .jpg | | .svg | Anything that can be specified using CSS color syntax. | NA | UI that requires to be redrawn accurately at different sizes | --- # How to get SVG 1. Create SVG from scratch 2. Generate SVG 3. Extract from websites --- layout: center class: text-center --- # Create SVG with 3 basic elements `` `` ``
Code Time!
--- # Create SVG with 3 simple shapes in code --- layout: new-section logoHeader: '/intro-to-svg-slides/terminal-box-fill.svg' --- # JP flag in SVG
```html {all} ```
--- layout: new-section logoHeader: '/intro-to-svg-slides/terminal-box-fill.svg' --- # TH flag in SVG
```html {all} ```
--- layout: new-section logoHeader: '/intro-to-svg-slides/terminal-box-fill.svg' --- # VN flag in SVG
```html {all} ```
--- layout: new-section logoHeader: '/intro-to-svg-slides/terminal-box-fill.svg' --- ## Polygon vs Polyline
```html {all} ```
```html {all} ```
--- layout: new-section logoHeader: '/intro-to-svg-slides/terminal-box-fill.svg' --- # SG flag in SVG
```svg {all} ```
--- layout: center class: text-center --- # Create SVG with Design Tools
--- layout: center class: text-center --- # Figma Demo Ellipse, Polygon, Paths, Bezier Curves --- layout: new-section logoHeader: '/intro-to-svg-slides/terminal-box-fill.svg' --- # Setting SVG File as an image source
```html ```
--- layout: new-section logoHeader: '/intro-to-svg-slides/terminal-box-fill.svg' --- # Setting SVG File as an image source
```html ``` ```css .special-image { height:240px; animation:spin 4s linear infinite; } @keyframes spin { 100% { transform:rotate(360deg); } } ```
--- # Generate SVG
1. Squicley for generating Squircles
--- # Generate SVG
2. SVGBackgrounds.com for generating backgrounds
--- # Extract from websites Demo with [Hacktoberfest's SVG](https://hacktoberfest.digitalocean.com/) > P.S. If you use any extracted images for your own websites or apps, please remember to give **attribution**. --- # Bonus: Optimization of SVG [SVGOMG](https://jakearchibald.github.io/svgomg/) --- # Bonus for React Devs: convert from SVG to JSX [SVG to JSX Demo](https://svg2jsx.com/) --- # Summary 1. What is SVG? 2. Why do we use SVG? 3. How do we get SVG? 4. How to use SVG? --- # SVG Element Cheatsheet | | Shape | Usage Example | | --- | --------- | ---------------------------------------------------------- | | 1. | Square | `` | | 2. | Rectangle | `` | | 3. | Circle | `` | | 4. | Ellipse | `` | | 5. | Polygon | `` | | 6. | Polyline | `` | --- # Topics for you to explore more - More complex SVG elements such as patterns, filters, paths - Accessibility of SVGs - Performance of SVGs --- # More Resources - [MDN Web Docs on SVG](https://developer.mozilla.org/en-US/docs/Web/SVG) - [CSS Tricks - how to scale SVG](https://css-tricks.com/scale-svg/) - [Smashing Magazine - SVG Generators](https://www.smashingmagazine.com/2021/03/svg-generators/) - [Frontend Masters - SVG Essentials & Animations v2](https://frontendmasters.com/courses/svg-essentials-animation/?utm_source=css-tricks&utm_medium=website&utm_campaign=css-tricks-tags-sidebar) --- # Thank you! Hope you enjoyed the L&L 😄 Any questions? -- [Feedback form](https://forms.gle/HQ8JoEL3MuESbbVP9)