Making Shapes with Pixels

How do you draw a circle with squares?

1

The Pixel Grid Challenge

Your screen is a giant grid of tiny squares. Each pixel can only be ONE color - there's no "half a pixel." So how do we make smooth diagonal lines and curves?

Click pixels to toggle them on/off

🔴 The Problem

Pixels are squares arranged in a grid. There's no way to place a pixel "between" grid positions.

💡 The Solution

Smart algorithms choose which pixels to light up so the pattern LOOKS like a smooth line or curve.

📊 Resolution Matters

More pixels = smoother shapes. A 4K display has 8 million pixels to work with!

💡 Fun Fact

The Atari 2600 (1977) had a resolution of just 160x192 pixels - about 30,000 total. Your phone probably has over 2 million pixels!

2

Drawing Lines: Bresenham's Algorithm

In 1962, Jack Bresenham invented an algorithm to draw lines using only simple math (no division!). It's still used today in everything from games to printers.

⚡ Why It's Fast

Only uses addition and subtraction - no slow division or square roots needed!

💪 The Trick

It tracks an "error" value to decide whether to step diagonally or straight.

💡 Fun Fact

Bresenham developed this algorithm while working at IBM on a plotter that could only move in fixed steps - exactly like pixels!

3

Drawing Circles: Midpoint Algorithm

Circles are even trickier than lines! The midpoint circle algorithm uses the circle's symmetry - calculate 1/8 of the circle, then mirror it 8 ways.

🔭 8-Way Symmetry

A circle looks the same from 8 directions. Calculate one octant, mirror it 7 times!

🧮 Perfect Circles?

Mathematical circles have infinite resolution. Pixel circles are always approximations.

💡 Fun Fact

Early video games often used ovals instead of circles because they were faster to draw - and TV screens weren't perfectly square anyway!

4

Anti-Aliasing: Faking Smoothness

See those jagged "stair-step" edges? That's called aliasing. Anti-aliasing adds partially-lit pixels to trick your eye into seeing smoother edges.

Without Anti-Aliasing
With Anti-Aliasing

🎨 How It Works

Pixels near edges get partial brightness based on how much of the "ideal" shape covers them.

👁 Eye Trick

Your brain blends the partial pixels together, perceiving a smoother edge than actually exists.

⚡ Performance Cost

Anti-aliasing requires more calculations, which is why games let you turn it on/off.

💡 Fun Fact

MSAA, FXAA, TAA - these are all different anti-aliasing techniques! Games use different methods depending on speed vs quality needs.

5

Resolution: More Pixels = Smoother Shapes

Watch how the same circle looks at different resolutions. Higher resolution means more pixels to work with, making curves appear smoother.

💾
8x8

Atari-era

💻
16x16

Icon size

🎮
32x32

Retro game

📱
64x64

High detail

64 pixels total - Circle uses ~50 pixels

💡 Fun Fact

A 4K display (3840x2160) has over 8 million pixels! Early Macintosh computers (1984) had only 175,104 pixels.

6

Your Turn: Draw with Algorithms!

Try drawing shapes yourself! Select a tool and click on the canvas to see the algorithms in action.

Click to place pixels

0
Pixels Placed
0
Lines Drawn
0
Circles Drawn

Pixel Master!

You've discovered the clever math behind digital graphics! From Bresenham's lines to anti-aliased circles, now you know how computers turn squares into art.

0
Pixels Placed
0
Lines Drawn
0
Circles Drawn

Pixels Are Squares

Every image is built from a grid of single-color squares

Bresenham's Algorithm

Draws lines using only addition, still used after 60+ years

8-Way Symmetry

Circles are drawn by calculating 1/8 and mirroring

Anti-Aliasing

Partial-brightness pixels trick our eyes into seeing smooth edges

Ready to Create?

Put your new knowledge into practice!

Suggest a Correction