Skip to content

Instantly share code, notes, and snippets.

@Fiewor
Last active December 11, 2021 12:49
Show Gist options
  • Select an option

  • Save Fiewor/4b24064167f879f6d36146723a306266 to your computer and use it in GitHub Desktop.

Select an option

Save Fiewor/4b24064167f879f6d36146723a306266 to your computer and use it in GitHub Desktop.
Notes about SVG using the FrontEnd Masters SVG course

what is svg?

  • scalable vector graphics
  • crisp on any display
  • less requests to handle
  • easily scalable for responsive
  • less file size for performance
  • easy to animate. has a navigable DOM
  • easy to make accessible
  • well supported across browsers
  • great for loaders
  • we can use the stablility of svg for page transitions

SVG anatomy overview

overview of the svg DOM

  • think of it as drawing on the points of a graph paper
  • viewBox
  • a lot of things in the DOM have the pattern of: x-coordinate y-coordinate width height <svg viewBox="0 0 450 100"></svg> svg {width:450px;}
  • preserveAspectRatio
  • Polyline - very similar to Polygon.
  • Space seperated X,Y values

Groups

  • g in svg is like a group(div) - used to group mulitple objects

  • use groups to move multiple things at once

  • you can add classes to groups <g fill="none" stroke="#000"></g>

    • a 'z' at the path is what closes a path
  • always has 'M' for moveTo image Capital letter is for absolute position Small letter is for relative position (e.g. 30 units relative to a particular point) image

  • Limitations of cubic bezier: only has 2 control points

  • Template Literals + SVG Path Points = ❤ image Accessibility image role="presentation" or role="image"if you don't want the screen reader to read it cause it's juist for visual purposes

CSS Animation

  • use SVG filter in place of drop shadows

Resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment