One colour, seen through four stencils

A photograph that fades away towards the foot of a cover page. A banner whose edges darken. A word cut out of a block of colour, the way a stencil cuts a shape out of card. Those three effects are usually made in a drawing program and pasted in afterwards as a picture — and a picture is heavy, shows where it stops when the page is printed, and has to be made all over again the day the colour changes. Here they are drawn inside the document instead: the same block of colour, shown four times, seen through four different stencils.

The first stencil fades from one side to the other, which is what a photograph needs when it has to run under a headline with no line where it stops. The second is clear in the middle and dark at the edges, which is how a picture is made to hold the eye on the face in it. The third is cut through two words, so the colour shows only inside the letters — a title takes the colour of whatever is behind it, and no picture is pasted in. The fourth is read not from light and dark but from how see-through the stencil itself came out, which is what lets something you have already drawn become the stencil for what comes next. Under the four runs a band that fades out with a label painted whole on top of it: the stencil stops where you say it stops.

What this example shows

  • The same block of colour four times, and nothing changing but the stencil over it.
  • A fade and a darkened border, both cut from a gradient.
  • Two words cut clean out of a block of colour, with no picture in 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 colour, seen through four stencils, first page

Optimised, this document weighs 16.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.

Text and shapes filled with a gradient

A gradient used as the colour something is filled with: a headline whose letters are windows onto a blend of three colours, and a panel filled with a circular one.

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