liveBook · Manning

Vector image

As explained in D3.js in Action, Third Edition

A vector graphic is an image represented by mathematical descriptions of geometric shapes rather than by fixed pixels.

A vector image describes shapes with math and geometry instead of a fixed grid of pixels. Unlike PNG and JPG raster images, it stays crisp when scaled to different sizes or screen resolutions. section 1.2.2

On the web, SVG makes vector graphics part of the DOM. Individual shapes can be styled, manipulated, animated, and exposed to screen readers; well-built SVG can also use less data than an equivalent raster image. section 1.2.2

SVG vector images are assembled from geometric elements with attributes for position, size, and presentation:

  • Lines, rectangles, circles, ellipses, paths, and text form visible marks. section 1.2.2
  • An SVG coordinate system positions elements, while fill, stroke, stroke-width, and related attributes control appearance. section 1.2.2
  • A viewBox and responsive container let the same coordinate space scale across available widths. section 1.2.2

Shape gallery

Create an SVG with a 900 by 300 viewBox, then place a line, several rectangles, a circle, an ellipse, a curved path, and labels. Group related elements and use translate to move a grouped rectangle and its label together. section 1.2.2

Figure 1.8 Gallery of fundamental SVG shapes that we’ll build in this section
figure

Browse the shape gallery to connect each SVG element type with its rendered result. section 1.2.2

How D3.js in Action, Third Edition covers it

How deep it goes
Explains SVG shapes, coordinates, attributes, grouping, and responsive sizing through a complete gallery.
Examples
Builds a labeled gallery containing lines, rectangles, circles, ellipses, paths, and text.
What it assumes
Starts SVG from zero while using basic HTML markup and attributes.
What you can do after
Build it from scratch as a responsive SVG shape gallery with positioned and styled elements.
How it connects
Connects SVG to raster graphics, the DOM, D3.js, accessibility, animation, viewBox, and SVG paths.

Also explained in

Compare how 2 books explain vector image →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.