Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename matrix _min_v to _m_inv because it's the inverse of _m #41

Merged
merged 3 commits into from
Dec 9, 2022
Merged
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
14 changes: 8 additions & 6 deletions hsluv.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
from functools import wraps as _wraps, partial as _partial # unexport, see #17
import math as _math # unexport, see #17

# XYZ-to-sRGB matrix
_m = [[3.240969941904521, -1.537383177570093, -0.498610760293],
[-0.96924363628087, 1.87596750150772, 0.041555057407175],
[0.055630079696993, -0.20397695888897, 1.056971514242878]]
_min_v = [[0.41239079926595, 0.35758433938387, 0.18048078840183],
# sRGB-to-XYZ matrix
_m_inv = [[0.41239079926595, 0.35758433938387, 0.18048078840183],
[0.21263900587151, 0.71516867876775, 0.072192315360733],
[0.019330818715591, 0.11919477979462, 0.95053215224966]]
_ref_y = 1.0
_ref_u = 0.19783000664283
_ref_v = 0.46831999493879
_kappa = 903.2962962
_epsilon = 0.0088564516
_kappa = 903.2962962 # 24389/27 == (29/3)**3
_epsilon = 0.0088564516 # 216/24389 == (6/29)**3


def _normalize_output(conversion):
Expand Down Expand Up @@ -124,9 +126,9 @@ def rgb_to_xyz(_hx_tuple):
rgbl = (_to_linear(_hx_tuple[0]),
_to_linear(_hx_tuple[1]),
_to_linear(_hx_tuple[2]))
return (_dot_product(_min_v[0], rgbl),
_dot_product(_min_v[1], rgbl),
_dot_product(_min_v[2], rgbl))
return (_dot_product(_m_inv[0], rgbl),
_dot_product(_m_inv[1], rgbl),
_dot_product(_m_inv[2], rgbl))


def xyz_to_luv(_hx_tuple):
Expand Down