Transparency and Blend Modes

A watermark that hides the text under it is useless, and a highlight that is not see-through is a blot. Both want the same thing: paint that lets what is underneath come back through, by a stated amount, without anybody having to work out what the mixed colour would be and paint that instead.

The other half of the page is about what happens when one colour lies over another, and there are four answers to pick from. They stand on the page under the names every drawing program knows them by. Normal simply covers: the square hides the bar, and that is what is wanted nearly all the time. Multiply darkens — it is exactly how a highlighter pen behaves on paper, which makes it the one to reach for when the words underneath have to stay readable. Screen does the opposite and lightens, for a glow or a pale wash over a dark photograph. Difference is the odd one out and serves checking rather than design: lay two versions of the same page over each other and everywhere they agree comes out black. All four are on the page below, the same orange square over the same blue bar each time, with the name of the mode beside it. Whichever is set holds for everything drawn after it until it is taken back off, so a watermark can be laid across a whole page without touching a word of what is under it.

At the foot of the page the same line is written twice at half strength, each letter crossed by a stroke that lies over it. On the left the line is painted as one piece, so where a stroke crosses its letter the colour goes down once and stays as light as the rest. On the right each shape is painted on its own, and every crossing comes out darker, the way two strips of tinted film do where they overlap. Not every reading program honours the difference: one that does not shows the two lines alike.

What This Example Shows

  • Half-transparent fills overlapping, so the colours show through.
  • The same square over the same bar, mixed four different ways.
  • The same crossed letters twice, painted as one piece and one by one.

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 Open the document in German Open the document in Spanish Open the document in Italian Open the document in Portuguese

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.

Overlaps Mixed in Linear Light

A page that asks for its half-transparent colours to be mixed in linear light: two pairs of overlapping discs, each beside the colour its overlap should take and the one it takes when the request is ignored.

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, a panel filled with a circular one that lets the page show through, and a band whose blend is stood upright and whose border is painted with the 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