Sketch UI: click a constraint glyph to select it, Delete removes the constraint; glyphs sit half way along their curve; lighter randomized sketch test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
bherbruckandClaude Opus 5.5 committed 2026-10-08 01:31:16 +00:00
1 parent 1c10d1e56a
commit 1b664bb1b0
4 files changed
+66 -6

No files matched your search

+11 -1
View File
@@ -403,9 +403,19 @@ fn toggle_driven(s: &mut Session, p: &Value) -> Result<Value> {
/// or at its point.
fn anchor(sk: &Sketch, k: &ConstraintKind) -> Option<Vec2> {
use ConstraintKind::*;
// Half way along the curve.
let mid = |c: usize| -> Option<Vec2> {
let poly = sk.polyline(c);
poly.get(poly.len() / 2).copied()
let total: f64 = poly.windows(2).map(|w| w[0].dist(w[1])).sum();
let mut acc = 0.0;
for w in poly.windows(2) {
let l = w[0].dist(w[1]);
if acc + l >= total * 0.5 && l > 0.0 {
return Some(w[0].lerp(w[1], (total * 0.5 - acc) / l));
}
acc += l;
}
poly.first().copied()
};
let pt = |p: usize| sk.point(p);
match *k {