mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Refactor geom for strict Clippy checks
This commit is contained in:
1 parent
169bbdfa22
commit
2ed75b4ec3
1 file changed
+14
-9
+14
-9
@@ -836,15 +836,8 @@ impl BezierMesh {
|
||||
*f = f.max((1.0 - interior) * w);
|
||||
}
|
||||
// Every control point moves with the anchor it is closest to.
|
||||
for j in 0..self.ny() {
|
||||
for i in 0..nx {
|
||||
let (ai, aj) = (((i + 1) / 3).min(cols), ((j + 1) / 3).min(rows));
|
||||
let k = share[aj * (cols + 1) + ai];
|
||||
let p = &mut self.points[j * nx + i];
|
||||
p[0] += d[0] * k;
|
||||
p[1] += d[1] * k;
|
||||
}
|
||||
}
|
||||
let ny = self.ny();
|
||||
move_control_points(&mut self.points, nx, ny, cols, rows, &share, d);
|
||||
// Close the gap exactly, with three groups of control points that share the work:
|
||||
// - the four inner points of the grabbed patch (all of it in the middle of the patch,
|
||||
// little near a grid line, where they barely reach the surface);
|
||||
@@ -1022,6 +1015,18 @@ impl BezierMesh {
|
||||
}
|
||||
}
|
||||
|
||||
fn move_control_points(points: &mut [[f64; 2]], nx: usize, ny: usize, cols: usize, rows: usize, shares: &[f64], delta: [f64; 2]) {
|
||||
for j in 0..ny {
|
||||
for i in 0..nx {
|
||||
let (ai, aj) = (((i + 1) / 3).min(cols), ((j + 1) / 3).min(rows));
|
||||
let share = shares[aj * (cols + 1) + ai];
|
||||
let point = &mut points[j * nx + i];
|
||||
point[0] += delta[0] * share;
|
||||
point[1] += delta[1] * share;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A complete warp: what Photoshop's `warp` descriptor stores, plus the custom mesh.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
||||
Reference in new issue
Block a user