Basic Shape

Let's learn how to draw basic shapes.

SVG attributes

pathLength

Changes how the path length is computed. Instead of using the actual computed length, force the computer to use this number.

| LIVE PREVIEW

SVG elements

<circle>

  • cxcenter x (specify length or percentage)
  • cycenter y (specify length or percentage)
  • rradius (specify length or percentage)
  • pathLengthwhen drawing the stroke, assume the circumference of the circle is this number (this won't change the size of the circle)
| LIVE PREVIEW

<ellipse>

  • cxcenter x (specify length or percentage)
  • cycenter y (specify length or percentage)
  • rxradius in the x-axis (specify length or percentage)
  • rxradius in the y-axis (specify length or percentage)
  • pathLengthwhen drawing the stroke, assume the circumference of the ellipse is this number (this won't change the size of the ellipse)
| LIVE PREVIEW

<rect>

  • xtop-left x coordinate (specify length or percentage)
  • ytop-left y coordinate (specify length or percentage)
  • widthwidth (specify length or percentage)
  • heightheight (specify length or percentage)
  • rxhorizontal corner radius of the rectangle (specify length or percentage, takes the value of ry if it's specified)
  • ryhorizontal corner radius of the rectangle (specify length or percentage, takes the value of rx if it's specified)
  • pathLengthwhen drawing the stroke, assume the perimeter of the rectangle is this number (this won't change the size of the rectangle)
| LIVE PREVIEW

<polygon>

  • pointsspace-separated x,y coordinates of the polygon (only accepts numbers for both x and y)
  • pathLengthwhen drawing the stroke, assume the perimeter of the polygon is this number (this won't change the size of the polygon)
| LIVE PREVIEW

<line>

  • x1starting x coordinate (specify length or percentage)
  • y1starting y coordinate (specify length or percentage)
  • x2ending x coordinate (specify length or percentage)
  • y2ending y coordinate (specify length or percentage)
  • pathLengthwhen drawing the stroke, assume the length of the line is this number
| LIVE PREVIEW

<polyline>

Creates an open shape (unlike <polygon>).

  • pointsspace-separated x,y coordinates of the polyline (only accepts numbers for both x and y)
  • pathLengthwhen drawing the stroke, assume the length of the polyline is this number
| LIVE PREVIEW

References