mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Janitor: Replace float comparison dance with approx_eq from euclid
Sixtyfps uses euclid already, so let's use euclid for float comparisons as well. I changed the code to decide whether a number is a positive integer to make do without a comparison along the way.
This commit is contained in:
parent
e45635656d
commit
02bdcbf6ff
6 changed files with 11 additions and 11 deletions
|
@ -14,6 +14,7 @@ mod lsp_ext;
|
|||
mod preview;
|
||||
mod util;
|
||||
|
||||
use euclid::approxeq::ApproxEq;
|
||||
use std::collections::HashMap;
|
||||
use structopt::StructOpt;
|
||||
|
||||
|
@ -271,7 +272,7 @@ fn handle_request(
|
|||
// representation.
|
||||
let requested_color = params.color;
|
||||
|
||||
let color_literal = if (requested_color.alpha - 1.).abs() > 10.0 * f32::EPSILON {
|
||||
let color_literal = if requested_color.alpha.approx_eq(&1.) {
|
||||
format!(
|
||||
"#{:0>2x}{:0>2x}{:0>2x}{:0>2x}",
|
||||
(requested_color.red * 255.) as u8,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue