Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coloraide/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,5 @@ def parse_version(ver: str) -> Version:
return Version(major, minor, micro, release, pre, post, dev)


__version_info__ = Version(4, 4, 0, "final")
__version_info__ = Version(4, 4, 1, "final")
__version__ = __version_info__._get_canonical()
22 changes: 12 additions & 10 deletions coloraide/spaces/xyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,36 @@
[-3.6588512867136815, 2.712923045936092, 1.945928240777589]
]

# https://twitter.com/jonsneyers/status/1605321352143331328
# @jonsneyers Feb 22
# Yes, the default is to just subtract Y from B. In general there are locally
# signaled float multipliers to subtract some multiple of Y from X and some
# other multiple from B. But this is the baseline, making X=B=0 grayscale.
# ----
# We adjust the matrix to subtract Y from B match this statement.
XYB_LMS_TO_XYB = [
[0.5, -0.5, 0.0],
[0.5, 0.5, 0.0],
[0.0, -1.0, 1.0],
[0.0, 0.0, 1.0]
]

XYB_TO_XYB_LMS = [
[1.0, 1.0, 0.0],
[-1.0, 1.0, 0.0],
[-1.0, 1.0, 1.0]
[0.0, 0.0, 1.0]
]


def rgb_to_xyb(rgb: Vector) -> Vector:
"""Linear sRGB to XYB."""

return alg.matmul_x3(
xyb = alg.matmul_x3(
XYB_LMS_TO_XYB,
[alg.nth_root(c + BIAS, 3) - BIAS_CBRT for c in alg.matmul_x3(LRGB_TO_LMS, rgb, dims=alg.D2_D1)],
dims=alg.D2_D1
)

# https://twitter.com/jonsneyers/status/1605321352143331328
# @jonsneyers Feb 22
# Yes, the default is to just subtract Y from B. In general there are locally
# signaled float multipliers to subtract some multiple of Y from X and some
# other multiple from B. But this is the baseline, making X=B=0 grayscale.
xyb[2] -= xyb[1]
return xyb


def xyb_to_rgb(xyb: Vector) -> Vector:
"""XYB to linear sRGB."""
Expand All @@ -62,6 +63,7 @@ def xyb_to_rgb(xyb: Vector) -> Vector:
if not any(xyb):
return [0.0] * 3

xyb[2] += xyb[1]
return alg.matmul_x3(
LMS_TO_LRGB,
[(c + BIAS_CBRT) ** 3 - BIAS for c in alg.matmul_x3(XYB_TO_XYB_LMS, xyb, dims=alg.D2_D1)],
Expand Down
4 changes: 4 additions & 0 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.4.1

- **FIX**: Fix XYB transform.

## 4.4

- **NEW**: Add support for the CAM02 color model and add the CAM02 JMh, CAM02 UCS, CAM02 SCD, and CAM02 LCD color
Expand Down
2 changes: 1 addition & 1 deletion docs/src/markdown/demos/3d_models.html
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ <h1>ColorAide Color Space Models</h1>
let colorSpaces = null
let colorGamuts = null
let lastModel = null
let package = 'coloraide-4.4-py3-none-any.whl'
let package = 'coloraide-4.4.1-py3-none-any.whl'
const defaultSpace = 'lab'
const defaultGamut = 'srgb'
const exceptions = new Set(['hwb', 'ryb', 'ryb-biased'])
Expand Down
2 changes: 1 addition & 1 deletion docs/src/markdown/demos/colorpicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ <h1>ColorAide Color Picker</h1>
let pyodide = null
let webspace = ''
let initial = 'oklab(0.69 0.13 -0.1 / 0.85)'
let package = 'coloraide-4.4-py3-none-any.whl'
let package = 'coloraide-4.4.1-py3-none-any.whl'

const base = `${window.location.origin}/${window.location.pathname.split('/')[1]}/playground/`
package = base + package
Expand Down
Binary file modified docs/src/markdown/images/xyb-3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/src/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ extra_css:
extra_javascript:
- https://cdn.jsdelivr.net/npm/ace-builds@1.39.0/src-min-noconflict/ace.js
- https://cdn.jsdelivr.net/npm/mermaid@11.5.0/dist/mermaid.min.js
- playground-config-362fea92.js
- playground-config-d112cc38.js
- https://cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.js
- assets/coloraide-extras/extra-notebook.js

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var colorNotebook = {
"playgroundWheels": ['micropip', 'pygments-2.19.1-py3-none-any.whl', 'coloraide-4.4-py3-none-any.whl'],
"notebookWheels": ['pyyaml', 'Markdown-3.7-py3-none-any.whl', 'pymdown_extensions-10.14.3-py3-none-any.whl', 'micropip', 'pygments-2.19.1-py3-none-any.whl', 'coloraide-4.4-py3-none-any.whl'],
"playgroundWheels": ['micropip', 'pygments-2.19.1-py3-none-any.whl', 'coloraide-4.4.1-py3-none-any.whl'],
"notebookWheels": ['pyyaml', 'Markdown-3.7-py3-none-any.whl', 'pymdown_extensions-10.14.3-py3-none-any.whl', 'micropip', 'pygments-2.19.1-py3-none-any.whl', 'coloraide-4.4.1-py3-none-any.whl'],
"defaultPlayground": "import coloraide\ncoloraide.__version__\nColor('red')"
}
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ extra_css:
extra_javascript:
- https://cdn.jsdelivr.net/npm/ace-builds@1.39.0/src-min-noconflict/ace.js
- https://cdn.jsdelivr.net/npm/mermaid@11.5.0/dist/mermaid.min.js
- playground-config-362fea92.js
- playground-config-d112cc38.js
- https://cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.js
- assets/coloraide-extras/extra-notebook-CuRWK8GL.js

Expand Down
10 changes: 5 additions & 5 deletions tests/test_xyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ class TestXYB(util.ColorAssertsPyTest):
"""Test XYB."""

COLORS = [
('red', 'color(--xyb 0.0281 0.48819 0.01157)'),
('orange', 'color(--xyb 0.01132 0.64596 -0.10359)'),
('red', 'color(--xyb 0.0281 0.48819 -0.01653)'),
('orange', 'color(--xyb 0.01132 0.64596 -0.1149)'),
('yellow', 'color(--xyb 0 0.81867 -0.20719)'),
('green', 'color(--xyb -0.0091 0.36999 -0.17163)'),
('green', 'color(--xyb -0.0091 0.36999 -0.16253)'),
('blue', 'color(--xyb 0 0.27813 0.38801)'),
('indigo', 'color(--xyb 0.00704 0.18547 0.18989)'),
('violet', 'color(--xyb 0.01268 0.60656 0.15033)'),
('indigo', 'color(--xyb 0.00704 0.18547 0.18285)'),
('violet', 'color(--xyb 0.01268 0.60656 0.13766)'),
('white', 'color(--xyb 0 0.84531 0)'),
('gray', 'color(--xyb 0 0.44741 0)'),
('black', 'color(--xyb 0 0 0)'),
Expand Down