From 36f79275976c38caad999e25146021a67df77bb2 Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Fri, 9 Jan 2026 11:32:29 +0100 Subject: [PATCH] 0.12.0 "The Color Update" --- CHANGELOG.md | 2 +- README.md | 6 ++++++ docs/color.rst | 16 +++++++++++++++- src/suou/__init__.py | 8 ++++---- src/suou/color.py | 8 ++++++-- src/suou/quart_auth.py | 4 +++- tests/test_color.py | 7 +++++-- 7 files changed, 40 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a26905..bb3a6c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * New module `mat` adds a shallow reimplementation of `Matrix()` in order to implement matrix multiplication * Removed obsolete `configparse` implementation that has been around since 0.3 and shelved since 0.4. * `color`: added support for conversion from RGB to linear RGB, XYZ, OKLab and OKLCH. -* Added `user-loader` for Quart-Auth and SQLAlchemy +* Added `user-loader` for Quart-Auth + SQLAlchemy ## 0.11.2 diff --git a/README.md b/README.md index 3a08b1e..f83e756 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Read the [documentation](https://suou.readthedocs.io/). ## Support +### Disclaimer + Just a heads up: SUOU was made to support Sakuragasaki46 (me)'s own selfish, egoistic needs. Not certainly to provide a service to the public. As a consequence, 'add this add that' stuff is best-effort. @@ -42,6 +44,10 @@ Don't want to depend on my codebase for moral reasons (albeit unrelated)? It's f **DO NOT ASK TO MAKE SUOU SAFE FOR CHILDREN**. Enjoy having your fingers cut. +### "LTS" + +The following versions are supported: the latest, the second-to-latest, 0.12.x and 0.7.x. + ## License Licensed under the [Apache License, Version 2.0](LICENSE), a non-copyleft free and open source license. diff --git a/docs/color.rst b/docs/color.rst index 189a063..7d24102 100644 --- a/docs/color.rst +++ b/docs/color.rst @@ -4,7 +4,16 @@ Color .. currentmodule:: suou.color -... +libsuou provides some utilities for the manipulation of colors. + +In particular, conversion to and from RGB and OKLCH colors. + +Terminal colors +--------------- + +.. autoclass:: Chalk + + Note: instance is ``chalk`` and can be used as-is Web colors ---------- @@ -15,5 +24,10 @@ Web colors .. autoclass:: WebColor +.. auto + + .. autoclass:: XYZColor + +.. autoclass:: OKLabColor \ No newline at end of file diff --git a/src/suou/__init__.py b/src/suou/__init__.py index a47775a..60f8b7b 100644 --- a/src/suou/__init__.py +++ b/src/suou/__init__.py @@ -5,7 +5,7 @@ See README.md for a description. --- -Copyright (c) 2025 Sakuragasaki46. +Copyright (c) 2025-2026 Sakuragasaki46. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -35,16 +35,16 @@ from .strtools import PrefixIdentifier from .validators import matches, not_less_than, not_greater_than, yesno from .redact import redact_url_password from .http import WantsContentType -from .color import OKLabColor, chalk, WebColor, RGBColor, LinearRGBColor, XYZColor, OKLabColor +from .color import OKLabColor, chalk, WebColor, RGBColor, LinearRGBColor, XYZColor, OKLCHColor from .mat import Matrix -__version__ = "0.12.0a10" +__version__ = "0.12.0" __all__ = ( 'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue', 'DictConfigSource', 'EnvConfigSource', 'I18n', 'Incomplete', 'JsonI18n', 'LinearRGBColor', - 'Matrix', 'MissingConfigError', 'MissingConfigWarning', 'OKLabColor', + 'Matrix', 'MissingConfigError', 'MissingConfigWarning', 'OKLabColor', 'OKLCHColor', 'PrefixIdentifier', 'RGBColor', 'Siq', 'SiqCache', 'SiqGen', 'SiqType', 'Snowflake', 'SnowflakeGen', 'StringCase', 'TimedDict', 'TomlI18n', 'UserSigner', 'Wanted', 'WantsContentType', diff --git a/src/suou/color.py b/src/suou/color.py index cbbf2d0..26bf060 100644 --- a/src/suou/color.py +++ b/src/suou/color.py @@ -5,7 +5,7 @@ Colors for coding artists --- -Copyright (c) 2025 Sakuragasaki46. +Copyright (c) 2025-2026 Sakuragasaki46. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -244,7 +244,7 @@ class XYZColor(namedtuple('_XYZColor', 'x y z')): def to_oklab(self): lms = (self.XYZ_TO_LMS @ Matrix.as_column(self)).get_column() lmsg = [math.cbrt(i) for i in lms] - oklab = (self.LMSG_TO_OKLAB @ Matrix.as_column(self)).get_column() + oklab = (self.LMSG_TO_OKLAB @ Matrix.as_column(lmsg)).get_column() return OKLabColor(*oklab) def to_oklch(self): @@ -326,5 +326,9 @@ class OKLCHColor(namedtuple('_OKLCHColor', 'l c h')): def to_rgb(self): return self.to_oklab().to_rgb() + def __sub__(self, other: OKLCHColor): + """For testing only!""" + return sum(abs(i - j) / k for i, j, k in zip(self, other, (1, 1, 36))) + __all__ = ('chalk', 'WebColor', "RGBColor", 'LinearRGBColor', 'XYZColor', 'OKLabColor', 'OKLCHColor') diff --git a/src/suou/quart_auth.py b/src/suou/quart_auth.py index 6797841..f57db55 100644 --- a/src/suou/quart_auth.py +++ b/src/suou/quart_auth.py @@ -1,9 +1,11 @@ """ Utilities for Quart-Auth +(Require Quart and SQLAlchemy) + --- -Copyright (c) 2025 Sakuragasaki46. +Copyright (c) 2025-2026 Sakuragasaki46. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/tests/test_color.py b/tests/test_color.py index 8b8a732..a941b0e 100644 --- a/tests/test_color.py +++ b/tests/test_color.py @@ -33,5 +33,8 @@ class TestColor(unittest.TestCase): self.assertEqual(OKLCHColor(0.5932, 0., 0.).to_rgb(), RGBColor(126, 126, 126)) def test_rgb_to_oklch(self): - self.assertEqual(RGBColor(222, 62, 45).to_oklch(), OKLCHColor(0.6,0.2, 30.)) - self.assertEqual(RGBColor(156, 123, 49).to_oklch(), OKLCHColor(.6, .1, 85.)) \ No newline at end of file + """ + This requires the presence of OKLCHColor.__sub__(), not to be used in production code. + """ + self.assertAlmostEqual(RGBColor(222, 62, 45).to_oklch(), OKLCHColor(0.6,0.2, 30.), delta=0.01) + self.assertAlmostEqual(RGBColor(156, 123, 48).to_oklch(), OKLCHColor(.6, .1, 85.), delta=0.01) \ No newline at end of file