v7.2.0: Palettes and #auto!
This version brings the long-awaited (at least by myself) color palette system!
Before that, the new #auto TIM pseudo-tag deserves a mention. It makes the parser look at the currently applied background color, and it is replaced with a color that properly contrasts it while parsing! This way, [alias #auto]Text, will always be legible, regardless of the meaning of alias. It is also automatically used by all widget styles (whenever there is no foreground specified), so you can just define a style as @surface+1, and PTG will make sure it looks nice and readable!
Anyways, the palette. Here is the gist of it:
- The new module
palettesprovides aPaletteclass - This class can generate mashing colors from just one primary color input, with multiple possible strategies
- The whole module now has a default palette that can be accessed using
ptg.paletteand in markup
TIM gains the following sets of new aliases:
primarysecondarytertiaryaccentsurfacesurface2surface3surface4successwarningerror
Each color has 7 shades, and each shade a foreground and background variant. The base color (i.e. with no shade modifications) use the name as written above, and every other alias is defined as {name}{+/-}{shade_amount}, like primary-3 for the darkest shade of primary, and surface+2for the second-brightest surface shade. Each alias comes complete with a background variant bound to@{alias}`, such as @secondary+2.
It's easier to show than tell, so here is the new default palette, as exported by ptg --palette --export-svg <filename>:
Changelog
Additions
- Add various color manipulation utilities
- Add
#autoTIM pseudo-tag that always gives properly contrasted foreground text - Add
palettesmodule for framework-wide color generation & configuration - Add
Synchronized Outputsupport - Add
FancyReprWidget - Add
ptg --paletteflag
Bugfixes
- Fix markup aliases getting literalized during
parsing.eval_alias&MarkupLanguage.alias - Fix background colors creating vertical seams in SVG exports
- Fix colors getting localized pre-maturely
Refactors
- Make all the
ptgprogram & all builting widgets use the global palette - Prefix all ANSI colors with
ansi-
Showcase
Here is my home-grown project launcher, lens, using the new default color palette (and an upcoming new button widget, but that's for the next release notes):
...and now, using it's custom-defined palette, using the primary color #58A46F:
Here is ptg in the new default color palette:
...and now with a bunch of randomly generated ones:






