diff --git a/app-config/firefox/alpine-monobiome-dark.xpi b/app-config/firefox/alpine-monobiome-dark.xpi index 3ae234b..2d9c0cd 100644 Binary files a/app-config/firefox/alpine-monobiome-dark.xpi and b/app-config/firefox/alpine-monobiome-dark.xpi differ diff --git a/app-config/firefox/alpine-monobiome-light.xpi b/app-config/firefox/alpine-monobiome-light.xpi index 0e3534b..57f1a64 100644 Binary files a/app-config/firefox/alpine-monobiome-light.xpi and b/app-config/firefox/alpine-monobiome-light.xpi differ diff --git a/app-config/firefox/alpine-monobiome.xpi b/app-config/firefox/alpine-monobiome.xpi index 366706e..149dcac 100644 Binary files a/app-config/firefox/alpine-monobiome.xpi and b/app-config/firefox/alpine-monobiome.xpi differ diff --git a/app-config/firefox/badlands-monobiome-dark.xpi b/app-config/firefox/badlands-monobiome-dark.xpi index 0e85c99..8529287 100644 Binary files a/app-config/firefox/badlands-monobiome-dark.xpi and b/app-config/firefox/badlands-monobiome-dark.xpi differ diff --git a/app-config/firefox/badlands-monobiome-light.xpi b/app-config/firefox/badlands-monobiome-light.xpi index a42fd3a..baacf6b 100644 Binary files a/app-config/firefox/badlands-monobiome-light.xpi and b/app-config/firefox/badlands-monobiome-light.xpi differ diff --git a/app-config/firefox/badlands-monobiome.xpi b/app-config/firefox/badlands-monobiome.xpi index 987562b..ccfbc2e 100644 Binary files a/app-config/firefox/badlands-monobiome.xpi and b/app-config/firefox/badlands-monobiome.xpi differ diff --git a/app-config/firefox/chaparral-monobiome-dark.xpi b/app-config/firefox/chaparral-monobiome-dark.xpi index 48e8186..73ba048 100644 Binary files a/app-config/firefox/chaparral-monobiome-dark.xpi and b/app-config/firefox/chaparral-monobiome-dark.xpi differ diff --git a/app-config/firefox/chaparral-monobiome-light.xpi b/app-config/firefox/chaparral-monobiome-light.xpi index b624d04..b13ada2 100644 Binary files a/app-config/firefox/chaparral-monobiome-light.xpi and b/app-config/firefox/chaparral-monobiome-light.xpi differ diff --git a/app-config/firefox/chaparral-monobiome.xpi b/app-config/firefox/chaparral-monobiome.xpi index 320fb4c..9194046 100644 Binary files a/app-config/firefox/chaparral-monobiome.xpi and b/app-config/firefox/chaparral-monobiome.xpi differ diff --git a/app-config/firefox/grassland-monobiome-dark.xpi b/app-config/firefox/grassland-monobiome-dark.xpi index 4564922..ba8c7dd 100644 Binary files a/app-config/firefox/grassland-monobiome-dark.xpi and b/app-config/firefox/grassland-monobiome-dark.xpi differ diff --git a/app-config/firefox/grassland-monobiome-light.xpi b/app-config/firefox/grassland-monobiome-light.xpi index ca1e7dc..50b4d63 100644 Binary files a/app-config/firefox/grassland-monobiome-light.xpi and b/app-config/firefox/grassland-monobiome-light.xpi differ diff --git a/app-config/firefox/grassland-monobiome.xpi b/app-config/firefox/grassland-monobiome.xpi index 14c4f03..36ba50d 100644 Binary files a/app-config/firefox/grassland-monobiome.xpi and b/app-config/firefox/grassland-monobiome.xpi differ diff --git a/app-config/firefox/heathland-monobiome-dark.xpi b/app-config/firefox/heathland-monobiome-dark.xpi index 475f41b..500212c 100644 Binary files a/app-config/firefox/heathland-monobiome-dark.xpi and b/app-config/firefox/heathland-monobiome-dark.xpi differ diff --git a/app-config/firefox/heathland-monobiome-light.xpi b/app-config/firefox/heathland-monobiome-light.xpi index 5a01433..b18a82b 100644 Binary files a/app-config/firefox/heathland-monobiome-light.xpi and b/app-config/firefox/heathland-monobiome-light.xpi differ diff --git a/app-config/firefox/heathland-monobiome.xpi b/app-config/firefox/heathland-monobiome.xpi index 18106f9..a6d91fe 100644 Binary files a/app-config/firefox/heathland-monobiome.xpi and b/app-config/firefox/heathland-monobiome.xpi differ diff --git a/app-config/firefox/moorland-monobiome-dark.xpi b/app-config/firefox/moorland-monobiome-dark.xpi index 351efdd..680fccb 100644 Binary files a/app-config/firefox/moorland-monobiome-dark.xpi and b/app-config/firefox/moorland-monobiome-dark.xpi differ diff --git a/app-config/firefox/moorland-monobiome-light.xpi b/app-config/firefox/moorland-monobiome-light.xpi index 96bebf4..acc5c13 100644 Binary files a/app-config/firefox/moorland-monobiome-light.xpi and b/app-config/firefox/moorland-monobiome-light.xpi differ diff --git a/app-config/firefox/moorland-monobiome.xpi b/app-config/firefox/moorland-monobiome.xpi index d16f151..e0e376f 100644 Binary files a/app-config/firefox/moorland-monobiome.xpi and b/app-config/firefox/moorland-monobiome.xpi differ diff --git a/app-config/firefox/reef-monobiome-dark.xpi b/app-config/firefox/reef-monobiome-dark.xpi index 164959a..e177eae 100644 Binary files a/app-config/firefox/reef-monobiome-dark.xpi and b/app-config/firefox/reef-monobiome-dark.xpi differ diff --git a/app-config/firefox/reef-monobiome-light.xpi b/app-config/firefox/reef-monobiome-light.xpi index 098ec05..daad916 100644 Binary files a/app-config/firefox/reef-monobiome-light.xpi and b/app-config/firefox/reef-monobiome-light.xpi differ diff --git a/app-config/firefox/reef-monobiome.xpi b/app-config/firefox/reef-monobiome.xpi index ac9205f..3e18259 100644 Binary files a/app-config/firefox/reef-monobiome.xpi and b/app-config/firefox/reef-monobiome.xpi differ diff --git a/app-config/firefox/savanna-monobiome-dark.xpi b/app-config/firefox/savanna-monobiome-dark.xpi index aa36afe..346e6be 100644 Binary files a/app-config/firefox/savanna-monobiome-dark.xpi and b/app-config/firefox/savanna-monobiome-dark.xpi differ diff --git a/app-config/firefox/savanna-monobiome-light.xpi b/app-config/firefox/savanna-monobiome-light.xpi index 6541cb6..641b01b 100644 Binary files a/app-config/firefox/savanna-monobiome-light.xpi and b/app-config/firefox/savanna-monobiome-light.xpi differ diff --git a/app-config/firefox/savanna-monobiome.xpi b/app-config/firefox/savanna-monobiome.xpi index 9930dfd..2fb06ab 100644 Binary files a/app-config/firefox/savanna-monobiome.xpi and b/app-config/firefox/savanna-monobiome.xpi differ diff --git a/app-config/firefox/tundra-monobiome-dark.xpi b/app-config/firefox/tundra-monobiome-dark.xpi index 0cc19c2..a41233b 100644 Binary files a/app-config/firefox/tundra-monobiome-dark.xpi and b/app-config/firefox/tundra-monobiome-dark.xpi differ diff --git a/app-config/firefox/tundra-monobiome-light.xpi b/app-config/firefox/tundra-monobiome-light.xpi index b284e72..028a787 100644 Binary files a/app-config/firefox/tundra-monobiome-light.xpi and b/app-config/firefox/tundra-monobiome-light.xpi differ diff --git a/app-config/firefox/tundra-monobiome.xpi b/app-config/firefox/tundra-monobiome.xpi index c8ac5f5..aa80ba2 100644 Binary files a/app-config/firefox/tundra-monobiome.xpi and b/app-config/firefox/tundra-monobiome.xpi differ diff --git a/colors/hex-palette.toml b/colors/hex-palette.toml index bb24c9e..b59d5ae 100644 --- a/colors/hex-palette.toml +++ b/colors/hex-palette.toml @@ -1,4 +1,4 @@ -version = "1.5.1" +version = "1.5.2" [alpine] l10 = "#030303" diff --git a/colors/oklch-palette.toml b/colors/oklch-palette.toml index a36fd57..854ec33 100644 --- a/colors/oklch-palette.toml +++ b/colors/oklch-palette.toml @@ -1,4 +1,4 @@ -version = "1.5.1" +version = "1.5.2" [alpine] l10 = "oklch(10.0% 0.0000 0.0)" diff --git a/images/release/1.5.1/palette.png b/images/release/1.5.1/palette.png index 9a79c13..a95e3d8 100644 Binary files a/images/release/1.5.1/palette.png and b/images/release/1.5.1/palette.png differ diff --git a/images/release/1.5.2/chroma-bounds.png b/images/release/1.5.2/chroma-bounds.png new file mode 100644 index 0000000..480e05c Binary files /dev/null and b/images/release/1.5.2/chroma-bounds.png differ diff --git a/images/release/1.5.2/chroma-curves.png b/images/release/1.5.2/chroma-curves.png new file mode 100644 index 0000000..3534e9c Binary files /dev/null and b/images/release/1.5.2/chroma-curves.png differ diff --git a/images/release/1.5.2/palette-bare.png b/images/release/1.5.2/palette-bare.png new file mode 100644 index 0000000..e64e2c3 Binary files /dev/null and b/images/release/1.5.2/palette-bare.png differ diff --git a/images/release/1.5.2/palette.png b/images/release/1.5.2/palette.png new file mode 100644 index 0000000..f663107 Binary files /dev/null and b/images/release/1.5.2/palette.png differ diff --git a/monobiome/palette.py b/monobiome/palette.py index af34e66..2011f27 100644 --- a/monobiome/palette.py +++ b/monobiome/palette.py @@ -5,6 +5,10 @@ from importlib.metadata import version from coloraide import Color +from monobiome.util import ( + hex_from_rgb8, + srgb8_from_color, +) from monobiome.constants import ( h_map, L_points, @@ -24,8 +28,8 @@ def compute_hlc_map(notation: str) -> dict[str, Any]: oklch = Color('oklch', [_l/100, _c, _h]) if notation == "hex": - srgb = oklch.convert('srgb') - c_str = srgb.to_string(hex=True) + rgb8 = srgb8_from_color(oklch) + c_str = hex_from_rgb8(rgb8) elif notation == "oklch": ol, oc, oh = oklch.convert('oklch').coords() c_str = f"oklch({ol*100:.1f}% {oc:.4f} {oh:.1f})" diff --git a/monobiome/plotting.py b/monobiome/plotting.py index 43274ca..788c463 100644 --- a/monobiome/plotting.py +++ b/monobiome/plotting.py @@ -5,6 +5,7 @@ import matplotlib.pyplot as plt from coloraide import Color from matplotlib.collections import LineCollection +from monobiome.util import srgb8_from_color from monobiome.palette import compute_hlc_map from monobiome.constants import ( h_map, @@ -87,7 +88,9 @@ def plot_hue_chroma_star() -> tuple[plt.Figure, plt.Axes]: _h = h_map[h_str] h_colors = [ - Color('oklch', [_l/100, _c, _h]).convert("srgb") + Color( + 'oklch', [_l/100, _c, _h] + ).convert("srgb").fit(method="oklch-chroma") for _l, _c in zip(L_points, Lpoints_Cstar, strict=True) ] @@ -124,7 +127,7 @@ def palette_image( h = row_count * cell_size w = max_cols * cell_size - img = np.ones((h, w, 3), float) + img = np.ones((h, w, 3), int) lightness_keys_per_row = [] @@ -133,8 +136,7 @@ def palette_image( lkeys = sorted(shades.keys()) lightness_keys_per_row.append(lkeys) for c, k in enumerate(lkeys): - col = Color(shades[k]).convert("srgb").fit(method="clip") - rgb = [col["r"], col["g"], col["b"]] + rgb = srgb8_from_color(shades[k]) r0, r1 = r * cell_size, (r + 1) * cell_size c0, c1 = c * cell_size, (c + 1) * cell_size img[r0:r1, c0:c1, :] = rgb @@ -156,7 +158,7 @@ def show_palette( if show_labels: fig, ax = plt.subplots(figsize=(fig_w, fig_h), dpi=dpi) - ax.imshow(img, interpolation="none", origin="upper") + ax.imshow(img, interpolation="nearest", origin="upper") ax.set_xticks([]) ytick_pos = [(i + 0.5) * cell_size for i in range(len(names))] diff --git a/monobiome/util.py b/monobiome/util.py index 9128649..dad0909 100644 --- a/monobiome/util.py +++ b/monobiome/util.py @@ -2,6 +2,7 @@ import math from types import GenericAlias from argparse import ArgumentParser, _SubParsersAction +import numpy as np from coloraide import Color _SubParsersAction.__class_getitem__ = classmethod(GenericAlias) @@ -33,3 +34,13 @@ def oklch_distance(xc: Color, yc: Color) -> float: dz = l1 - l2 return (dx**2 + dy**2 + dz**2)**0.5 + +def srgb8_from_color(c: str | Color) -> np.ndarray: + c = Color(c).convert("srgb").fit(method="oklch-chroma") + rgb = np.array([c["r"], c["g"], c["b"]], dtype=float) + rgb8 = np.clip(np.round(rgb * 255), 0, 255).astype(np.uint8) + + return rgb8 + +def hex_from_rgb8(rgb8: np.ndarray) -> str: + return f"#{int(rgb8[0]):02x}{int(rgb8[1]):02x}{int(rgb8[2]):02x}" diff --git a/pyproject.toml b/pyproject.toml index a256bae..dd7142e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "monobiome" -version = "1.5.1" +version = "1.5.2" description = "Monobiome color palette" requires-python = ">=3.12" authors = [ diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 2baa32e..89c025b 100755 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -11,3 +11,6 @@ uv run monobiome palette -n oklch -f toml -o colors/oklch-palette.toml # generate provided app config "$script_dir/generate.sh" + +# generate release plots +uv run "$script_dir/plots.py" diff --git a/uv.lock b/uv.lock index 9a35c70..27eb002 100644 --- a/uv.lock +++ b/uv.lock @@ -882,7 +882,7 @@ wheels = [ [[package]] name = "monobiome" -version = "1.5.1" +version = "1.5.2" source = { editable = "." } dependencies = [ { name = "coloraide" },