mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 20:08:12 +08:00
Upgrade to the Rust 2024 edition (#2367)
* Update to rust 2024 edition * Fixes * Clean up imports * Cargo fmt again --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
927d7dd9b2
commit
beb1c6ae64
@@ -1,10 +1,9 @@
|
||||
use crate::aabb::{bounding_box_max_extent, bounding_boxes_overlap, Aabb};
|
||||
use crate::aabb::{Aabb, bounding_box_max_extent, bounding_boxes_overlap};
|
||||
use crate::epsilons::Epsilons;
|
||||
use crate::line_segment::{line_segment_intersection, line_segments_intersect};
|
||||
use crate::line_segment_aabb::line_segment_aabb_intersect;
|
||||
use crate::math::lerp;
|
||||
use crate::path_segment::PathSegment;
|
||||
|
||||
use glam::DVec2;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -21,11 +21,7 @@ pub fn line_segment_intersection([p1, p2]: LineSegment, [p3, p4]: LineSegment, e
|
||||
let s = (c.x * b.y - c.y * b.x) / denom;
|
||||
let t = (a.x * c.y - a.y * c.x) / denom;
|
||||
|
||||
if (-eps..=1. + eps).contains(&s) && (-eps..=1. + eps).contains(&t) {
|
||||
Some((s, t))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if (-eps..=1. + eps).contains(&s) && (-eps..=1. + eps).contains(&t) { Some((s, t)) } else { None }
|
||||
}
|
||||
|
||||
pub fn line_segments_intersect(seg1: LineSegment, seg2: LineSegment, eps: f64) -> bool {
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
//! The implementations in this module closely follow the SVG path specification,
|
||||
//! making it suitable for use in vector graphics applications.
|
||||
|
||||
use crate::EPS;
|
||||
use crate::aabb::{Aabb, bounding_box_around_point, expand_bounding_box, extend_bounding_box, merge_bounding_boxes};
|
||||
use crate::math::{lerp, vector_angle};
|
||||
use glam::{DMat2, DMat3, DVec2};
|
||||
use std::f64::consts::{PI, TAU};
|
||||
|
||||
use crate::aabb::{bounding_box_around_point, expand_bounding_box, extend_bounding_box, merge_bounding_boxes, Aabb};
|
||||
use crate::math::{lerp, vector_angle};
|
||||
use crate::EPS;
|
||||
|
||||
/// Represents a segment of a path in a 2D space, based on the SVG path specification.
|
||||
///
|
||||
/// This enum closely follows the path segment types defined in the SVG 2 specification.
|
||||
@@ -155,11 +154,7 @@ impl PathSegment {
|
||||
let b = 6. * b;
|
||||
let numerator = a.x * b.y - a.y * b.x;
|
||||
let denominator = a.length_squared() * a.length();
|
||||
if denominator == 0. {
|
||||
0.
|
||||
} else {
|
||||
numerator / denominator
|
||||
}
|
||||
if denominator == 0. { 0. } else { numerator / denominator }
|
||||
}
|
||||
PathSegment::Quadratic(start, control, end) => {
|
||||
// First derivative
|
||||
@@ -168,11 +163,7 @@ impl PathSegment {
|
||||
let b = 2. * (start - 2. * control + end);
|
||||
let numerator = a.x * b.y - a.y * b.x;
|
||||
let denominator = a.length_squared() * a.length();
|
||||
if denominator == 0. {
|
||||
0.
|
||||
} else {
|
||||
numerator / denominator
|
||||
}
|
||||
if denominator == 0. { 0. } else { numerator / denominator }
|
||||
}
|
||||
PathSegment::Arc(..) => self.arc_segment_to_cubics(0.001)[0].start_curvature(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user