Theme¶
The palette the workbench paints plotly, pyvista, xterm and Monaco with, the colormap catalogue its pickers offer, and the render settings every 3D view draws with.
femforge_workbench.theme
¶
The palette read from the dist's theme.json, painting plotly, pyvista, xterm and Monaco in the stylesheet's colours.
Classes:
-
Token–The stylesheet tokens the palette reads.
-
Section–The sections of theme.json.
-
Font–The font stacks theme.json names.
-
Tokens–What theme.json carries: the colours, 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 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
fractionof the way fromontotocolor. -
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.
Tokens
dataclass
¶
What theme.json carries: the colours, the metrics in CSS pixels and the font stacks.
Methods:
-
from_json–Reads the tokens from theme.json's document.
from_json
classmethod
¶
Reads the tokens from theme.json's document.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
Metrics
dataclass
¶
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
classmethod
¶
Reads the metrics from the tokens, which name each field in kebab case.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
Tones
dataclass
¶
The interaction colours derived from a palette, as hex.
Palette
dataclass
¶
Palette(paper: str, plot: str, text: str, grid: str, accent: str, muted: str, chart: tuple[str, ...], metrics: Metrics, font: str, mono: str)
The colours the panels share, read from the tokens.
Methods:
-
from_tokens–The palette of the tokens.
-
load–The dist's palette.
-
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 by default, 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.
from_tokens
classmethod
¶
The palette of the tokens.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
with_accent
classmethod
¶
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.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
tones
¶
tones() -> Tones
The derived interaction colours: a raised surface and text that reads on the accent.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
plotly_template
¶
plotly_template(base: str | None = None) -> Json
The base template, plotly_dark by default, repainted in this palette, at the label size, with the top margin a titleless figure needs.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
install
¶
Registers this palette's plotly template as the default, so every figure built afterwards is painted in it.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
xterm_theme
¶
The xterm ITheme colours.
rgb
¶
The channels of a CSS colour written as a hex triplet, rgb()/rgba(), or white/black.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
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.
Parameters:
-
color(str) –The colour at a fraction of 1.
-
onto(str) –The colour at a fraction of 0.
-
fraction(float) –How far from
ontotowardcolor, from 0 to 1.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
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.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
template_json
¶
template_json(name: str | None = None) -> Json
A registered plotly template (the default when unnamed) as plain JSON.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
section
¶
The nested object under key, empty when absent.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
text
¶
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.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
load_tokens
cached
¶
load_tokens() -> Tokens
The tokens of the built dist; a missing dist names the build command.
Source code in packages/femforge-workbench/src/femforge_workbench/theme.py
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
module-attribute
¶
FAVORITES: tuple[str, ...] = ('viridis', 'haline', 'batlow', 'inferno', 'Black-Body Radiation', 'coolwarm', 'vik', 'Fast', 'turbo')
Suggested starting maps, listed first in the colormap pickers.
Colormap
¶
Bases: NamedTuple
One catalogue entry: its type, the name pyvista resolves and the sentence-case label the pickers show.
femforge_workbench.render
¶
The render settings every 3D view shares, persisted once per user across workbenches.
Classes:
-
Antialias–How a renderer smooths the edges it draws.
-
Lighting–The lights a renderer places.
-
Projection–How the camera projects the scene.
-
ToneMapping–How the stream maps the rendered light onto the screen's range.
-
RenderSettings–How every 3D view draws: its antialiasing per renderer, its lights, shading, camera, tone mapping and lines.
-
RenderVar–The shell's state variables of the render settings, one per field, named PREFIX and the field; a slider's holds its one thumb in a list.
Functions:
-
limits–The lowest and highest value a slider's setting validates.
-
render_state–The state variables showing
settings. -
settings_from_state–The settings the state variables show; None when they do not validate.
-
load_render–The user's saved render settings; the defaults when none are saved or the saved ones no longer validate.
-
save_render–Saves the user's render settings for every workbench.
Attributes:
-
SHARED–The workbench name of the documents every workbench of a user reads.
-
RENDER_KEY–The persisted document of the render settings.
-
PREFIX–What every render setting's state variable starts with, before its field name.
-
CLIENT_ANTIALIAS(tuple[Antialias, ...]) –What the mirror can draw: VTK.wasm ignores the window's multisamples.
-
SERVER_ANTIALIAS(tuple[Antialias, ...]) –What the stream can draw.
-
SLIDERS(tuple[RenderVar, ...]) –The settings a slider sets, which apply on its release.
-
CHOICES(tuple[RenderVar, ...]) –The settings a toggle or a switch sets, which apply at once.
SHARED
module-attribute
¶
The workbench name of the documents every workbench of a user reads.
PREFIX
module-attribute
¶
What every render setting's state variable starts with, before its field name.
CLIENT_ANTIALIAS
module-attribute
¶
What the mirror can draw: VTK.wasm ignores the window's multisamples.
SERVER_ANTIALIAS
module-attribute
¶
What the stream can draw.
SLIDERS
module-attribute
¶
SLIDERS: tuple[RenderVar, ...] = tuple(var for var in RenderVar if RenderSettings.model_fields[var.field].annotation is float)
The settings a slider sets, which apply on its release.
CHOICES
module-attribute
¶
The settings a toggle or a switch sets, which apply at once.
RenderSettings
pydantic-model
¶
Bases: BaseModel
How every 3D view draws: its antialiasing per renderer, its lights, shading, camera, tone mapping and lines.
Config:
frozen:Trueuse_attribute_docstrings:True
Fields:
-
client_antialias(Antialias) -
server_antialias(Antialias) -
lighting(Lighting) -
brightness(float) -
ambient(float) -
specular(float) -
smooth_shading(bool) -
split_angle(float) -
projection(Projection) -
view_angle(float) -
tone_mapping(ToneMapping) -
exposure(float) -
outline_width(float) -
feature_angle(float) -
highlight_width(float) -
line_width(float)
Validators:
client_antialias
pydantic-field
¶
The mirror's antialiasing, one of CLIENT_ANTIALIAS.
server_antialias
pydantic-field
¶
The stream's antialiasing.
brightness
pydantic-field
¶
brightness: float = 1.0
[-]: The intensity of every light, relative to the preset's own.
ambient
pydantic-field
¶
ambient: float = 0.0
[-]: The share of a surface's color shown without light.
specular
pydantic-field
¶
specular: float = PLAIN_SPECULAR
[-]: The highlight strength of a body in a plain color.
smooth_shading
pydantic-field
¶
smooth_shading: bool = True
Shade curved faces evenly; off shades every facet flat.
split_angle
pydantic-field
¶
split_angle: float = 30.0
[deg]: The dihedral angle above which a smooth surface keeps its edge sharp.
projection
pydantic-field
¶
projection: Projection = Projection.ORTHOGRAPHIC
How the camera projects the scene.
view_angle
pydantic-field
¶
view_angle: float = 30.0
[deg]: The perspective camera's vertical field of view.
tone_mapping
pydantic-field
¶
tone_mapping: ToneMapping = ToneMapping.OFF
The stream's tone mapping; the mirror has none.
exposure
pydantic-field
¶
exposure: float = 1.0
[-]: The light the tone mapping takes in, relative to the rendered.
outline_width
pydantic-field
¶
outline_width: float = 2.0
[px]: The width of the feature-edge outline in CSS pixels.
feature_angle
pydantic-field
¶
feature_angle: float = 30.0
[deg]: The dihedral angle above which a surface edge counts as a feature edge.
highlight_width
pydantic-field
¶
highlight_width: float = 2.0
[px]: The width of a hover outline in CSS pixels; a selection draws wider in proportion.
drawable
pydantic-validator
¶
Rejects an antialiasing the mirror cannot draw.
Source code in packages/femforge-workbench/src/femforge_workbench/render.py
edges
¶
edges() -> EdgeStyle
The outline and line widths and the feature angle as the scenes take them.
Source code in packages/femforge-workbench/src/femforge_workbench/render.py
RenderVar
¶
limits
¶
The lowest and highest value a slider's setting validates.
Source code in packages/femforge-workbench/src/femforge_workbench/render.py
render_state
¶
render_state(settings: RenderSettings) -> dict[str, object]
The state variables showing settings.
Source code in packages/femforge-workbench/src/femforge_workbench/render.py
settings_from_state
¶
settings_from_state(state: Mapping[str, object]) -> RenderSettings | None
The settings the state variables show; None when they do not validate.
Source code in packages/femforge-workbench/src/femforge_workbench/render.py
load_render
¶
load_render(store: UiStateStore, user: str) -> RenderSettings
The user's saved render settings; the defaults when none are saved or the saved ones no longer validate.
Source code in packages/femforge-workbench/src/femforge_workbench/render.py
save_render
¶
save_render(store: UiStateStore, user: str, settings: RenderSettings) -> None
Saves the user's render settings for every workbench.
Parameters:
-
store(UiStateStore) –The store the shell persists its UI state in.
-
user(str) –The user the settings belong to.
-
settings(RenderSettings) –The settings to save.