Releases: apparebit/prettypretty
v0.10.0 Assorted improvements
v0.9.0 Unity!
I’m happy to present the Unity! release of prettypretty, my library for awesome terminal colors. Core color functionality is now implemented in Rust only, with PyO3 providing integration with Python through an extension module. At the same time, thanks to a liberal sprinkling of #[cfg]
and related annotations, the Rust crate continues to build by itself. Moving forward, both Rust and Python versions will be released together. For the next few releases, the focus will be to port remaining Python-only code over to Rust and integrate the new functionality with the extension module.
This release not only ups the game when it comes to the project’s engineering. It also introduces a new user guide with code examples in both languages and adds plenty of new features. Notably, they include a complete implementation of the CSS Color 4 algorithm for color interpolation, including support for missing components and hue interpolation strategies.
But I’m particularly proud to include my first color algorithm of my own design. It translates high-resolution to ANSI colors and yields more consistent results than brute force search in Oklab, which remains supported. The new algorithm turns an oddity, ANSI colors’ lack of intrinsic color values, into a strength and picks the closest matching pair of regular and bright ANSI colors by hue and then selects the final result based on lightness. Since that won’t work with color themes that violate the semantics of ANSI colors, the implementation transparently falls back onto brute force search for such color themes.
Additional experiments with a cleaned up version of Chalk’s algorithm for translation to ANSI colors demonstrate that this popular JavaScript library reliably produces unacceptable results. That’s pretty ironic for a library with the tagline “Terminal string styling done right.” I think there is an easy way to fix this: Anyone interested in taking on the integration of prettypretty with Node.js and Demo.js? The latter should be straight-forward since it already has a Rust-based core.
Oxidized Colors v0.1.1
Nowadays, many terminal emulators are being written in Rust. So that they too can benefit from awesome color support, here is the Rust version of prettypretty. The crate is BYOIO (Bring Your Own I/O) for now, i.e., there is no support for reading and writing ANSI escape codes. But the crate's color support is first class. In fact, it currently surpasses that of the Python version and includes the Oklrab and Oklrch color spaces—think Oklab 2.0. Other than that, have a look at the documentation. It has plenty of code examples and shiny color swatches, too!
Alright Mr DeMille, I'm ready for my close-up!
Prettypretty is ready for that close-up indeed: It takes care of your application's styling needs, adjusting to a user's color theme, dark or light mode, and color preferences. The documentation provides a walk-through of an example script for display a progress bar as well as a detailed explanation of the underlying color transformations. Check it out!
A first taste of awesome terminal colors
When working with colors, even fifty-year-old terminal colors, it's a good idea to do most analysis and transformations in a perceptually uniform color space. Prettypretty makes it possible to convert the 16 extended ANSI colors, the 6x6x6 RGB cube, and the 24-step gray gradient into Oklab and Oklch. Awesomeness is the result!