Skip to content

Commit

Permalink
Fixed bug in documentation of colorsynth.d65_standard_illuminant()
Browse files Browse the repository at this point in the history
…where a link wasn't being rendered properly.
  • Loading branch information
byrdie committed Nov 15, 2023
1 parent afffb8f commit f440fe8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions colorsynth/_colorsynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def d65_standard_illuminant(
which corresponds to average midday light in Western/Northern Europe.
This function interpolates the
`tabulated SPD <https://web.archive.org/web/20171122140854/http://www.cie.co.at/publ/abst/datatables15_2004/std65.txt>`
`tabulated SPD <https://web.archive.org/web/20171122140854/http://www.cie.co.at/publ/abst/datatables15_2004/std65.txt>`_
provided by CIE.
Parameters
Expand Down Expand Up @@ -313,6 +313,7 @@ def cie_1931_tristimulus(
y=integrand,
axis=axis,
)
result = np.abs(result)
result = np.moveaxis(
a=result,
source=0,
Expand Down Expand Up @@ -405,12 +406,12 @@ def srgb(
.. jupyter-execute::
x = np.linspace(0, 1, num=100)[:, np.newaxis]
y = np.linspace(0, 1, num=101)[np.newaxis, :]
x = np.linspace(0, 1, num=1000)[:, np.newaxis]
y = np.linspace(0, 1, num=1001)[np.newaxis, :]
x, y = np.broadcast_arrays(x, y)
z = 1 - x - y
Y = 0.5
Y = 0.9
X = Y * x / y
Z = Y * z / y
XYZ = [
Expand All @@ -421,12 +422,16 @@ def srgb(
XYZ = np.stack(XYZ, axis=-1)
rgb = colorsynth.srgb(XYZ, axis=-1)
rgb = np.clip(rgb, 0, 1)
# rgb = np.clip(rgb, 0, 1)
rgb[X < 0] = 1
rgb[Z < 0] = 1
rgb[X >= 0.9505] = 1
rgb[Z >= 1.0890] = 1
# rgb[X < 0] = 1
# rgb[Z < 0] = 1
# rgb[X >= 0.9505] = 1
# rgb[Z >= 1.0890] = 1
# rgb[rgb.sum(axis=-1) > 1] = 1
# rgb[np.any(rgb < 0, axis=-1)] = 1
# rgb[np.any(rgb > 1, axis=-1)] = 1
plt.figure();
plt.pcolormesh(x, y, rgb);
Expand Down

0 comments on commit f440fe8

Please sign in to comment.