Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6995e0c423 |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
allow-unwrap-in-tests = true
|
||||
allow-expect-in-tests = true
|
||||
allow-panic-in-tests = true
|
||||
allow-indexing-slicing-in-tests = true
|
||||
@@ -204,7 +204,7 @@ impl Mesh {
|
||||
|
||||
/// Band width (in vertices) of the vertex adjacency.
|
||||
fn vertex_band(&self) -> usize {
|
||||
self.tris.iter().map(|t| t.iter().max().unwrap() - t.iter().min().unwrap()).max().unwrap_or(0)
|
||||
self.tris.iter().filter_map(|t| Some(t.iter().max()? - t.iter().min()?)).max().unwrap_or(0)
|
||||
}
|
||||
|
||||
/// The triangle and barycentric coordinates of `p` (extrapolated from the nearest mesh cell
|
||||
@@ -448,10 +448,12 @@ pub fn auto_pins(mesh: &Mesh, count: usize) -> Vec<Point> {
|
||||
return vec![];
|
||||
}
|
||||
let c = centres.iter().fold(Vec2::ZERO, |a, p| a + p.to_vec2()) / centres.len() as f64;
|
||||
let first = *centres.iter().min_by(|a, b| a.distance_squared(c.to_point()).total_cmp(&b.distance_squared(c.to_point()))).unwrap();
|
||||
let Some(&first) = centres.iter().min_by(|a, b| a.distance_squared(c.to_point()).total_cmp(&b.distance_squared(c.to_point()))) else {
|
||||
return vec![];
|
||||
};
|
||||
let mut out = vec![first];
|
||||
while out.len() < count.min(centres.len()) {
|
||||
let next = centres
|
||||
let Some(next) = centres
|
||||
.iter()
|
||||
.max_by(|a, b| {
|
||||
let da = out.iter().map(|o| o.distance_squared(**a)).fold(f64::MAX, f64::min);
|
||||
@@ -459,7 +461,9 @@ pub fn auto_pins(mesh: &Mesh, count: usize) -> Vec<Point> {
|
||||
da.total_cmp(&db)
|
||||
})
|
||||
.copied()
|
||||
.unwrap();
|
||||
else {
|
||||
break;
|
||||
};
|
||||
out.push(next);
|
||||
}
|
||||
out
|
||||
|
||||
@@ -218,7 +218,7 @@ pub fn dabs(points: &[Point], spacing: f64) -> Vec<Point> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let end = *points.last().unwrap();
|
||||
let Some(&end) = points.last() else { return out };
|
||||
if end.distance(last) > spacing * 0.25 {
|
||||
out.push(end);
|
||||
}
|
||||
|
||||
@@ -128,10 +128,11 @@ impl Tool for AnchorTool {
|
||||
*began = true;
|
||||
}
|
||||
}
|
||||
out.push(match self.state {
|
||||
State::Convert { id, si, ai, .. } => {
|
||||
Action::Preview("path.convertAnchor".into(), json!({"id": id.0, "subpath": si, "anchor": ai, "to": "smooth", "x": p.x, "y": p.y}))
|
||||
}
|
||||
let preview = match self.state {
|
||||
State::Convert { id, si, ai, .. } => Action::Preview(
|
||||
"path.convertAnchor".into(),
|
||||
json!({"id": id.0, "subpath": si, "anchor": ai, "to": "smooth", "x": p.x, "y": p.y}),
|
||||
),
|
||||
State::Handle { id, si, ai, out, .. } => Action::Preview(
|
||||
"path.setHandle".into(),
|
||||
json!({"id": id.0, "subpath": si, "anchor": ai, "which": if out { "out" } else { "in" }, "x": p.x, "y": p.y, "independent": true}),
|
||||
@@ -140,8 +141,9 @@ impl Tool for AnchorTool {
|
||||
"path.reshapeSegment".into(),
|
||||
json!({"id": id.0, "subpath": si, "segment": seg, "t": t, "dx": p.x - start.x, "dy": p.y - start.y}),
|
||||
),
|
||||
State::Idle => unreachable!(),
|
||||
});
|
||||
State::Idle => return out,
|
||||
};
|
||||
out.push(preview);
|
||||
out
|
||||
}
|
||||
("anchorPoint", PointerKind::Up) => {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//! and journal entry. One-shot `Exec` actions run immediately. This makes every gesture replayable
|
||||
//! by the control channel and MCP, and keeps tools testable without a UI.
|
||||
#![forbid(unsafe_code)]
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
pub mod bbox;
|
||||
pub mod builder;
|
||||
|
||||
@@ -137,9 +137,8 @@ impl TypeTool {
|
||||
}
|
||||
if self.typing.is_none() {
|
||||
out.push(Action::Begin("Typing".into()));
|
||||
self.typing = Some(Typing { base: t.runs.clone(), cur: t.runs.clone() });
|
||||
}
|
||||
let ty = self.typing.as_mut().expect("typing session");
|
||||
let ty = self.typing.get_or_insert_with(|| Typing { base: t.runs.clone(), cur: t.runs.clone() });
|
||||
let len = edit::runs_len(&ty.cur);
|
||||
let (a, b) = (self.caret.min(self.anchor).min(len), self.caret.max(self.anchor).min(len));
|
||||
let caret = match &styled {
|
||||
|
||||
@@ -401,8 +401,9 @@ impl Tool for GradientTool {
|
||||
}
|
||||
(PointerKind::Drag, Some(g)) => return freeform::drag(cx, g, ev.pos),
|
||||
(PointerKind::Up, Some(_)) => {
|
||||
let g = self.free.take().expect("checked");
|
||||
return freeform::release(cx, FreeformAnnotator::of(cx).as_ref(), g);
|
||||
if let Some(g) = self.free.take() {
|
||||
return freeform::release(cx, FreeformAnnotator::of(cx).as_ref(), g);
|
||||
}
|
||||
}
|
||||
(PointerKind::DoubleClick, free) if free.is_some() || FreeformAnnotator::of(cx).is_some() => return vec![],
|
||||
_ => {}
|
||||
|
||||
Reference in new issue
Block a user