dtstudent.com · Virtual DT Workshop

Raster vs vector graphics

Open the interactive version →

← Concepts

PIXELS OR MATHS?

Every picture on a screen is stored in one of two ways. Zoom in to find out which.

Why does a logo stay sharp on a giant banner, but a phone photo goes blocky when you zoom right in?

The photo is a raster image: a fixed grid of coloured squares (pixels). Zooming in just makes each square bigger. The logo is a vector image: it is stored as points, lines and curves (maths), so the computer redraws it sharply at any size.

TWO WAYS TO STORE A PICTURE

Raster and vector

A grid of tiny squares called pixels. Each pixel stores one colour as three numbers: how much red, green and blue. More pixels means more detail, and a bigger file.

Photos, scans, screenshots, paintings in apps such as Photoshop, GIMP and Procreate.

A list of instructions: points (called nodes or anchor points), the lines and curves that join them, and the colours to fill and outline them. The computer works out the pixels each time it draws the picture.

Logos, fonts, icons, laser-cut parts, made in apps such as Illustrator, Inkscape, CorelDRAW and 2D Design.

TRY IT

The zoom lab

The same light bulb, stored both ways. Zoom in, then drag either picture to look around.

Raster 32 × 32 pixels = 1024 pixels × 3 numbers = 3.0 KB

Zoom in and point at a pixel to see the numbers it stores.

Vector 5 paths, 31 nodes = 945 bytes of text

Zoom as far as you like: the edges stay sharp, because the curves are redrawn from their numbers.

Why does "Smooth the pixels" look blurry?

Smoothing guesses in-between colours by blending neighbouring pixels. It hides the blocks, but it cannot add detail that was never stored, so the picture just goes soft. The only real fix is a higher-resolution image, or a vector.

INSIDE A VECTOR

A curve is just four points

This whole curve, as it is stored in an SVG file: <path d="M 40 215 C 80 40, 300 30, 360 215" />

How does the computer find each point on the curve?

It slides a value t from 0 (the start) to 1 (the end). For each t it finds the point that fraction of the way along each grey line, joins those points (green), does the same again (orange), and again, until only one point is left: that point is on the curve. Use the slider to watch it. This is called a Bézier curve, after Pierre Bézier, an engineer who used it to design car bodies at Renault in the 1960s.

B(t) = (1 − t)³P₀ + 3(1 − t)²t P₁ + 3(1 − t)t² P₂ + t³P₃

OBJECTS, NOT PIXELS

Stacking order (z-order)

In a vector drawing every shape is a separate object, stacked one above another. Pick a shape (tap it or use the list), drag it, and change its place in the stack.

LAYERS (front first)

COMBINING SHAPES

Union, subtract, intersect, exclude

Union joins the shapes into one outline: everything inside either shape.

Challenges: can you make these?

In 2D Design, Inkscape and Illustrator these are called union / weld, subtract / difference, intersect and exclude / XOR. In 3D CAD (Fusion, Onshape, Tinkercad) they are join, cut and intersect: modelling by combining solids this way is called constructive solid geometry.

Side by side

RasterVectorMade of
A grid of pixels, each one colourPoints, lines, curves and fills (maths)
Enlarging
Goes blocky or blurry
Stays sharp at any size
Detail
Good for photos, textures and subtle shading
Best for flat colours, clean shapes and text
File size
Grows with the number of pixels
Grows with the number of shapes, usually small
Editing
Paint and erase pixels; shapes cannot be picked up again
Every shape can be moved, resized, recoloured or reshaped
File types
JPEG, PNG, GIF, WebP, HEIC, TIFF
SVG, PDF, AI, EPS, DXF
In the workshop
Laser engraving photos, mood boards, textures for renders
Laser cutting and scoring, vinyl cutting, CNC routing, logos

Resolution: pixels per inch

Resolution is how many pixels fit in a length. Printing usually needs about 300 pixels per inch (ppi, often called dpi) to look sharp, so a photo that looks fine on screen can print blocky if it is enlarged. Camera resolution is given in megapixels: a 12-megapixel photo is about 4000 × 3000 pixels.

Converting between them

Vector to raster (rasterising) is easy and always works: the computer just works out the pixels. Every screen and printer does this whenever it shows a vector, because screens are grids of pixels too. But once saved as pixels, the shapes cannot be edited as objects again.

Raster to vector (tracing or vectorising) is harder. Tools such as Inkscape's Trace bitmap or Illustrator's Image trace find the edges between colours and draw curves along them. It works well for bold sketches and logos, but photos turn into thousands of shapes. A good trick for laser cutting: draw your design in thick black pen, scan it, trace it, then tidy the nodes. Inkscape tutorials ↗

SORT IT

Raster or vector?

Choose for each one.

NOW AND NEXT

Cutting-edge computer graphics

Raster and vector are still the two ways to store a flat picture, but the tools built on them are changing fast. A twist: when a graphics card draws a 3D model, it turns each triangle into pixels. That step is also called rasterisation.

One ray for each pixel: from the camera to the object, then towards the light to check for shadow. Image: Henrik, CC BY-SA 4.0 (licence), via Wikimedia Commons

Left: the small original. Right: the AI's guess at a version four times bigger. Image: PantheraLeo1359531, CC BY 4.0, cropped (licence), via Wikimedia Commons

The AI starts from random noise and removes a little more of it at every step. Image: Benlisquare, CC BY-SA 4.0, rearranged (licence), via Wikimedia Commons

First step of a scan: the software works out where each photo was taken from (each pyramid is one camera). Image: Colin Kranz, CC BY-SA 4.0 (licence), via Wikimedia Commons

One font file, with every style in between its extremes. Image: Stephen Nixon, SIL Open Font Licence (licence), via Wikimedia Commons

Resolutions drawn to scale: each newer standard packs in far more pixels. Image: TRauMa, CC0 (licence), via Wikimedia Commons

The 3D tools and machines on this site are drawn live in your browser by your graphics card, using WebGL: vector-style 3D models turned into pixels many times a second.

Key words

Pixel

One square of colour in a raster image (from "picture element").

Raster (bitmap)

An image stored as a grid of pixels.

An image stored as points, lines, curves and fills.

Resolution

How many pixels an image has, or how many fit in an inch (ppi / dpi).

Node (anchor point)

A point on a vector path where a line or curve starts or ends.

Bézier curve

A curve set by end nodes and handles (control points).

Z-order

The stacking order of objects, from back to front.

Boolean operations

Union, subtract, intersect and exclude: combining shapes into new ones.

Rasterise / trace

Turn a vector into pixels / turn pixels into vector paths.

See it in use: CAD/CAM → Laser cutter → Sketching →

Related topics

Open the interactive version →