One drawing, placed many times

A logo on every page of a two-hundred-page document is the same drawing two hundred times. Written out in full each time, that is two hundred copies of the same instructions inside the file, and a document far heavier than it has any reason to be — which is noticed by whoever has to send it, never by whoever made it.

Here the name badge is described once and placed eight times, plus a ninth at half size, and the file carries one copy of it however many times it appears. Only the names differ from one badge to the next, so the names are drawn on the page over the badge rather than inside it. That line is the whole trick: keep everything that varies outside the shared drawing, and one copy goes on serving every badge on every page.

What this example shows

  • A drawing described once, then placed by naming it and saying where.
  • The same drawing placed at another size without describing it again.
  • Varying text drawn over the shared drawing, not inside it.

The source code, complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library. The third is the description itself: a plain list of what the page has to say, which is what the service is sent.

Read the Rust source Read the Python source Read the JSON source

The document itself

Open the document in English Open the document in French

One drawing, placed many times, first page

Optimised, this document weighs 13.4 kB — at least 85 % lighter than most PDF generators would write it

The document is lighter than it was, and every page still looks exactly the same. See this document's row in the table of every example.

Examples near this one

Cutting out what you draw

The same area of stripes shown through two windows: a plain disc, and a ring whose middle is left bare.

Transparency and blend modes

Half-transparent fills that overlap and mix, one orange square laid over a blue bar in four different ways of mixing colours, and a line of overlapping letters painted two ways.

Gradients in a line, in a circle, and read from a function

Five panels: a header that fades out, the same fade on the diagonal, a glow carried past its own circle so the corners fill, a blend that goes by way of a third colour, and a checkerboard whose colour is worked out from where each point stands, redder to the right and greener towards the top.

Four kinds of mesh, every corner its own colour

Six triangles round a centre they share, their edges stroked over the paint; a lattice of points in the four printing inks; a patch whose four sides are curves; and the same patch pulled about by four points inside it.

Every example, by subject