Theme and colors
Themes, theme tokens and colors.
Contents:
k.theme: Tokens of the current theme:k.theme.bg,fg,accent,muted,secondary.k.themes: Built-in themes:k.themes.dark(default),k.themes.lightandk.themes.blueprint.k.Theme: Built-in themes:k.themes.dark(default),k.themes.lightandk.themes.blueprint.k.BLUE: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.BLACK: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.GRAY: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.GREEN: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.ORANGE: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.PINK: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.PURPLE: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.RED: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.TEAL: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.TRANSPARENT: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.WHITE: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.YELLOW: Fixed palette:k.BLUE,k.RED,k.GREEN,k.YELLOW,k.ORANGE,k.PURPLE,k.PINK,k.TEAL,k.WHITE,k.BLACK,k.GRAYandk.TRANSPARENT.k.rgb: Color from components from 0 to 1 (a=is the opacity).k.Color: Color from components from 0 to 1 (a=is the opacity).
Back to the reference index.
k.theme (namespace)#
k.theme # namespace
Written as: k.theme.bg | k.theme.fg | k.theme.accent | k.theme.muted | k.theme.secondary
Tokens of the current theme: k.theme.bg, fg, accent, muted, secondary. They are resolved when the scene is built, so switching the theme changes the whole scene without touching the code. k.RED, k.BLUE... are the fixed palette.
Example:
@k.scene(theme=k.themes.blueprint)
def tokens(s: k.Scene):
box = k.RoundedRect(w=4, h=2, stroke=k.theme.accent).place(at="center")
note = k.Text("blueprint theme", fill=k.theme.secondary).place(below=box, gap=0.3)
s.play(k.draw(box), k.write(note))
k.themes (namespace)#
k.themes # namespace
Written as: k.themes.dark | k.themes.light | k.themes.blueprint
Built-in themes: k.themes.dark (default), k.themes.light and k.themes.blueprint. Choose one with @k.scene(theme=...) or in kinemo.toml; theme.with_(accent=k.PINK) creates a variation.
Members:
| Member | Description or type |
|---|---|
k.themes.dark |
Theme |
k.themes.light |
Theme |
k.themes.blueprint |
Theme |
Example:
@k.scene(theme=k.themes.light.with_(accent=k.PINK))
def light(s: k.Scene):
dot = k.Circle(r=1, fill=k.theme.accent, fill_opacity=1).place(at="center")
s.play(k.grow(dot))
See also: k.theme.
k.Theme (class)#
k.Theme(
name: str,
bg: Color,
fg: Color,
accent: Color,
muted: Color,
secondary: Color,
font_size: float = 0.5,
stroke_width: float = 4.0,
extra: dict[str, Any] = <factory>,
)
Documented together with k.themes. Built-in themes: k.themes.dark (default), k.themes.light and k.themes.blueprint. Choose one with @k.scene(theme=...) or in kinemo.toml; theme.with_(accent=k.PINK) creates a variation.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
name |
str |
required | |
bg |
Color |
required | |
fg |
Color |
required | |
accent |
Color |
required | |
muted |
Color |
required | |
secondary |
Color |
required | |
font_size |
float |
0.5 |
|
stroke_width |
float |
4.0 |
|
extra |
dict[str, Any] |
<factory> |
Members:
with_: A copy of the theme with some tokens changed.
k.Theme.with_ (method)
theme.with_(**changes: object) -> Theme
A copy of the theme with some tokens changed.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
**changes |
object |
variadic |
k.BLUE (constant)#
k.BLUE: Color = "#4C9BE8"
Written as: k.BLUE | k.RED | k.GREEN | k.YELLOW | k.ORANGE | k.PURPLE | k.PINK | k.TEAL | k.WHITE | k.BLACK | k.GRAY | k.TRANSPARENT
Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
Example:
@k.scene
def palette(s: k.Scene):
colors = [k.BLUE, k.RED, k.GREEN, k.YELLOW, k.PURPLE]
dots = [k.Circle(r=0.5, fill=c, fill_opacity=1, stroke=c) for c in colors]
row = k.Row(*dots, gap=0.4).place(at="center")
s.play(k.stagger([k.grow(d) for d in dots], lag=0.1))
See also: k.rgb, k.theme, k.mix.
k.BLACK (constant)#
k.BLACK: Color = "#111216"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.GRAY (constant)#
k.GRAY: Color = "#8A8F98"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.GREEN (constant)#
k.GREEN: Color = "#5CC489"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.ORANGE (constant)#
k.ORANGE: Color = "#F29A4A"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.PINK (constant)#
k.PINK: Color = "#E879B9"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.PURPLE (constant)#
k.PURPLE: Color = "#A57BE0"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.RED (constant)#
k.RED: Color = "#E8645A"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.TEAL (constant)#
k.TEAL: Color = "#45C1C0"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.TRANSPARENT (constant)#
k.TRANSPARENT: Color = "#00000000"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.WHITE (constant)#
k.WHITE: Color = "#F2F2F2"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.YELLOW (constant)#
k.YELLOW: Color = "#F5C542"
Documented together with k.BLUE. Fixed palette: k.BLUE, k.RED, k.GREEN, k.YELLOW, k.ORANGE, k.PURPLE, k.PINK, k.TEAL, k.WHITE, k.BLACK, k.GRAY and k.TRANSPARENT. Colors interpolate in OKLab. For theme-dependent colors use k.theme.*.
k.rgb (function)#
k.rgb(r: float, g: float, b: float, a: float = 1.0) -> Color
Color from components from 0 to 1 (a= is the opacity). Outside the palette and the theme, this is the way to define a color.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
r |
float |
required | |
g |
float |
required | |
b |
float |
required | |
a |
float |
1.0 |
Color from components from 0 to 1 (a= is the opacity). |
Example:
@k.scene
def custom_color(s: k.Scene):
amber = k.rgb(1.0, 0.55, 0.1)
sq = k.Square(2, fill=amber, fill_opacity=1).place(at="center")
s.play(k.draw(sq))
k.Color (class)#
k.Color(r: float, g: float, b: float, a: float = 1.0)
Documented together with k.rgb. Color from components from 0 to 1 (a= is the opacity). Outside the palette and the theme, this is the way to define a color.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
r |
float |
required | |
g |
float |
required | |
b |
float |
required | |
a |
float |
1.0 |
Members:
hex: staticmethod.with_alpha: The same color with another alpha.to_hex:#RRGGBB(or#RRGGBBAAwhen translucent).components:[r, g, b, a]in 0..1.
k.Color.hex (staticmethod)
k.Color.hex(code: str) -> Color
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
code |
str |
required |
k.Color.with_alpha (method)
color.with_alpha(a: float) -> Color
The same color with another alpha.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
a |
float |
required |
k.Color.to_hex (method)
color.to_hex() -> str
#RRGGBB (or #RRGGBBAA when translucent).
k.Color.components (method)
color.components() -> list[float]
[r, g, b, a] in 0..1.