or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

console.mdcontainers.mdindex.mdinteractive.mdlayout.mdmarkdown.mdprogress.mdsyntax.mdtables.mdtext-styling.mdutilities.md

utilities.mddocs/

0

# Utilities

1

2

Color handling, measurement, error types, and other utility functions. Rich provides various utility functions and classes for working with colors, measurements, and other common operations.

3

4

## Capabilities

5

6

### Color System

7

8

Comprehensive color handling and conversion.

9

10

```python { .api }

11

class Color:

12

"""Color representation with conversion capabilities."""

13

14

@classmethod

15

def parse(cls, color: ColorType) -> "Color":

16

"""Parse color from various formats."""

17

18

def blend(self, destination: "Color", factor: float) -> "Color":

19

"""Blend with another color."""

20

21

def get_truecolor(self) -> Tuple[int, int, int]:

22

"""Get RGB values."""

23

24

class ColorTriplet(NamedTuple):

25

"""RGB color triplet."""

26

red: int

27

green: int

28

blue: int

29

30

def inspect(

31

obj: Any,

32

*,

33

console: Optional[Console] = None,

34

title: Optional[str] = None,

35

help: bool = False,

36

methods: bool = False,

37

docs: bool = True,

38

private: bool = False,

39

dunder: bool = False,

40

sort: bool = True,

41

all: bool = False,

42

value: bool = True,

43

) -> None:

44

"""Inspect Python objects with rich formatting."""

45

46

class Measurement(NamedTuple):

47

"""Content measurement with min/max dimensions."""

48

minimum: int

49

maximum: int

50

51

def with_maximum(self, maximum: int) -> "Measurement": ...

52

def with_minimum(self, minimum: int) -> "Measurement": ...

53

def clamp(self, min_width: int, max_width: int) -> "Measurement": ...

54

```

55

56

**Usage Examples:**

57

58

```python

59

from rich.color import Color

60

from rich import inspect

61

from rich.console import Console

62

63

console = Console()

64

65

# Color operations

66

red = Color.parse("red")

67

blue = Color.parse("#0000FF")

68

purple = red.blend(blue, 0.5)

69

70

# Object inspection

71

inspect([1, 2, 3, 4, 5])

72

inspect(console, methods=True)

73

```