Prettypretty

Latest version: v0.11.1

Safety actively analyzes 710445 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.11.1

This release puts the `pretty.css` styles back into the crate, so that hopefully docs.rs can find them now.—I checked, it does.

0.11.0

This release modularizes prettypretty's interface:

* The top-level `prettypretty` module implements high-resolution [`Color`]s and translation between color representations via [`Translator`].
* The [`termco`] module defines terminal-specific color representations, such as [`AnsiColor`] and [`Rob`], as well as the catch-all [`Colorant`] enumeration.
* The [`style`] module implements terminal [`Style`]s as a combination of text [`Format`] (technically, [`FormatUpdate`]) and foreground as well as background [`Colorant`]s. It also defines [`Layer`] to distinguish between the two color bands and [`Fidelity`] to represent terminals' hardware capabilities.
* The [`theme`] module represents the terminal's current color [`Theme`].
* The optional [`gamut`] and [`spectrum`] modules support traversing the gamuts of color spaces and human vision. They are enabled with the `gamut` feature, which is off by default.

To actually interact with the terminal, prettypretty now optionally interfaces with the [prettytty](https://crates.io/crates/prettytty) crate. Unlike other terminal crates for Rust, prettytty is engineered to be lightweight and dependency-free. It only depends on one of the platform crates `libc` (Unix) or `windows-sys` (Windows). The `tty` feature, which is on by default, enables this integration. However, when building the Python extension module, the `tty` feature is disabled—use [`prettypretty.terminal.Terminal`](https://github.com/apparebit/prettypretty/blob/main/prettypretty/terminal.py) instead—and the `gamut` feature is enabled—ensuring that batteries are included.

The much improved [plot.py](https://github.com/apparebit/prettypretty/blob/main/prettypretty/plot.py) script for visualizing colors in the Oklab color space and the new [viz3d.py](https://github.com/apparebit/prettypretty/blob/main/prettypretty/viz3d.py) script for visualizing the volume of the human visual gamut leverage the extension module's functionality to their fullest.

[`assert_close_enough`]: https://apparebit.github.io/prettypretty/prettypretty/macro.assert_close_enough.html
[`assert_same_color`]: https://apparebit.github.io/prettypretty/prettypretty/macro.assert_same_color.html
[`close_enough`]: https://apparebit.github.io/prettypretty/prettypretty/fn.close_enough.html
[`to_eq_bits`]: https://apparebit.github.io/prettypretty/prettypretty/fn.to_eq_bits.html
[`Action`]: https://apparebit.github.io/prettypretty/prettypretty/term/enum.Action.html
[`AnsiColor`]: https://apparebit.github.io/prettypretty/prettypretty/termco/enum.AnsiColor.html
[`AnsiColorIterator`]: https://apparebit.github.io/prettypretty/prettypretty/termco/struct.AnsiColorIterator.html
[`Bits`]: https://apparebit.github.io/prettypretty/prettypretty/type.Bits.html
[`Color`]: https://apparebit.github.io/prettypretty/prettypretty/struct.Color.html
[`Colorant`]: https://apparebit.github.io/prettypretty/prettypretty/termco/enum.Colorant.html
[`Colorant::Default`]: https://apparebit.github.io/prettypretty/prettypretty/termco/enum.Colorant.html#variant.Default
[`ColorFormatError`]: https://apparebit.github.io/prettypretty/prettypretty/enum.ColorFormatError.html
[`ColorSpace`]: https://apparebit.github.io/prettypretty/prettypretty/enum.ColorSpace.html
[`Command`]: https://apparebit.github.io/prettypretty/prettytty/trait.Command.html
[`Connection`]: https://apparebit.github.io/prettypretty/prettytty/struct.Connection.html
[`Control`]: https://apparebit.github.io/prettypretty/prettytty/term/enum.Control.html
[`EightBitColor`]: https://apparebit.github.io/prettypretty/prettypretty/termco/enum.EightBitColor.html
[`EmbeddedRgb`]: https://apparebit.github.io/prettypretty/prettypretty/termco/struct.EmbeddedRgb.html
[`error`]: https://apparebit.github.io/prettypretty/prettypretty/error/
[`Fidelity`]: https://apparebit.github.io/prettypretty/prettypretty/style/enum.Fidelity.html
[`Fidelity::from_environment`]: https://apparebit.github.io/prettypretty/prettypretty/style/enum.Fidelity.html#method.from_environment
[`Float`]: https://apparebit.github.io/prettypretty/prettypretty/type.Float.html
[`Format`]: https://apparebit.github.io/prettypretty/prettypretty/style/struct.Format.html
[`FormatUpdate`]: https://apparebit.github.io/prettypretty/prettypretty/style/struct.FormatUpdate.html
[`gamut`]: https://apparebit.github.io/prettypretty/prettypretty/gamut/
[`GrayGradient`]: https://apparebit.github.io/prettypretty/prettypretty/termco/struct.GrayGradient.html
[`HueInterpolation`]: https://apparebit.github.io/prettypretty/prettypretty/enum.HueInterpolation.html
[`Input`]: https://apparebit.github.io/prettypretty/prettytty/struct.Input.html
[`Interpolator`]: https://apparebit.github.io/prettypretty/prettypretty/struct.Interpolator.html
[`Layer`]: https://apparebit.github.io/prettypretty/prettypretty/style/enum.Layer.html
[`Mode`]: https://apparebit.github.io/prettypretty/prettypretty/term/enum.Mode.html
[`OkVersion`]: https://apparebit.github.io/prettypretty/prettypretty/enum.OkVersion.html
[`Output`]: https://apparebit.github.io/prettypretty/prettytty/struct.Output.html
[`OutOfBoundsError`]: https://apparebit.github.io/prettypretty/prettypretty/error/struct.OutOfBoundsError.html
[`Query`]: https://apparebit.github.io/prettypretty/prettytty/trait.Query.html
[`Rgb`]: https://apparebit.github.io/prettypretty/prettypretty/termco/struct.Rgb.html
[`Scan`]: https://apparebit.github.io/prettypretty/prettytty/trait.Scan.html
[`Scanner`]: https://apparebit.github.io/prettypretty/prettypretty/term/struct.Scanner.html
[`Sgr`]: https://apparebit.github.io/prettypretty/prettytty/trait.Sgr.html
[`spectrum`]: https://apparebit.github.io/prettypretty/prettypretty/spectrum/
[`style`]: https://apparebit.github.io/prettypretty/prettypretty/style/
[`Style`]: https://apparebit.github.io/prettypretty/prettypretty/style/struct.Style.html
[`Style::cap`]: https://apparebit.github.io/prettypretty/prettypretty/style/struct.Style.html#method.cap
[`termco`]: https://apparebit.github.io/prettypretty/prettypretty/termco/
[`theme`]: https://apparebit.github.io/prettypretty/prettypretty/theme/
[`Theme`]: https://apparebit.github.io/prettypretty/prettypretty/theme/struct.Theme.html
[`ThemeEntry`]: https://apparebit.github.io/prettypretty/prettypretty/theme/enum.ThemeEntry.html
[`ThemeEntryIterator`]: https://apparebit.github.io/prettypretty/prettypretty/theme/struct.ThemeEntryIterator.html
[`Token`]: https://apparebit.github.io/prettypretty/prettytty/enum.Token.html
[`Translator`]: https://apparebit.github.io/prettypretty/prettypretty/struct.Translator.html
[`Translator::is_dark_theme`]: https://apparebit.github.io/prettypretty/prettypretty/struct.Translator.html#method.is_dark_theme
[`VGA_COLORS`]: https://apparebit.github.io/prettypretty/prettypretty/theme/constant.VGA_COLORS.html

0.10.0

This release bundles assorted improvements, notably to the documentation. It bumps the minor version as indicator of potential breakage: `Sampler::adjust` is now known as `Sampler::cap`.

0.9.0

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](https://pyo3.rs/v0.22.0/) 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**](https://apparebit.github.io/prettypretty/) with code examples in both languages and adds plenty of [new features](https://github.com/apparebit/prettypretty/blob/main/CHANGELOG.md). 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**](https://github.com/chalk/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.

rs-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](https://docs.rs/prettypretty/latest/prettypretty/). It has plenty of code examples and shiny color swatches, too!

0.8.0

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](https://apparebit.github.io/prettypretty/) 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!

0.2.0

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!

Links

Releases

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.