One rectangle, four masks

The same flat rectangle four times over, each under a different stencil — a gradient fade, darkened edges, letters cut through it, a stencil read from transparency — and a band that fades out with a label painted whole inside it.

A soft mask is a drawing built apart from the page and never shown: it works as a stencil. Where it comes out light, what you paint goes through whole; where it comes out dark, nothing does. It is how a fade stops being a stack of nearly transparent rectangles.

Four panels are painted exactly the same way — one flat rectangle each — and differ only in the stencil in force: a gradient fade, darkened edges, letters cut through the fill, and a stencil read from transparency rather than from lightness. At the foot, a band fades out under a label that stays whole inside it.

What this example shows

  • Stencils read from lightness and stencils read from transparency, both shown.
  • A fade and darkened edges, from a gradient used as a stencil.
  • Text cut out of a fill with a stencil rather than with a cut-out.

The code, in full

The same document is written twice, once in each language. Both files are shown in full, with the code coloured on the server, and can be copied in one click.

The document itself

The same document is written in each of these languages. Open the one you want to look at.

Open the document in English Open the document in French

Read the Rust source Read the Python source

First page of One rectangle, four masks

What this document weighs

Before 114,195 bytes
Now 43,774 bytes
Saved 61.7 %

Not one mark on the page changed. See every document measured.

Examples near this one

Cutting out what you draw

A field of stripes shown through two cut-outs: a disc from the nonzero rule, and a frame from the even-odd rule over two nested rectangles.

Transparency and blend modes

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

Gradients in a line and in a circle

Gradients in a line and in a circle painted into boxes the page cuts out: a two-colour blend across and another on the diagonal, a circular one whose outer colour is carried out to the corners, and one passing through three colours.

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.

Content shown and hidden by layer

One floor plan on four layers a reader shows and hides: the furniture and the dimensions shown, the notes hidden until asked for, and a draft mark that is looked at but never printed.

One drawing, placed many times

One badge built as a drawing and placed eight times, plus once at half size: the file holds the drawing once, however many times it is placed.

Every example, by subject