Skip to content

v7.2.0: Palettes and #auto!

Choose a tag to compare

@bczsalba bczsalba released this 05 Aug 22:06
· 150 commits to master since this release

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 palettes provides a Palette class
  • 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.palette and in markup

TIM gains the following sets of new aliases:

  • primary
  • secondary
  • tertiary
  • accent
  • surface
  • surface2
  • surface3
  • surface4
  • success
  • warning
  • error

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>:
palette

Changelog

Additions

  • Add various color manipulation utilities
  • Add #auto TIM pseudo-tag that always gives properly contrasted foreground text
  • Add palettes module for framework-wide color generation & configuration
  • Add Synchronized Output support
  • Add FancyReprWidget
  • Add ptg --palette flag

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 ptg program & 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):

Screenshot 2022-08-05 at 23 53 46

...and now, using it's custom-defined palette, using the primary color #58A46F:

Screenshot 2022-08-05 at 23 54 32

Here is ptg in the new default color palette:

Screenshot 2022-08-05 at 23 55 29

...and now with a bunch of randomly generated ones:

Screenshot 2022-08-05 at 23 55 35

Screenshot 2022-08-05 at 23 55 42

Screenshot 2022-08-05 at 23 55 46

Screenshot 2022-08-05 at 23 55 55