Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions desktop/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
Expand Down
10 changes: 5 additions & 5 deletions desktop/src/cef/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions desktop/src/render/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1215,15 +1215,15 @@ 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
}

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)
Expand Down
18 changes: 9 additions & 9 deletions editor/src/messages/viewport/viewport_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.,
}
}
}
Expand Down Expand Up @@ -400,14 +400,14 @@ impl FromWithScale<Bounds> for PhysicalBounds {
impl Mul<f64> 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<f64> 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 }
}
}
Expand All @@ -426,16 +426,16 @@ impl Sub<f64> for Point {
impl Mul<Point> 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<Point> 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 }
}
}
Expand All @@ -455,7 +455,7 @@ impl Sub<Point> for Point {
impl Mul<f64> 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,
Expand All @@ -465,7 +465,7 @@ impl Mul<f64> for Bounds {
impl Div<f64> 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,
Expand Down
4 changes: 2 additions & 2 deletions libraries/math-parser/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
);
Expand Down
36 changes: 18 additions & 18 deletions libraries/math-parser/src/executer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.))),
},
}
}
20 changes: 10 additions & 10 deletions libraries/math-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
36 changes: 18 additions & 18 deletions libraries/math-parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl NodeMetadata {
}

fn parse_unit(pairs: Pairs<Rule>) -> 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;
Expand Down Expand Up @@ -102,9 +102,9 @@ fn parse_unit(pairs: Pairs<Rule>) -> Result<(Unit, f64), ParseError> {
fn parse_const(pair: Pair<Rule>) -> 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),
Expand Down Expand Up @@ -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.))),
}),
}
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/math-parser/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion node-graph/graphene-cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
12 changes: 6 additions & 6 deletions node-graph/libraries/graphic-types/src/graphic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand All @@ -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());
}

Expand All @@ -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.,
Expand All @@ -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.,
Expand Down
Loading
Loading