Skip to content

Commit

Permalink
Testing overhaul phase 1
Browse files Browse the repository at this point in the history
Now have test black, white, primary, secondary, overblown, and negative

Actually everything looks good except JzAzBz of course, but that's what
encouraged me to make this test in the first place.

Idk how to fix it tbh, NaNs aren't fun.
I'll have to look at the matlab or python code see if they have guards.
  • Loading branch information
Beinsezii committed Dec 24, 2023
1 parent ac66032 commit 994f1d5
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 162 deletions.
20 changes: 18 additions & 2 deletions scripts/colour_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
import colour
import numpy as np

def rustprint(id, arr):
layers = ""
for a in arr:
layers += f" [{a[0]:.8f}, {a[1]:.8f}, {a[2]:.8f}],\n"
print(f"const {id.upper()}: &'static [[f32; 3]] = &[\n{layers}];")

d65 = colour.xyY_to_XYZ(colour.xy_to_xyY(colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"]))
srgb = np.array([0.2, 0.35, 0.95], dtype=np.float64)
srgb = np.array([
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[1.0, 1.0, 0.0],
[0.0, 1.0, 1.0],
[1.0, 0.0, 1.0],
[1.0, 1.0, 1.0],
[5.0, 10.0, 15.0],
[-5.0, -10.0, -15.0],
], dtype=np.float32)
lrgb = colour.models.eotf_sRGB(srgb)
hsv = colour.RGB_to_HSV(srgb)
xyz = colour.sRGB_to_XYZ(srgb)
Expand All @@ -21,7 +38,6 @@

print(f"pub const D65: [f32; 3] = [{d65[0]}, {d65[1]}, {d65[2]}];")

rustprint = lambda id, arr: print(f"const {id.upper()}: [f32; 3] = [{arr[0]:.8f}, {arr[1]:.8f}, {arr[2]:.8f}];")
print()

rustprint('srgb', srgb)
Expand Down
Loading

0 comments on commit 994f1d5

Please sign in to comment.