From cde8dd78e69d30404bb9a784fb50a8e79a81382c Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Fri, 12 Jun 2026 19:47:36 -0700 Subject: [PATCH] Remove stray float literal .0 suffixes in lieu of just ending with a point (#4233) Remove the .0 suffix on floats in lieu of just ending with a point --- desktop/src/app.rs | 4 +- desktop/src/cef/consts.rs | 10 ++--- desktop/src/render/state.rs | 4 +- .../document/overlays/utility_functions.rs | 4 +- .../document/overlays/utility_types_native.rs | 4 +- .../viewport/viewport_message_handler.rs | 18 ++++----- libraries/math-parser/src/constants.rs | 4 +- libraries/math-parser/src/executer.rs | 36 +++++++++--------- libraries/math-parser/src/lib.rs | 20 +++++----- libraries/math-parser/src/parser.rs | 36 +++++++++--------- libraries/math-parser/src/value.rs | 4 +- node-graph/graphene-cli/src/export.rs | 2 +- .../libraries/graphic-types/src/graphic.rs | 12 +++--- .../no-std-types/src/color/color_types.rs | 14 +++---- .../no-std-types/src/color/discrete_srgb.rs | 2 +- .../vector/algorithms/bezpath_algorithms.rs | 10 ++--- .../src/vector/algorithms/spline.rs | 8 ++-- .../vector-types/src/vector/click_target.rs | 38 +++++++++---------- .../libraries/vector-types/src/vector/misc.rs | 4 +- .../wgpu-executor/src/background/mod.rs | 4 +- node-graph/nodes/gstd/src/pixel_preview.rs | 2 +- node-graph/nodes/gstd/src/render_cache.rs | 8 ++-- .../nodes/raster/src/fullscreen_vertex.rs | 2 +- 23 files changed, 125 insertions(+), 125 deletions(-) diff --git a/desktop/src/app.rs b/desktop/src/app.rs index 841780da18..1c0841d7c7 100644 --- a/desktop/src/app.rs +++ b/desktop/src/app.rs @@ -280,8 +280,8 @@ impl App { let viewport_offset_y = y / window_size.height as f64; render_state.set_viewport_offset([viewport_offset_x as f32, viewport_offset_y as f32]); - let viewport_scale_x = if width != 0.0 { window_size.width as f64 / width } else { 1.0 }; - let viewport_scale_y = if height != 0.0 { window_size.height as f64 / height } else { 1.0 }; + let viewport_scale_x = if width != 0. { window_size.width as f64 / width } else { 1. }; + let viewport_scale_y = if height != 0. { window_size.height as f64 / height } else { 1. }; render_state.set_viewport_scale([viewport_scale_x as f32, viewport_scale_y as f32]); } } diff --git a/desktop/src/cef/consts.rs b/desktop/src/cef/consts.rs index ced6f6e105..62b5aad288 100644 --- a/desktop/src/cef/consts.rs +++ b/desktop/src/cef/consts.rs @@ -8,16 +8,16 @@ pub(crate) const SCROLL_LINE_HEIGHT: usize = 40; pub(crate) const SCROLL_LINE_WIDTH: usize = 40; #[cfg(target_os = "linux")] -pub(crate) const SCROLL_SPEED_X: f32 = 3.0; +pub(crate) const SCROLL_SPEED_X: f32 = 3.; #[cfg(target_os = "linux")] -pub(crate) const SCROLL_SPEED_Y: f32 = 3.0; +pub(crate) const SCROLL_SPEED_Y: f32 = 3.; #[cfg(not(target_os = "linux"))] -pub(crate) const SCROLL_SPEED_X: f32 = 1.0; +pub(crate) const SCROLL_SPEED_X: f32 = 1.; #[cfg(not(target_os = "linux"))] -pub(crate) const SCROLL_SPEED_Y: f32 = 1.0; +pub(crate) const SCROLL_SPEED_Y: f32 = 1.; -pub(crate) const PINCH_ZOOM_SPEED: f64 = 300.0; +pub(crate) const PINCH_ZOOM_SPEED: f64 = 300.; pub(crate) const MULTICLICK_TIMEOUT: Duration = Duration::from_millis(DOUBLE_CLICK_MILLISECONDS); pub(crate) const MULTICLICK_ALLOWED_TRAVEL: usize = 4; diff --git a/desktop/src/render/state.rs b/desktop/src/render/state.rs index 2a3ec3b458..27a9b5c67a 100644 --- a/desktop/src/render/state.rs +++ b/desktop/src/render/state.rs @@ -174,8 +174,8 @@ impl RenderState { sampler, desired_width: size.width, desired_height: size.height, - viewport_scale: [1.0, 1.0], - viewport_offset: [0.0, 0.0], + viewport_scale: [1., 1.], + viewport_offset: [0., 0.], viewport_texture: None, overlays_texture: None, ui_texture: None, diff --git a/editor/src/messages/portfolio/document/overlays/utility_functions.rs b/editor/src/messages/portfolio/document/overlays/utility_functions.rs index 00ac3851ee..1d7bd1e54a 100644 --- a/editor/src/messages/portfolio/document/overlays/utility_functions.rs +++ b/editor/src/messages/portfolio/document/overlays/utility_functions.rs @@ -228,10 +228,10 @@ pub fn text_width(text: &str, font_size: f64) -> f64 { let typesetting = TypesettingConfig { font_size, line_height_ratio: 1.2, - character_spacing: 0.0, + character_spacing: 0., max_width: None, max_height: None, - tilt: 0.0, + tilt: 0., align: TextAlign::AlignLeft, }; diff --git a/editor/src/messages/portfolio/document/overlays/utility_types_native.rs b/editor/src/messages/portfolio/document/overlays/utility_types_native.rs index bf73ebe07b..e519c8a06a 100644 --- a/editor/src/messages/portfolio/document/overlays/utility_types_native.rs +++ b/editor/src/messages/portfolio/document/overlays/utility_types_native.rs @@ -1215,7 +1215,7 @@ impl OverlayContextInternal { fn snap_to_physical_pixel(&self, p: DVec2) -> DVec2 { let s = self.viewport.scale(); - if !s.is_finite() || s <= 0.0 { + if !s.is_finite() || s <= 0. { return p.round(); } (p * s).round() / s @@ -1223,7 +1223,7 @@ impl OverlayContextInternal { fn snap_to_physical_pixel_center(&self, p: DVec2) -> DVec2 { let s = self.viewport.scale(); - if !s.is_finite() || s <= 0.0 { + if !s.is_finite() || s <= 0. { return p.round() - DVec2::splat(0.5); } self.snap_to_physical_pixel(p) - DVec2::splat(0.5 / s) diff --git a/editor/src/messages/viewport/viewport_message_handler.rs b/editor/src/messages/viewport/viewport_message_handler.rs index 8a3196119b..0c98424a60 100644 --- a/editor/src/messages/viewport/viewport_message_handler.rs +++ b/editor/src/messages/viewport/viewport_message_handler.rs @@ -17,7 +17,7 @@ impl Default for ViewportMessageHandler { offset: Point { x: 0., y: 0. }, size: Point { x: 0., y: 0. }, }, - scale: 1.0, + scale: 1., } } } @@ -400,14 +400,14 @@ impl FromWithScale for PhysicalBounds { impl Mul for Point { type Output = Point; fn mul(self, rhs: f64) -> Self::Output { - assert_ne!(rhs, 0.0, "Cannot multiply point by zero"); + assert_ne!(rhs, 0., "Cannot multiply point by zero"); Point { x: self.x * rhs, y: self.y * rhs } } } impl Div for Point { type Output = Point; fn div(self, rhs: f64) -> Self::Output { - assert_ne!(rhs, 0.0, "Cannot divide point by zero"); + assert_ne!(rhs, 0., "Cannot divide point by zero"); Point { x: self.x / rhs, y: self.y / rhs } } } @@ -426,16 +426,16 @@ impl Sub for Point { impl Mul for Point { type Output = Point; fn mul(self, rhs: Point) -> Self::Output { - assert_ne!(rhs.x, 0.0, "Cannot multiply point by zero"); - assert_ne!(rhs.y, 0.0, "Cannot multiply point by zero"); + assert_ne!(rhs.x, 0., "Cannot multiply point by zero"); + assert_ne!(rhs.y, 0., "Cannot multiply point by zero"); Point { x: self.x * rhs.x, y: self.y * rhs.y } } } impl Div for Point { type Output = Point; fn div(self, rhs: Point) -> Self::Output { - assert_ne!(rhs.x, 0.0, "Cannot multiply point by zero"); - assert_ne!(rhs.y, 0.0, "Cannot multiply point by zero"); + assert_ne!(rhs.x, 0., "Cannot multiply point by zero"); + assert_ne!(rhs.y, 0., "Cannot multiply point by zero"); Point { x: self.x / rhs.x, y: self.y / rhs.y } } } @@ -455,7 +455,7 @@ impl Sub for Point { impl Mul for Bounds { type Output = Bounds; fn mul(self, rhs: f64) -> Self::Output { - assert_ne!(rhs, 0.0, "Cannot multiply bounds by zero"); + assert_ne!(rhs, 0., "Cannot multiply bounds by zero"); Bounds { offset: self.offset * rhs, size: self.size * rhs, @@ -465,7 +465,7 @@ impl Mul for Bounds { impl Div for Bounds { type Output = Bounds; fn div(self, rhs: f64) -> Self::Output { - assert_ne!(rhs, 0.0, "Cannot divide bounds by zero"); + assert_ne!(rhs, 0., "Cannot divide bounds by zero"); Bounds { offset: self.offset / rhs, size: self.size / rhs, diff --git a/libraries/math-parser/src/constants.rs b/libraries/math-parser/src/constants.rs index c010d13253..f2ca33c646 100644 --- a/libraries/math-parser/src/constants.rs +++ b/libraries/math-parser/src/constants.rs @@ -111,8 +111,8 @@ lazy_static! { map.insert( "invcot", Box::new(|values| match values { - [Value::Number(Number::Real(real))] => Some(Value::Number(Number::Real((PI / 2.0 - real).atan()))), - [Value::Number(Number::Complex(complex))] => Some(Value::Number(Number::Complex((Complex::new(PI / 2.0, 0.0) - complex).atan()))), + [Value::Number(Number::Real(real))] => Some(Value::Number(Number::Real((PI / 2. - real).atan()))), + [Value::Number(Number::Complex(complex))] => Some(Value::Number(Number::Complex((Complex::new(PI / 2., 0.) - complex).atan()))), _ => None, }), ); diff --git a/libraries/math-parser/src/executer.rs b/libraries/math-parser/src/executer.rs index 9d6180f1ab..3d5394dd4a 100644 --- a/libraries/math-parser/src/executer.rs +++ b/libraries/math-parser/src/executer.rs @@ -63,38 +63,38 @@ mod tests { } eval_tests! { - test_addition: Value::from_f64(7.0) => Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(3.0))), + test_addition: Value::from_f64(7.) => Node::BinOp { + lhs: Box::new(Node::Lit(Literal::Float(3.))), op: BinaryOp::Add, - rhs: Box::new(Node::Lit(Literal::Float(4.0))), + rhs: Box::new(Node::Lit(Literal::Float(4.))), }, - test_subtraction: Value::from_f64(1.0) => Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(5.0))), + test_subtraction: Value::from_f64(1.) => Node::BinOp { + lhs: Box::new(Node::Lit(Literal::Float(5.))), op: BinaryOp::Sub, - rhs: Box::new(Node::Lit(Literal::Float(4.0))), + rhs: Box::new(Node::Lit(Literal::Float(4.))), }, - test_multiplication: Value::from_f64(12.0) => Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(3.0))), + test_multiplication: Value::from_f64(12.) => Node::BinOp { + lhs: Box::new(Node::Lit(Literal::Float(3.))), op: BinaryOp::Mul, - rhs: Box::new(Node::Lit(Literal::Float(4.0))), + rhs: Box::new(Node::Lit(Literal::Float(4.))), }, test_division: Value::from_f64(2.5) => Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(5.0))), + lhs: Box::new(Node::Lit(Literal::Float(5.))), op: BinaryOp::Div, - rhs: Box::new(Node::Lit(Literal::Float(2.0))), + rhs: Box::new(Node::Lit(Literal::Float(2.))), }, - test_negation: Value::from_f64(-3.0) => Node::UnaryOp { - expr: Box::new(Node::Lit(Literal::Float(3.0))), + test_negation: Value::from_f64(-3.) => Node::UnaryOp { + expr: Box::new(Node::Lit(Literal::Float(3.))), op: UnaryOp::Neg, }, - test_sqrt: Value::from_f64(2.0) => Node::UnaryOp { - expr: Box::new(Node::Lit(Literal::Float(4.0))), + test_sqrt: Value::from_f64(2.) => Node::UnaryOp { + expr: Box::new(Node::Lit(Literal::Float(4.))), op: UnaryOp::Sqrt, }, - test_power: Value::from_f64(8.0) => Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(2.0))), + test_power: Value::from_f64(8.) => Node::BinOp { + lhs: Box::new(Node::Lit(Literal::Float(2.))), op: BinaryOp::Pow, - rhs: Box::new(Node::Lit(Literal::Float(3.0))), + rhs: Box::new(Node::Lit(Literal::Float(3.))), }, } } diff --git a/libraries/math-parser/src/lib.rs b/libraries/math-parser/src/lib.rs index e596d78dff..40e56ce04f 100644 --- a/libraries/math-parser/src/lib.rs +++ b/libraries/math-parser/src/lib.rs @@ -130,20 +130,20 @@ mod tests { constant_pi: "pi" => (std::f64::consts::PI, Unit::BASE_UNIT), constant_e: "e" => (std::f64::consts::E, Unit::BASE_UNIT), constant_phi: "phi" => (1.61803398875, Unit::BASE_UNIT), - constant_tau: "tau" => (2.0 * std::f64::consts::PI, Unit::BASE_UNIT), + constant_tau: "tau" => (2. * std::f64::consts::PI, Unit::BASE_UNIT), constant_infinity: "inf" => (f64::INFINITY, Unit::BASE_UNIT), constant_infinity_symbol: "∞" => (f64::INFINITY, Unit::BASE_UNIT), - multiply_pi: "2 * pi" => (2.0 * std::f64::consts::PI, Unit::BASE_UNIT), - add_e_constant: "e + 1" => (std::f64::consts::E + 1.0, Unit::BASE_UNIT), - multiply_phi_constant: "phi * 2" => (1.61803398875 * 2.0, Unit::BASE_UNIT), - exponent_tau: "2^tau" => (2f64.powf(2.0 * std::f64::consts::PI), Unit::BASE_UNIT), + multiply_pi: "2 * pi" => (2. * std::f64::consts::PI, Unit::BASE_UNIT), + add_e_constant: "e + 1" => (std::f64::consts::E + 1., Unit::BASE_UNIT), + multiply_phi_constant: "phi * 2" => (1.61803398875 * 2., Unit::BASE_UNIT), + exponent_tau: "2^tau" => (2f64.powf(2. * std::f64::consts::PI), Unit::BASE_UNIT), infinity_subtract_large_number: "inf - 1000" => (f64::INFINITY, Unit::BASE_UNIT), // Trigonometric functions - trig_sin_pi: "sin(pi)" => (0.0, Unit::BASE_UNIT), - trig_cos_zero: "cos(0)" => (1.0, Unit::BASE_UNIT), - trig_tan_pi_div_four: "tan(pi/4)" => (1.0, Unit::BASE_UNIT), - trig_sin_tau: "sin(tau)" => (0.0, Unit::BASE_UNIT), - trig_cos_tau_div_two: "cos(tau/2)" => (-1.0, Unit::BASE_UNIT), + trig_sin_pi: "sin(pi)" => (0., Unit::BASE_UNIT), + trig_cos_zero: "cos(0)" => (1., Unit::BASE_UNIT), + trig_tan_pi_div_four: "tan(pi/4)" => (1., Unit::BASE_UNIT), + trig_sin_tau: "sin(tau)" => (0., Unit::BASE_UNIT), + trig_cos_tau_div_two: "cos(tau/2)" => (-1., Unit::BASE_UNIT), } } diff --git a/libraries/math-parser/src/parser.rs b/libraries/math-parser/src/parser.rs index e707b500f4..9389915b92 100644 --- a/libraries/math-parser/src/parser.rs +++ b/libraries/math-parser/src/parser.rs @@ -68,7 +68,7 @@ impl NodeMetadata { } fn parse_unit(pairs: Pairs) -> Result<(Unit, f64), ParseError> { - let mut scale = 1.0; + let mut scale = 1.; let mut length = 0; let mut mass = 0; let mut time = 0; @@ -102,9 +102,9 @@ fn parse_unit(pairs: Pairs) -> Result<(Unit, f64), ParseError> { fn parse_const(pair: Pair) -> Literal { match pair.as_rule() { Rule::infinity => Literal::Float(f64::INFINITY), - Rule::imaginary_unit => Literal::Complex(Complex::new(0.0, 1.0)), + Rule::imaginary_unit => Literal::Complex(Complex::new(0., 1.)), Rule::pi => Literal::Float(std::f64::consts::PI), - Rule::tau => Literal::Float(2.0 * std::f64::consts::PI), + Rule::tau => Literal::Float(2. * std::f64::consts::PI), Rule::euler_number => Literal::Float(std::f64::consts::E), Rule::golden_ratio => Literal::Float(1.61803398875), _ => unreachable!("Unexpected constant: {:?}", pair), @@ -327,52 +327,52 @@ mod tests { } test_parser! { - test_parse_int_literal: "42" => Node::Lit(Literal::Float(42.0)), + test_parse_int_literal: "42" => Node::Lit(Literal::Float(42.)), test_parse_float_literal: "3.14" => Node::Lit(Literal::Float(#[allow(clippy::approx_constant)] 3.14)), test_parse_ident: "x" => Node::Var("x".to_string()), test_parse_unary_neg: "-42" => Node::UnaryOp { - expr: Box::new(Node::Lit(Literal::Float(42.0))), + expr: Box::new(Node::Lit(Literal::Float(42.))), op: UnaryOp::Neg, }, test_parse_binary_add: "1 + 2" => Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(1.0))), + lhs: Box::new(Node::Lit(Literal::Float(1.))), op: BinaryOp::Add, - rhs: Box::new(Node::Lit(Literal::Float(2.0))), + rhs: Box::new(Node::Lit(Literal::Float(2.))), }, test_parse_binary_mul: "3 * 4" => Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(3.0))), + lhs: Box::new(Node::Lit(Literal::Float(3.))), op: BinaryOp::Mul, - rhs: Box::new(Node::Lit(Literal::Float(4.0))), + rhs: Box::new(Node::Lit(Literal::Float(4.))), }, test_parse_binary_pow: "2 ^ 3" => Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(2.0))), + lhs: Box::new(Node::Lit(Literal::Float(2.))), op: BinaryOp::Pow, - rhs: Box::new(Node::Lit(Literal::Float(3.0))), + rhs: Box::new(Node::Lit(Literal::Float(3.))), }, test_parse_unary_sqrt: "sqrt(16)" => Node::UnaryOp { - expr: Box::new(Node::Lit(Literal::Float(16.0))), + expr: Box::new(Node::Lit(Literal::Float(16.))), op: UnaryOp::Sqrt, }, test_parse_sqr_ident: "sqr(16)" => Node::FnCall { name:"sqr".to_string(), - expr: vec![Node::Lit(Literal::Float(16.0))] + expr: vec![Node::Lit(Literal::Float(16.))] }, test_parse_complex_expr: "(1 + 2) 3 - 4 ^ 2" => Node::BinOp { lhs: Box::new(Node::BinOp { lhs: Box::new(Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(1.0))), + lhs: Box::new(Node::Lit(Literal::Float(1.))), op: BinaryOp::Add, - rhs: Box::new(Node::Lit(Literal::Float(2.0))), + rhs: Box::new(Node::Lit(Literal::Float(2.))), }), op: BinaryOp::Mul, - rhs: Box::new(Node::Lit(Literal::Float(3.0))), + rhs: Box::new(Node::Lit(Literal::Float(3.))), }), op: BinaryOp::Sub, rhs: Box::new(Node::BinOp { - lhs: Box::new(Node::Lit(Literal::Float(4.0))), + lhs: Box::new(Node::Lit(Literal::Float(4.))), op: BinaryOp::Pow, - rhs: Box::new(Node::Lit(Literal::Float(2.0))), + rhs: Box::new(Node::Lit(Literal::Float(2.))), }), } } diff --git a/libraries/math-parser/src/value.rs b/libraries/math-parser/src/value.rs index 3577f3ea60..1e56070a9c 100644 --- a/libraries/math-parser/src/value.rs +++ b/libraries/math-parser/src/value.rs @@ -77,7 +77,7 @@ impl Number { } (Number::Real(lhs), Number::Complex(rhs)) => { - let lhs_complex = Complex::new(lhs, 0.0); + let lhs_complex = Complex::new(lhs, 0.); let result = match op { BinaryOp::Add => lhs_complex + rhs, BinaryOp::Sub => lhs_complex - rhs, @@ -89,7 +89,7 @@ impl Number { } (Number::Complex(lhs), Number::Real(rhs)) => { - let rhs_complex = Complex::new(rhs, 0.0); + let rhs_complex = Complex::new(rhs, 0.); let result = match op { BinaryOp::Add => lhs + rhs_complex, BinaryOp::Sub => lhs - rhs_complex, diff --git a/node-graph/graphene-cli/src/export.rs b/node-graph/graphene-cli/src/export.rs index 54fe1a04f4..c09c291cde 100644 --- a/node-graph/graphene-cli/src/export.rs +++ b/node-graph/graphene-cli/src/export.rs @@ -146,7 +146,7 @@ impl AnimationParams { /// Get the frame delay in centiseconds (GIF uses 10ms units) pub fn frame_delay_centiseconds(&self) -> u16 { - ((100.0 / self.fps).round() as u16).max(1) + ((100. / self.fps).round() as u16).max(1) } } diff --git a/node-graph/libraries/graphic-types/src/graphic.rs b/node-graph/libraries/graphic-types/src/graphic.rs index e70153a389..7d5267d352 100644 --- a/node-graph/libraries/graphic-types/src/graphic.rs +++ b/node-graph/libraries/graphic-types/src/graphic.rs @@ -701,7 +701,7 @@ mod graphic_is_opaque_tests { use super::*; fn color_graphic(alpha: f64) -> Graphic { - let color = Color::from_rgbaf32(1.0, 0.0, 0.0, alpha as f32).unwrap(); + let color = Color::from_rgbaf32(1., 0., 0., alpha as f32).unwrap(); Graphic::Color(List::new_from_element(color)) } @@ -713,7 +713,7 @@ mod graphic_is_opaque_tests { #[test] fn opaque_color_is_opaque() { - let g = color_graphic(1.0); + let g = color_graphic(1.); assert!(g.is_opaque()); } @@ -731,8 +731,8 @@ mod graphic_is_opaque_tests { #[test] fn gradient_with_all_opaque_stops_is_opaque() { - let color_1 = Color::from_rgbaf32(1.0, 0.0, 0.0, 1.).unwrap(); - let color_2 = Color::from_rgbaf32(1.0, 0.0, 0.0, 1.).unwrap(); + let color_1 = Color::from_rgbaf32(1., 0., 0., 1.).unwrap(); + let color_2 = Color::from_rgbaf32(1., 0., 0., 1.).unwrap(); let gradient = GradientStops::new(vec![ GradientStop { position: 0., @@ -751,8 +751,8 @@ mod graphic_is_opaque_tests { #[test] fn gradient_with_transparent_stop_is_not_opaque() { - let color_1 = Color::from_rgbaf32(1.0, 0.0, 0.0, 0.5).unwrap(); - let color_2 = Color::from_rgbaf32(1.0, 0.0, 0.0, 1.).unwrap(); + let color_1 = Color::from_rgbaf32(1., 0., 0., 0.5).unwrap(); + let color_2 = Color::from_rgbaf32(1., 0., 0., 1.).unwrap(); let gradient = GradientStops::new(vec![ GradientStop { position: 0., diff --git a/node-graph/libraries/no-std-types/src/color/color_types.rs b/node-graph/libraries/no-std-types/src/color/color_types.rs index 2985665f6f..51ce385538 100644 --- a/node-graph/libraries/no-std-types/src/color/color_types.rs +++ b/node-graph/libraries/no-std-types/src/color/color_types.rs @@ -261,12 +261,12 @@ impl RGB for Luma { impl Pixel for Luma {} /// Structure that represents a color. -/// Internally alpha is stored as `f32` that ranges from `0.0` (transparent) to `1.0` (opaque). -/// The other components (RGB) are stored as `f32` that range from `0.0` up to `f32::MAX`, -/// the values encode the brightness of each channel proportional to the light intensity in cd/m² (nits) in HDR, and `0.0` (black) to `1.0` (white) in SDR color. +/// Internally alpha is stored as `f32` that ranges from `0.` (transparent) to `1.` (opaque). +/// The other components (RGB) are stored as `f32` that range from `0.` up to `f32::MAX`, +/// the values encode the brightness of each channel proportional to the light intensity in cd/m² (nits) in HDR, and `0.` (black) to `1.` (white) in SDR color. /// Linear-light sRGB color with `f32` channels (alpha unassociated for swatch/UI colors, associated/premultiplied for pixel data inside [`Image`]). /// -/// Channels range from `0.0` to `f32::MAX`, encoding brightness proportional to light intensity (cd/m² nits in HDR, or `0..=1` mapped to white for SDR). +/// Channels range from `0.` to `f32::MAX`, encoding brightness proportional to light intensity (cd/m² nits in HDR, or `0..=1` mapped to white for SDR). /// /// Anything crossing the Wasm/JS boundary must go through [`SRGBA8`] instead. #[repr(C)] @@ -452,8 +452,8 @@ impl Color { alpha: 0., }; - /// Returns `Some(Color)` if `red`, `green`, `blue` and `alpha` have a valid value. Negative numbers (including `-0.0`), NaN, and infinity are not valid values and return `None`. - /// Alpha values greater than `1.0` are not valid. + /// Returns `Some(Color)` if `red`, `green`, `blue` and `alpha` have a valid value. Negative numbers (including `-0.`), NaN, and infinity are not valid values and return `None`. + /// Alpha values greater than `1.` are not valid. /// /// # Examples /// ``` @@ -593,7 +593,7 @@ impl Color { self.blue } - /// Return the `alpha` component without checking its expected `0.0` to `1.0` range. + /// Return the `alpha` component without checking its expected `0.` to `1.` range. /// /// # Examples /// ``` diff --git a/node-graph/libraries/no-std-types/src/color/discrete_srgb.rs b/node-graph/libraries/no-std-types/src/color/discrete_srgb.rs index 13a06e30ab..e8d2ef5472 100644 --- a/node-graph/libraries/no-std-types/src/color/discrete_srgb.rs +++ b/node-graph/libraries/no-std-types/src/color/discrete_srgb.rs @@ -62,7 +62,7 @@ pub fn float_to_srgb_u8(mut f: f32) -> u8 { f = 1.; } - // Shift away slightly from 0.0 to reduce exponent range. + // Shift away slightly from 0 to reduce exponent range. const C: f32 = 0.009842521f32; let u = (f + C).to_bits() - C.to_bits(); if u > (1. + C).to_bits() - C.to_bits() { diff --git a/node-graph/libraries/vector-types/src/vector/algorithms/bezpath_algorithms.rs b/node-graph/libraries/vector-types/src/vector/algorithms/bezpath_algorithms.rs index c905ec1491..35e2b2bd2d 100644 --- a/node-graph/libraries/vector-types/src/vector/algorithms/bezpath_algorithms.rs +++ b/node-graph/libraries/vector-types/src/vector/algorithms/bezpath_algorithms.rs @@ -214,16 +214,16 @@ pub fn pathseg_find_tvalues_for_x(segment: PathSeg, x: f64) -> impl Iterator MAX_ABSOLUTE_DIFFERENCE { [Some(-b / a), None, None] } else { [None; 3] } } PathSeg::Quad(QuadBez { p0, p1, p2 }) => { - let a = p2.x - 2.0 * p1.x + p0.x; - let b = 2.0 * (p1.x - p0.x); + let a = p2.x - 2. * p1.x + p0.x; + let b = 2. * (p1.x - p0.x); let c = p0.x - x; let r = solve_quadratic(c, b, a); [r.first().copied(), r.get(1).copied(), None] } PathSeg::Cubic(CubicBez { p0, p1, p2, p3 }) => { - let a = p3.x - 3.0 * p2.x + 3.0 * p1.x - p0.x; - let b = 3.0 * (p2.x - 2.0 * p1.x + p0.x); - let c = 3.0 * (p1.x - p0.x); + let a = p3.x - 3. * p2.x + 3. * p1.x - p0.x; + let b = 3. * (p2.x - 2. * p1.x + p0.x); + let c = 3. * (p1.x - p0.x); let d = p0.x - x; let r = solve_cubic(d, c, b, a); [r.first().copied(), r.get(1).copied(), r.get(2).copied()] diff --git a/node-graph/libraries/vector-types/src/vector/algorithms/spline.rs b/node-graph/libraries/vector-types/src/vector/algorithms/spline.rs index 27011013b2..e03d84ce3b 100644 --- a/node-graph/libraries/vector-types/src/vector/algorithms/spline.rs +++ b/node-graph/libraries/vector-types/src/vector/algorithms/spline.rs @@ -96,14 +96,14 @@ pub fn solve_spline_first_handle_closed(points: &[DVec2]) -> Vec { // Handle from from `1` to `len_points - 2` (inclusive). for ix in 1..=(len_points - 2) { - let m = 1.0 / (b[ix] - a[ix] * cmod[ix - 1]); + let m = 1. / (b[ix] - a[ix] * cmod[ix - 1]); cmod[ix] = c[ix] * m; - u[ix] = (0.0 - a[ix] * u[ix - 1]) * m; + u[ix] = (0. - a[ix] * u[ix - 1]) * m; x[ix] = (x[ix] - a[ix] * x[ix - 1]) * m; } // Handle `len_points - 1`. - let m = 1.0 / (b[len_points - 1] - alpha * beta / gamma - beta * cmod[len_points - 2]); + let m = 1. / (b[len_points - 1] - alpha * beta / gamma - beta * cmod[len_points - 2]); u[len_points - 1] = (alpha - a[len_points - 1] * u[len_points - 2]) * m; x[len_points - 1] = (x[len_points - 1] - a[len_points - 1] * x[len_points - 2]) * m; @@ -113,7 +113,7 @@ pub fn solve_spline_first_handle_closed(points: &[DVec2]) -> Vec { x[ix] = x[ix] - cmod[ix] * x[ix + 1]; } - let fact = (x[0] + x[len_points - 1] * beta / gamma) / (1.0 + u[0] + u[len_points - 1] * beta / gamma); + let fact = (x[0] + x[len_points - 1] * beta / gamma) / (1. + u[0] + u[len_points - 1] * beta / gamma); for ix in 0..(len_points) { x[ix] -= fact * u[ix]; diff --git a/node-graph/libraries/vector-types/src/vector/click_target.rs b/node-graph/libraries/vector-types/src/vector/click_target.rs index 020054423b..e97ea4be8b 100644 --- a/node-graph/libraries/vector-types/src/vector/click_target.rs +++ b/node-graph/libraries/vector-types/src/vector/click_target.rs @@ -360,9 +360,9 @@ mod tests { #[test] fn test_bounding_box_cache_fingerprint_generation() { // Test that fingerprints have MSB set and use only 7 bits for data - let rotation1 = 0.0; - let rotation2 = PI / 3.0; - let rotation3 = PI / 2.0; + let rotation1 = 0.; + let rotation2 = PI / 3.; + let rotation3 = PI / 2.; let fp1 = BoundingBoxCache::rotation_fingerprint(rotation1); let fp2 = BoundingBoxCache::rotation_fingerprint(rotation2); @@ -387,11 +387,11 @@ mod tests { let mut cache = BoundingBoxCache::default(); // Create a simple rectangle subpath for testing - let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(100.0, 50.0)); + let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(100., 50.)); - let rotation = PI / 4.0; - let scale = DVec2::new(2.0, 2.0); - let translation = DVec2::new(10.0, 20.0); + let rotation = PI / 4.; + let scale = DVec2::new(2., 2.); + let translation = DVec2::new(10., 20.); let fingerprint = BoundingBoxCache::rotation_fingerprint(rotation); // Cache should be empty initially @@ -410,12 +410,12 @@ mod tests { #[test] fn test_bounding_box_cache_ring_buffer_behavior() { let mut cache = BoundingBoxCache::default(); - let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(10.0, 10.0)); + let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(10., 10.)); let scale = DVec2::ONE; let translation = DVec2::ZERO; // Fill cache beyond capacity to test ring buffer behavior - let rotations: Vec = (0..10).map(|i| i as f64 * PI / 8.0).collect(); + let rotations: Vec = (0..10).map(|i| i as f64 * PI / 8.).collect(); for rotation in &rotations { let fingerprint = BoundingBoxCache::rotation_fingerprint(*rotation); @@ -435,12 +435,12 @@ mod tests { #[test] fn test_click_target_bounding_box_caching() { // Create a click target with a simple rectangle - let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(100.0, 50.0)); - let click_target = ClickTarget::new_with_subpath(subpath, 1.0); + let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(100., 50.)); + let click_target = ClickTarget::new_with_subpath(subpath, 1.); - let rotation = PI / 6.0; + let rotation = PI / 6.; let scale = DVec2::new(1.5, 1.5); - let translation = DVec2::new(20.0, 30.0); + let translation = DVec2::new(20., 30.); let transform = DAffine2::from_scale_angle_translation(scale, rotation, translation); // Helper function to count present values in cache @@ -463,7 +463,7 @@ mod tests { assert_eq!(count_present_values(), 1); // Should still be 1, not 2 // Different scale/translation but same rotation should use cached rotation - let transform2 = DAffine2::from_scale_angle_translation(DVec2::new(2.0, 2.0), rotation, DVec2::new(50.0, 60.0)); + let transform2 = DAffine2::from_scale_angle_translation(DVec2::new(2., 2.), rotation, DVec2::new(50., 60.)); let result3 = click_target.bounding_box_with_transform(transform2); assert!(result3.is_some()); assert_ne!(result1, result3); // Different due to different scale/translation @@ -472,11 +472,11 @@ mod tests { #[test] fn test_click_target_skew_bypass_cache() { - let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(100.0, 50.0)); - let click_target = ClickTarget::new_with_subpath(subpath.clone(), 1.0); + let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(100., 50.)); + let click_target = ClickTarget::new_with_subpath(subpath.clone(), 1.); // Create a transform with skew (non-uniform scaling in different directions) - let skew_transform = DAffine2::from_cols_array(&[2.0, 0.5, 0.0, 1.0, 10.0, 20.0]); + let skew_transform = DAffine2::from_cols_array(&[2., 0.5, 0., 1., 10., 20.]); assert!(skew_transform.has_skew()); // Should bypass cache and compute directly @@ -488,12 +488,12 @@ mod tests { #[test] fn test_cache_fingerprint_collision_handling() { let mut cache = BoundingBoxCache::default(); - let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(10.0, 10.0)); + let subpath = Subpath::new_rectangle(DVec2::ZERO, DVec2::new(10., 10.)); let scale = DVec2::ONE; let translation = DVec2::ZERO; // Find two rotations that produce the same fingerprint (collision) - let rotation1 = 0.0; + let rotation1 = 0.; let rotation2 = 0.25; let fp1 = BoundingBoxCache::rotation_fingerprint(rotation1); let fp2 = BoundingBoxCache::rotation_fingerprint(rotation2); diff --git a/node-graph/libraries/vector-types/src/vector/misc.rs b/node-graph/libraries/vector-types/src/vector/misc.rs index bda89fcd0e..a7564fd855 100644 --- a/node-graph/libraries/vector-types/src/vector/misc.rs +++ b/node-graph/libraries/vector-types/src/vector/misc.rs @@ -291,11 +291,11 @@ pub trait Tangent { fn tangent_at(&self, t: f64) -> DVec2; fn tangent_at_start(&self) -> DVec2 { - self.tangent_at(0.0) + self.tangent_at(0.) } fn tangent_at_end(&self) -> DVec2 { - self.tangent_at(1.0) + self.tangent_at(1.) } } diff --git a/node-graph/libraries/wgpu-executor/src/background/mod.rs b/node-graph/libraries/wgpu-executor/src/background/mod.rs index dd4df445ad..efa0f9b100 100644 --- a/node-graph/libraries/wgpu-executor/src/background/mod.rs +++ b/node-graph/libraries/wgpu-executor/src/background/mod.rs @@ -190,14 +190,14 @@ impl BackgroundCompositor { } pub fn composite(&self, context: &crate::WgpuContext, foreground: &wgpu::Texture, output: &wgpu::Texture, backgrounds: &[rendering::Background], document_to_screen: Affine2, zoom: f32) { - if zoom <= 0.0 { + if zoom <= 0. { return; } let device = &context.device; let queue = &context.queue; - let checker_size_doc = 8.0 / zoom; + let checker_size_doc = 8. / zoom; let screen_to_document = document_to_screen.inverse(); let viewport_size = output.size(); let viewport_size = Vec2::new(viewport_size.width as f32, viewport_size.height as f32); diff --git a/node-graph/nodes/gstd/src/pixel_preview.rs b/node-graph/nodes/gstd/src/pixel_preview.rs index d27b0cb8a7..1f43cc43c0 100644 --- a/node-graph/nodes/gstd/src/pixel_preview.rs +++ b/node-graph/nodes/gstd/src/pixel_preview.rs @@ -46,7 +46,7 @@ pub async fn pixel_preview<'a: 'n>( let upstream_resolution = upstream_size.as_uvec2().max(UVec2::ONE); let upstream_footprint = Footprint { - transform: DAffine2::from_scale(DVec2::splat(1.0 / physical_scale)) * DAffine2::from_translation(-upstream_min), + transform: DAffine2::from_scale(DVec2::splat(1. / physical_scale)) * DAffine2::from_translation(-upstream_min), resolution: upstream_resolution, quality: footprint.quality, }; diff --git a/node-graph/nodes/gstd/src/render_cache.rs b/node-graph/nodes/gstd/src/render_cache.rs index 2759cba97d..05e5e4617b 100644 --- a/node-graph/nodes/gstd/src/render_cache.rs +++ b/node-graph/nodes/gstd/src/render_cache.rs @@ -90,8 +90,8 @@ impl CacheKey { thumbnail, aligned_strokes, override_paint_order, - animation_time_ms: (animation_time * 1000.0).round() as i64, - real_time_ms: (real_time * 1000.0).round() as i64, + animation_time_ms: (animation_time * 1000.).round() as i64, + real_time_ms: (real_time * 1000.).round() as i64, pointer: pointer_bytes, } } @@ -369,8 +369,8 @@ pub async fn render_output_cache<'a: 'n>( render_params.thumbnail, render_params.aligned_strokes, render_params.override_paint_order, - ctx.try_animation_time().unwrap_or(0.0), - ctx.try_real_time().unwrap_or(0.0), + ctx.try_animation_time().unwrap_or(0.), + ctx.try_real_time().unwrap_or(0.), ctx.try_pointer_position(), ); diff --git a/node-graph/nodes/raster/src/fullscreen_vertex.rs b/node-graph/nodes/raster/src/fullscreen_vertex.rs index be125ade67..50014248bd 100644 --- a/node-graph/nodes/raster/src/fullscreen_vertex.rs +++ b/node-graph/nodes/raster/src/fullscreen_vertex.rs @@ -1,7 +1,7 @@ use glam::{Vec2, Vec4}; use spirv_std::spirv; -/// webgpu NDC is like OpenGL: (-1.0 .. 1.0, -1.0 .. 1.0, 0.0 .. 1.0) +/// WebGPU NDC is like OpenGL: (-1..1, -1..1, 0..1) /// https://www.w3.org/TR/webgpu/#coordinate-systems /// /// So to make a fullscreen triangle around a box at (-1..1):