Skip to content

Commit

Permalink
Add the original source for Oklab conversions (#17199)
Browse files Browse the repository at this point in the history
# Objective

- Add the original source for Oklab calculations (a blog from the
creator of Oklab) instead of linking to other Rust crates.

## Solution

- Update the links.
  • Loading branch information
eero-lehtinen authored Jan 7, 2025
1 parent f896ad8 commit 7cd1cba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_color/src/oklaba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ impl From<LinearRgba> for Oklaba {
blue,
alpha,
} = value;
// From https://github.com/DougLau/pix
// Floats literals are truncated from the source code above, to avoid excessive precision.
// From https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab
// Float literals are truncated to avoid excessive precision.
let l = 0.41222146 * red + 0.53633255 * green + 0.051445995 * blue;
let m = 0.2119035 * red + 0.6806995 * green + 0.10739696 * blue;
let s = 0.08830246 * red + 0.28171885 * green + 0.6299787 * blue;
Expand All @@ -248,8 +248,8 @@ impl From<Oklaba> for LinearRgba {
alpha,
} = value;

// From https://github.com/Ogeon/palette/blob/e75eab2fb21af579353f51f6229a510d0d50a311/palette/src/oklab.rs#L312-L332
// Floats literals are truncated from the source code above, to avoid excessive precision.
// From https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab
// Float literals are truncated to avoid excessive precision.
let l_ = lightness + 0.39633778 * a + 0.21580376 * b;
let m_ = lightness - 0.105561346 * a - 0.06385417 * b;
let s_ = lightness - 0.08948418 * a - 1.2914855 * b;
Expand Down

0 comments on commit 7cd1cba

Please sign in to comment.