click_extra.logo module¶
Terminal rendition of the Click Extra brand mark.
The mark of docs/assets/logo-square.svg is six cubes stacked three-two-one. Here
they are rebuilt as flat shaded solids, with one color per face and no outline
anywhere, and painted with half blocks, two sub-pixels to a terminal line.
Flat faces are what let one palette serve a light terminal and a dark one. An
outlined mark carries its shape in the outline, so every stroke has to out-contrast
whatever sits behind it, and the artwork’s own palette spans too wide a range for
that: six of its colors vanish on white, two more on black. A flat mark carries its
shape in the difference between its three planes, which no background can touch,
leaving only the silhouette to keep its distance. That fits comfortably in the middle
of the range, which is where FACE_COLORS sits.
Caution
The mark’s structure is carried by color: strip the ANSI codes and it collapses
into one silhouette. VersionScreen therefore only draws
it where color reaches the output, falling back to the plain --version line
everywhere else, which is also the form machine readers parse.
- click_extra.logo.TAGLINE = 'Drop-in replacement for Click and Cloup'¶
What the project is, spelled out under the program name.
- click_extra.logo.UNIT = 2¶
Scale of the whole mark, in sub-pixels.
Every dimension is a multiple of it, so the mark is
12 * UNITcolumns wide and5 * UNITlines tall. Two is the largest that still seats the mark beside the version screen’s facts inside eighty columns: 24 columns of mark, three of gutter and fifty of facts comes to 77. Three would need 89, and the screen would decline to draw itself on any standard terminal.
- click_extra.logo.LEVELS: tuple[tuple[int, int], ...] = ((0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0))¶
Each cube’s (row, column) up the pyramid, bottom row first.
Also the order
FACE_COLORSis written in, and the order the mark is painted in: a cube resting on two others has to be laid down after them.
- click_extra.logo.BRAND_HUES: tuple[int, ...] = (41, 94, 306, 279, 210, 156)¶
Each cube’s hue in degrees, in
LEVELSorder.Read off the ribbon that outlines each cube’s top face in the artwork. The mark has no per-cube hue of its own: cube one alone carries gold, green and olive across its six ribbons. So this is a reading of the artwork rather than a recovery of it. It keeps the terminal mark recognizably the same six colors people already associate with the logo, which an evenly spaced spectrum would not.
- click_extra.logo.SATURATION = 0.62¶
HLS saturation shared by every face. Vivid enough to tell six hues apart.
- click_extra.logo.PLANE_LUMINANCE: dict[str, float] = {'l': 0.13, 'r': 0.22, 't': 0.36}¶
WCAG relative luminance per plane: the lid, then the two walls.
Chosen as a band rather than per color, so every hue is equally far from both backgrounds. The floor of the band is what the mark shows against white and the ceiling what it shows against black, which is why it sits in the middle: the widest band tried reads beautifully on black and falls to 1.74:1 on white.
The 2.25:1 it leaves between a cube’s lid and its dark wall is well past what an eye needs to see a facet, and it survives every dichromacy, planes differing in luminance alone.
- click_extra.logo.FACE_COLORS: tuple[dict[str, str], ...] = ({'l': '#7F611E', 'r': '#A37B26', 't': '#CB9A30'}, {'l': '#40721B', 'r': '#519122', 't': '#66B52A'}, {'l': '#AD28A1', 'r': '#D344C6', 't': '#E17FD8'}, {'l': '#9730CC', 'r': '#AE5ED9', 't': '#C58CE4'}, {'l': '#2767A8', 'r': '#3985D0', 't': '#70A7DD'}, {'l': '#1B724F', 'r': '#229265', 't': '#2BB87F'})¶
Each cube’s three face colors, in
LEVELSorder.Derived, not picked: every entry is its cube’s
BRAND_HUEShue atSATURATION, taken to the luminance its plane declares inPLANE_LUMINANCE. Written out rather than computed at import so the palette stays greppable and a designer can hand-tune one value;test_palette_follows_its_derivationfails if a tuned value drifts off the system.Emitted as 24-bit color. The 256-color cube cannot separate all eighteen, and the usual reason to prefer it does not apply: no touching pair of faces collides there, so a terminal that downsamples still shows six distinct cubes.
- click_extra.logo.geometry()[source]¶
One cube’s dimensions, in sub-pixels.
A lid four units wide and two tall is 2:1 dimetric, and the smallest such rhombus whose half-height is a whole number, which the row pitch needs. The body matches the lid’s width over two, making every box a true cube.
- click_extra.logo.LOGO_WIDTH = 24¶
Columns the mark occupies.
- click_extra.logo.LOGO_LINES = 10¶
Terminal lines the mark renders to, two sub-pixel rows making one.
- click_extra.logo.faces()[source]¶
Every visible face, bottom row first, as whole-sub-pixel polygons.
2:1 dimetric rather than the artwork’s 30 degrees, and integer vertices rather than a sampled rendering, for the same reason: a 30-degree edge advances 1.732 sub-pixels per row, which no grid can hold, so it comes out as a stair of uneven treads that the eye reads as fraying. Two across for every one down tiles a square grid exactly, and every tread is then the same.
- click_extra.logo.sub_pixels()[source]¶
The mark as a grid of flat colors, hit-tested against the face polygons.
Rasterizing the mark and reading pixels back would hand the antialiaser a say in the palette: every boundary it smooths mints a color belonging to neither face, and a rendition this size comes back carrying over a hundred of them. Testing each sub-pixel’s centre against the polygons keeps it to the eighteen declared, three per cube, which is what makes the edges read as steps rather than smudge.
- click_extra.logo.render_logo()[source]¶
Paint the mark into styled lines, each exactly
LOGO_WIDTHwide.A cell whose two sub-pixels carry different colors paints the top one as foreground over the bottom one as background, which is what fits two independent colors on one line. Runs of cells sharing a color pair are styled together rather than one escape sequence per character, keeping the mark from tripling in size.
Trailing blanks are kept:
VersionScreenpads a ragged logo for us, but a mark that arrives square costs it nothing to measure.Cached: the mark never changes, so it is painted on the first call that needs it and read back by every later one.
- click_extra.logo.brand_facts()[source]¶
The interpreter and platform every screen reports, plus this project’s own.
- click_extra.logo.BRAND_SCREEN = VersionScreen(logo=<functools._lru_cache_wrapper object>, tagline='Drop-in replacement for Click and Cloup', facts=<function brand_facts>, gutter=' ')¶
Click Extra’s own
--versionscreen.Mounted on the
click-extraCLI, and the shape a CLI of your own would copy:from functools import partial from click_extra import group from click_extra.commands import default_params @group(params=partial(default_params, screen=BRAND_SCREEN)) def cli(): pass
Both
render_logo()andbrand_facts()are passed uncalled, so the mark is painted and the facts are read when--versionis drawn, not when this module is imported: the habit that keeps a costlier value from being charged to every invocation. The mark is then cached, since it never changes.