Skip to content

Commit 3ef7846

Browse files
committed
Remove arbitrary EPSILON
1 parent aad4f11 commit 3ef7846

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

crates/bevy_color/src/okcolor_convert.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,15 @@ pub(crate) fn oklab_to_okhsl(value: Oklaba) -> Okhsla {
301301
alpha,
302302
} = value;
303303
// Patch: Fixes NaN for pure black and white colors.
304-
if lab_l >= 1.0 - f32::EPSILON {
304+
if lab_l >= 1.0 {
305305
return Okhsla {
306306
hue: 0.0,
307307
saturation: 0.0,
308308
lightness: 1.0,
309309
alpha,
310310
};
311311
}
312-
if lab_l <= f32::EPSILON {
312+
if lab_l <= 0.0 {
313313
return Okhsla {
314314
hue: 0.0,
315315
saturation: 0.0,
@@ -318,7 +318,7 @@ pub(crate) fn oklab_to_okhsl(value: Oklaba) -> Okhsla {
318318
};
319319
}
320320
let C = ops::sqrt(lab_a * lab_a + lab_b * lab_b);
321-
if C <= f32::EPSILON {
321+
if C == 0. {
322322
let l = toe(lab_l);
323323
return Okhsla {
324324
hue: 0.,
@@ -376,9 +376,9 @@ pub(crate) fn okhsl_to_oklab(value: Okhsla) -> Oklaba {
376376
} = value;
377377
let h = h / 360.;
378378

379-
if l == 1. {
379+
if l >= 1. {
380380
return LinearRgba::new(1., 1., 1., alpha).into();
381-
} else if l == 0. {
381+
} else if l <= 0. {
382382
return LinearRgba::new(0., 0., 0., alpha).into();
383383
}
384384

@@ -424,15 +424,15 @@ pub(crate) fn oklab_to_okhsv(value: Oklaba) -> Okhsva {
424424
alpha,
425425
} = value;
426426
// Patch: Fixes NaN for pure black and white colors.
427-
if lab_l >= 1.0 - f32::EPSILON {
427+
if lab_l >= 1.0 {
428428
return Okhsva {
429429
hue: 0.0,
430430
saturation: 0.0,
431431
value: 1.0,
432432
alpha,
433433
};
434434
}
435-
if lab_l <= f32::EPSILON {
435+
if lab_l <= 0.0 {
436436
return Okhsva {
437437
hue: 0.0,
438438
saturation: 0.0,
@@ -441,7 +441,7 @@ pub(crate) fn oklab_to_okhsv(value: Oklaba) -> Okhsva {
441441
};
442442
}
443443
let C = ops::sqrt(lab_a * lab_a + lab_b * lab_b);
444-
if C <= f32::EPSILON {
444+
if C == 0. {
445445
// In this case, value is equal to lightness.
446446
let l = toe(lab_l);
447447
return Okhsva {
@@ -504,7 +504,7 @@ pub(crate) fn okhsv_to_oklab(value: Okhsva) -> Oklaba {
504504
} = value;
505505
let h = h / 360.;
506506

507-
if v == 0. {
507+
if v <= 0. {
508508
return LinearRgba::new(0., 0., 0., alpha).into();
509509
}
510510

0 commit comments

Comments
 (0)