0.12.0 "The Color Update"
This commit is contained in:
parent
edd52ffeed
commit
36f7927597
7 changed files with 40 additions and 11 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.))
|
||||
"""
|
||||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue