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 {
+2 -2
View File
@@ -41,12 +41,12 @@ fn entities(s: &Session) -> (Vec<String>, Vec<String>, Vec<String>) {
#[test]
fn random_sketch_editing_never_breaks() {
for seed in 1..=4u64 {
for seed in 1..=2u64 {
let mut r = Rng(0x9E37_79B9_7F4A_7C15 ^ seed);
let mut s = Session::default();
let _ = s.execute("PrimitiveBox", &json!({"length": 30, "width": 20, "height": 10}));
let _ = s.execute("SketchCreate", &json!({"plane": {"face": [15, 10, 10]}}));
for step in 0..150 {
for step in 0..120 {
let (curves, points, cons) = entities(&s);
let c = |r: &mut Rng| r.pick(&curves).cloned().unwrap_or_default();
let p = |r: &mut Rng| r.pick(&points).cloned().unwrap_or_default();