Fix "contrain" typo (#1717)

Fix typo 'contrain' to true 'constrain

Fix typo 'contrain' to true 'constrain'
This commit is contained in:
Muhammad Aqdas
2024-03-31 06:15:57 +00:00
committed by GitHub
parent 291c580924
commit e22db31738
4 changed files with 20 additions and 20 deletions
@@ -150,7 +150,7 @@ impl GridSnapper {
}
}
pub fn contrained_snap(&mut self, snap_data: &mut SnapData, point: &SnapCandidatePoint, snap_results: &mut SnapResults, constraint: SnapConstraint) {
pub fn constrained_snap(&mut self, snap_data: &mut SnapData, point: &SnapCandidatePoint, snap_results: &mut SnapResults, constraint: SnapConstraint) {
let tolerance = snap_tolerance(snap_data.document);
let projected = constraint.projection(point.document_point);
let lines = self.get_snap_lines(projected, snap_data);
@@ -170,7 +170,7 @@ impl GridSnapper {
source: point.source,
target: SnapTarget::Grid(GridSnapTarget::Line),
at_intersection: false,
contrained: true,
constrained: true,
source_bounds: point.quad,
curves: [
Some(Bezier::from_linear_dvec2(projected - constraint_direction * tolerance, projected + constraint_direction * tolerance)),
@@ -227,7 +227,7 @@ impl LayerSnapper {
target: candidate.target,
distance,
tolerance,
contrained: true,
constrained: true,
target_bounds: candidate.quad,
..Default::default()
});
@@ -242,7 +242,7 @@ impl LayerSnapper {
self.free_snap_paths(snap_data, point, snap_results);
}
pub fn contrained_snap(&mut self, snap_data: &mut SnapData, point: &SnapCandidatePoint, snap_results: &mut SnapResults, constraint: SnapConstraint) {
pub fn constrained_snap(&mut self, snap_data: &mut SnapData, point: &SnapCandidatePoint, snap_results: &mut SnapResults, constraint: SnapConstraint) {
self.snap_anchors(snap_data, point, snap_results, constraint, constraint.projection(point.document_point));
self.snap_paths_constrained(snap_data, point, snap_results, constraint);
}
@@ -264,7 +264,7 @@ fn normals_and_tangents(path: &SnapCandidatePath, normals: bool, tangents: bool,
tolerance,
curves: [Some(path.document_curve), None],
source: point.source,
contrained: true,
constrained: true,
..Default::default()
});
}
@@ -285,7 +285,7 @@ fn normals_and_tangents(path: &SnapCandidatePath, normals: bool, tangents: bool,
tolerance,
curves: [Some(path.document_curve), None],
source: point.source,
contrained: true,
constrained: true,
..Default::default()
});
}
@@ -17,7 +17,7 @@ pub struct SnappedPoint {
pub source: SnapSource,
pub target: SnapTarget,
pub at_intersection: bool,
pub contrained: bool, // Found when looking for contrained
pub constrained: bool, // Found when looking for constrained
pub target_bounds: Option<Quad>,
pub source_bounds: Option<Quad>,
pub curves: [Option<Bezier>; 2],
@@ -56,16 +56,16 @@ impl SnappedPoint {
// Prefer closest
let other_closer = other_dist < my_dist + bias;
// We should prefer the most contrained option (e.g. intersection > path)
let other_more_contrained = other.contrained && !self.contrained;
let self_more_contrained = self.contrained && !other.contrained;
// We should prefer the most constrained option (e.g. intersection > path)
let other_more_constrained = other.constrained && !self.constrained;
let self_more_constrained = self.constrained && !other.constrained;
// Prefer nodes to intersections if both are at the same position
let contrained_at_same_pos = other.contrained && self.contrained && self.snapped_point_document.abs_diff_eq(other.snapped_point_document, 1.);
let other_better_constraint = contrained_at_same_pos && self.at_intersection && !other.at_intersection;
let self_better_constraint = contrained_at_same_pos && other.at_intersection && !self.at_intersection;
let constrained_at_same_pos = other.constrained && self.constrained && self.snapped_point_document.abs_diff_eq(other.snapped_point_document, 1.);
let other_better_constraint = constrained_at_same_pos && self.at_intersection && !other.at_intersection;
let self_better_constraint = constrained_at_same_pos && other.at_intersection && !self.at_intersection;
(other_closer || other_more_contrained || other_better_constraint) && !self_more_contrained && !self_better_constraint
(other_closer || other_more_constrained || other_better_constraint) && !self_more_constrained && !self_better_constraint
}
pub fn is_snapped(&self) -> bool {
self.distance.is_finite()