# Theme

The palette the workbench paints plotly, pyvista, xterm and Monaco with, and the colormap catalogue its pickers offer.

## femforge\_workbench.theme

The palette read from the dist's theme.json, painting plotly, pyvista, xterm and Monaco in the stylesheet's colours.

Classes:

- **`Scheme`** –

  The two colour schemes theme.json carries.
- **`Token`** –

  The stylesheet tokens the palette reads.
- **`Section`** –

  The non-scheme sections of theme.json.
- **`Font`** –

  The font stacks theme.json names.
- **`Tokens`** –

  What theme.json carries: the colours of each scheme, the metrics in CSS pixels and the font stacks.
- **`Metrics`** –

  The type sizes and chrome heights of the stylesheet, in CSS pixels.
- **`Tones`** –

  The interaction colours derived from a palette, as hex.
- **`Palette`** –

  The colours the panels share, read from one scheme of the tokens.

Functions:

- **`rgb`** –

  The channels of a CSS colour written as a hex triplet, rgb()/rgba(), or white/black.
- **`hex_color`** –

  The colour as an upper-case hex triplet, the form pyvista takes.
- **`mix`** –

  The hex colour `fraction` of the way from `onto` to `color`.
- **`luminance`** –

  The perceived brightness of a colour on the 0-255 scale.
- **`rotate_hue`** –

  The colour with its hue rotated by a fraction of the wheel, as a hex triplet.
- **`template_json`** –

  A registered plotly template (the default when unnamed) as plain JSON.
- **`section`** –

  The nested object under `key`, empty when absent.
- **`text`** –

  The string under `key`, else the fallback.
- **`load_tokens`** –

  The tokens of the built dist; a missing dist names the build command.

### Scheme

Bases: `StrEnum`

The two colour schemes theme.json carries.

### Token

Bases: `StrEnum`

The stylesheet tokens the palette reads.

### Section

Bases: `StrEnum`

The non-scheme sections of theme.json.

### Font

Bases: `StrEnum`

The font stacks theme.json names.

### Tokens

```python
Tokens(colors: Mapping[str, Mapping[str, str]], metrics: Mapping[str, float], fonts: Mapping[str, str])
```

What theme.json carries: the colours of each scheme, the metrics in CSS pixels and the font stacks.

Methods:

- **`from_json`** –

  Reads the tokens from theme.json's document.

#### from\_json

```python
from_json(document: Mapping[str, object]) -> Tokens
```

Reads the tokens from theme.json's document.

### Metrics

```python
Metrics(size_body: float, size_label: float, bar_height: float, tab_height: float, space: float, row_height: float)
```

The type sizes and chrome heights of the stylesheet, in CSS pixels.

Methods:

- **`from_tokens`** –

  Reads the metrics from the tokens, which name each field in kebab case.

#### from\_tokens

```python
from_tokens(tokens: Tokens) -> Metrics
```

Reads the metrics from the tokens, which name each field in kebab case.

### Tones

```python
Tones(raised: str, on_accent: str)
```

The interaction colours derived from a palette, as hex.

### Palette

```python
Palette(paper: str, plot: str, text: str, grid: str, accent: str, muted: str, chart: tuple[str, ...], dark: bool, metrics: Metrics, font: str, mono: str)
```

The colours the panels share, read from one scheme of the tokens.

Methods:

- **`from_tokens`** –

  The palette of one scheme of the tokens.
- **`load`** –

  The dist's palette in one scheme.
- **`with_accent`** –

  The dist's palette with an accent of the caller's own.
- **`colorway`** –

  The chart colours, then hues rotated evenly from the accent for the rest.
- **`tones`** –

  The derived interaction colours: a raised surface and text that reads on the accent.
- **`plotly_template`** –

  The base template (plotly\_dark or plotly\_white by scheme) repainted in this palette, at the label size, with the top margin a titleless figure needs.
- **`install`** –

  Registers this palette's plotly template as the default, so every figure built afterwards is painted in it.
- **`xterm_theme`** –

  The xterm ITheme colours.

Attributes:

