Skip to content

Place a point

  • The Craft

A position answers two questions: how far across, and how far up? Move the point using its coordinates before we ask it to travel.

Drag in the picture or use the labelled inputs and sliders. Grid squares span 25 world units. This is a mathematical model running in your browser.

Choose an origin

The crossing of the axes is our origin: (0, 0). Coordinates are written (x, y), with the horizontal value first. A point at (120, 90) lies 120 units right of the origin and 90 units above it. These are world units; resizing the picture does not change the point’s position.

Make X negative while leaving Y at 90. The point crosses to the left, but stays at the same height. Now make Y negative too. The signs tell us which side of each axis contains the point.

Position and movement

A position is where something is. A displacement is the change from one position to another. To get from (20, 30) to (120, 90), subtract start from finish: Δx = 120 − 20 = 100 and Δy = 90 − 30 = 60. The symbol Δ means “change in”.

From (120, 90), move 30 units left and 50 units down. Where will the point end up?

Show the explanation

(90, 40): add −30 to X and −50 to Y. A negative change does not necessarily produce a negative position.

Set that result using the controls. If a point moves in the wrong direction, check the coordinate order and the signs. Many screen APIs count Y downwards; this experiment keeps world Y upwards and reverses it only when drawing.

Put the point in display memory

The Pattern Library’s pixels, spans and boxes turn coordinates into actual Spectrum, BBC Micro and Dragon bitmap addresses. Integer division chooses a byte; the remainder chooses a bit. The routines count Y down from the top left, so keep that screen position distinct from the upwards world Y used here.

Writable characters gives a second example: local dot (3,5) inside cell (2,2) becomes screen pixel (19,21). The machine entries explain the arithmetic alongside reusable code, so you can try either direction: use the maths to understand the routine, or use a visible routine to give the maths a purpose.

Draw with integer error takes the next step: choose dots for a line or curve, keep rounding consistent, then turn an edge into row spans. Its machine routines include CPC packed colour alongside the three monochrome backends.

Move a glyph, keep its shape takes coordinates into reusable bitmap text: translate local dots, retain advance when clipping, and account for byte boundaries.

Follow the same point through linear Atom rows, Electron interleaving, C64 bitmap colour cells and an Amiga Chip RAM plane. The point stays (x,y); the address and the ownership rules change.

A coordinate meets a console

The Atari 2600 playfield gives each independent cell four colour clocks of width and eight scanlines of height. Point (13,19) maps to cell (3,2), with local remainders (1,3). Repeating or reflecting that half-picture changes the image without allocating another independent half.

The Atari 7800 object builder keeps a different distinction: a glyph’s local x3 placed at object x32 appears at logical x35. A capture can add overscan and double horizontal pixels, so capture coordinates and game coordinates need not match.

An offset needs an origin

A five-code 8-pixel label needs 40 pixels. Inside a 177-pixel panel, 137 remain. Integer division gives 68 on the left and 69 on the right. If the panel begins at x21, the label begins at 21+68=89, not x68. Check that the label fits before subtracting: unsigned underflow is not a layout policy.

The bounded text-layout routines apply that calculation on Spectrum, BBC Micro, Dragon and CPC, with native examples of both a wrong width and a forgotten origin.

The word-aware bitmap-text variant uses integer cell capacity to choose a line break, then translates each aligned line into screen coordinates. Its examples show where preserving a word changes the number of rows.

The proportional text variants sum a width and spacing for each glyph. Six narrow letters can take less room than six wide ones. Use that same sum for centring, wrapping and the next drawing position; a fixed step in just one of those paths makes the visible result disagree with the calculation.

The integer-enlarged glyph routines turn one font pixel into a rectangle. Multiply source coordinates by the scale to place it; divide a destination-local coordinate by that scale to find its source pixel. Add the cell origin before clipping, so a cut-off letter keeps the same sampling phase.

The glyph shrinking routines apply this directly: a five-pixel output samples columns 0,1,3,4,6 from an eight-pixel source. The machine code uses an error accumulator; division gives an independent way to check it. The entries also show which details can disappear and why cropping is a different operation.