Let the conic tool take a typed Rho, and preview the curve it is about to draw (#736)
The conic tool takes a typed Rho in its canvas value box and previews the curve it's about to draw, with the tangent legs as a faint guide.
This commit is contained in:
1 parent
9b5e39844a
commit
aae70053ee
10 files changed
+349
-47
No files matched your search
@@ -534,6 +534,32 @@ fn dragging_circles_and_arcs() {
|
||||
assert!(pt(&s, "a1.start").dist(v(70.0, 0.0)) < 1e-9, "{:?}", pt(&s, "a1.start"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dragging_a_conic_reads_rho_off_the_cursor_and_its_apex_slides_like_any_point() {
|
||||
let mut s = new_sketch();
|
||||
run(&mut s, "sketch.conic", json!({"start": [0, 0], "end": [40, 0], "apex": [20, 20]}));
|
||||
let rho = |s: &Session| match sketch(s).curves[0].kind {
|
||||
solidcraft_sketch::CurveKind::Conic { rho, .. } => rho,
|
||||
ref k => panic!("not a conic: {k:?}"),
|
||||
};
|
||||
assert!((rho(&s) - 0.5).abs() < 1e-9, "default rho: {}", rho(&s));
|
||||
|
||||
// Grabbed on the curve itself (its midpoint, at the default rho of 0.5): `rho` follows the
|
||||
// cursor, read off where it falls between the chord's midpoint (20, 0) and the apex (20,
|
||||
// 20). The three defining points stay exactly where they were.
|
||||
drag(&mut s, "k1", [20.0, 10.0], [20.0, 14.0]);
|
||||
assert!((rho(&s) - 0.7).abs() < 1e-6, "rho after drag: {}", rho(&s));
|
||||
assert!(pt(&s, "k1.start").dist(v(0.0, 0.0)) < 1e-9);
|
||||
assert!(pt(&s, "k1.end").dist(v(40.0, 0.0)) < 1e-9);
|
||||
assert!(pt(&s, "k1.apex").dist(v(20.0, 20.0)) < 1e-9);
|
||||
|
||||
// Grabbed on the apex itself: it slides like any other point (not a `rho` edit), and `rho`
|
||||
// is unaffected.
|
||||
drag(&mut s, "k1.apex", [20.0, 20.0], [10.0, 30.0]);
|
||||
assert!(pt(&s, "k1.apex").dist(v(10.0, 30.0)) < 1e-9);
|
||||
assert!((rho(&s) - 0.7).abs() < 1e-6, "rho after apex drag: {}", rho(&s));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn constrained_geometry_resists_drags() {
|
||||
let mut s = new_sketch();
|
||||
|
||||
Reference in new issue
Block a user