- **`is_dark`** (`bool`) –

  Whether the palette paints the dark scheme.
- **`monaco_theme`** (`str`) –

  The built-in Monaco theme matching the scheme.

#### is\_dark

```python
is_dark: bool
```

Whether the palette paints the dark scheme.

#### monaco\_theme

```python
monaco_theme: str
```

The built-in Monaco theme matching the scheme.

#### from\_tokens

```python
from_tokens(tokens: Tokens, *, dark: bool) -> Palette
```

The palette of one scheme of the tokens.

#### load

```python
load(*, dark: bool = True) -> Palette
```

The dist's palette in one scheme.

#### with\_accent

```python
with_accent(accent: str, *, dark: bool = True) -> Palette
```

The dist's palette with an accent of the caller's own.

#### colorway

```python
colorway(count: int = 6) -> list[str]
```

The chart colours, then hues rotated evenly from the accent for the rest.

#### tones

```python
tones() -> Tones
```

The derived interaction colours: a raised surface and text that reads on the accent.

#### plotly\_template

```python
plotly_template(base: str | None = None) -> Json
```

The base template (plotly\_dark or plotly\_white by scheme) repainted in this palette, at the label size, with the top margin a titleless figure needs.

#### install

```python
install() -> None
```

Registers this palette's plotly template as the default, so every figure built afterwards is painted in it.

#### xterm\_theme

```python
xterm_theme() -> dict[str, str]
```

The xterm ITheme colours.

### rgb

```python
rgb(color: str) -> tuple[int, int, int]
```

The channels of a CSS colour written as a hex triplet, rgb()/rgba(), or white/black.

### hex\_color

```python
hex_color(color: str) -> str
```

The colour as an upper-case hex triplet, the form pyvista takes.

### mix

```python
mix(color: str, onto: str, fraction: float) -> str
```

The hex colour `fraction` of the way from `onto` to `color`.

Parameters:

- **`color`** (`str`) –

  The colour at a fraction of 1.
- **`onto`** (`str`) –

  The colour at a fraction of 0.
- **`fraction`** (`float`) –

  How far from `onto` toward `color`, from 0 to 1.

### luminance

```python
luminance(color: str) -> float
```

The perceived brightness of a colour on the 0-255 scale.

### rotate\_hue

```python
rotate_hue(color: str, turns: float) -> str
```

The colour with its hue rotated by a fraction of the wheel, as a hex triplet.

### template\_json

```python
template_json(name: str | None = None) -> Json
```

A registered plotly template (the default when unnamed) as plain JSON.

### section

```python
section(source: Mapping[str, object], key: str) -> Json
```

The nested object under `key`, empty when absent.

### text

```python
text(source: Mapping[str, object], key: str, fallback: str) -> str
```

The string under `key`, else the fallback.

Parameters:

- **`source`** (`Mapping[str, object]`) –

  The JSON object to read.
- **`key`** (`str`) –

  The key to read.
- **`fallback`** (`str`) –

  The string returned when the value is missing or not a string.

### load\_tokens

```python
load_tokens() -> Tokens
```

The tokens of the built dist; a missing dist names the build command.

## femforge\_workbench.colormaps

The colormap catalogue the field viewer's pickers offer, by type, with the favorites listed first.

Classes:

- **`ColormapType`** –

  Enumeration of colormap types.
- **`Colormap`** –

  One catalogue entry: its type, the name pyvista resolves and the sentence-case label the pickers show.

Attributes:

- **`FAVORITES`** (`tuple[str, ...]`) –

  Suggested starting maps, listed first in the colormap pickers.

### FAVORITES

```python
FAVORITES: tuple[str, ...] = ('viridis', 'haline', 'batlow', 'inferno', 'Black-Body Radiation', 'coolwarm', 'vik', 'Fast', 'turbo')
```

Suggested starting maps, listed first in the colormap pickers.

### ColormapType

Bases: `Enum`

Enumeration of colormap types.

### Colormap

Bases: `NamedTuple`

One catalogue entry: its type, the name pyvista resolves and the sentence-case label the pickers show.
