diff --git a/crates/effects/src/solids.rs b/crates/effects/src/solids.rs index cdc2376724..5a2a179437 100644 --- a/crates/effects/src/solids.rs +++ b/crates/effects/src/solids.rs @@ -324,8 +324,7 @@ fn validate_solid_for(doc: Option<&Document>, n: &Node, id: &str, p: &Value, at: reshape_members(n, before, &mut shapes); let b = union_bounds(&shapes).ok_or_else(|| format!("{label} requires a group holding a shape with at least two anchors"))?; check_profiles(id, p, &shapes, b)?; - check_solids(id, p, &shapes)?; - return check_cast(id, p, &shapes); + return check_solids(id, p, &shapes); } let (path, rule) = object_profile(n, label)?; let anchors = || format!("{label} requires a shape with at least two anchors"); @@ -342,38 +341,68 @@ fn validate_solid_for(doc: Option<&Document>, n: &Node, id: &str, p: &Value, at: let b = path.bounds().ok_or_else(anchors)?; let shapes = [Profile { path, rule, items, opacity: 1.0, scopes: vec![] }]; check_profiles(id, p, &shapes, b)?; - check_solids(id, p, &shapes)?; - check_cast(id, p, &shapes) + check_solids(id, p, &shapes) } -/// With the shadow of 3D effect `id` with parameters `p` on, an error when the shadow of `shapes` -/// is past the limits ([`cast_shadow`]). In wireframe mode no shadow is drawn, and none is checked. -fn check_cast(id: &str, p: &Value, shapes: &[Profile]) -> Result<(), String> { - if wireframe::wireframe_params(id, p) { - return Ok(()); - } - cast_shadow(id, p, shapes).map(|_| ()) +/// Does 3D effect `id` with parameters `p` cast a shadow: is it Extrude & Bevel, Inflate or Rotate +/// with Shadows on, shaded? In wireframe mode no shadow is drawn, and none is checked. +fn casts_shadow(id: &str, p: &Value) -> bool { + !is_classic_three_d(id) && shadow::options(p).is_some() && !wireframe::wireframe_params(id, p) +} + +/// Does `item` of a shape with opacity `member` paint anything, and so cast a shadow? +fn visible(item: &AppearanceItem, member: f32) -> bool { + paint_of(item, member).1 > 0.0 } /// Do the solids 3D effect `id` with parameters `p` builds from the profiles of `shapes` about `b` -/// build? Only the profiles no solid of [`check_solids`] is built from are built here: every -/// shape's for Rotate, and for Extrude & Bevel and Inflate the profile of a shape with no fill, -/// whose solids are its strokes' outlines or none. A filled shape's profile is its fill's solid, -/// which [`check_solids`] builds once, about the bounds the effect draws it about. +/// build? Only the profiles no solid of [`check_solids`] is built from are built here: for Rotate +/// every shape's, except with its shadow cast that of a shape with a visible fill, whose plane is +/// the fill's; for Extrude & Bevel and Inflate the profile of a shape with no fill, whose solids +/// are its strokes' outlines or none. A filled shape's profile is its fill's solid, which +/// [`check_solids`] builds once, about the bounds the effect draws it about. fn check_profiles(id: &str, p: &Value, shapes: &[Profile], b: Rect) -> Result<(), String> { - shapes - .iter() - .filter(|s| is_plane(id) || !s.items.iter().any(|i| matches!(i, AppearanceItem::Fill(_)))) - .try_for_each(|s| facets(id, &s.path, s.rule, b, p).map(|_| ())) + let cast = casts_shadow(id, p); + let fill = |s: &Profile| s.items.iter().any(|i| matches!(i, AppearanceItem::Fill(_)) && (!is_plane(id) || visible(i, s.opacity))); + shapes.iter().filter(|s| if is_plane(id) { !(cast && fill(s)) } else { !fill(s) }).try_for_each(|s| facets(id, &s.path, s.rule, b, p).map(|_| ())) } /// Do the solids 3D effect `id` with parameters `p` builds from the fills and strokes of `shapes` -/// fit, each on its own and all of them together ([`built_solids`])? Rotate's planes are not -/// counted. +/// fit, each on its own and all of them together ([`built_solids`]), and with its shadow cast, does +/// the shadow fit? The shadow is cast from the faces those same builds kept ([`cast_built`]), as +/// [`art_for`] casts it: Extrude & Bevel and Inflate build each solid once, and Rotate builds the +/// plane of each visible fill and stroke once. Rotate's planes are not counted, and without its +/// shadow Rotate builds no plane here. fn check_solids(id: &str, p: &Value, shapes: &[Profile]) -> Result<(), String> { - let Some(b) = union_bounds(shapes).filter(|_| !is_plane(id)) else { return Ok(()) }; + let Some(b) = union_bounds(shapes) else { return Ok(()) }; + let cast = casts_shadow(id, p); + if is_plane(id) { + if !cast { + return Ok(()); + } + let mut built = vec![]; + for s in shapes { + for item in &s.items { + if !visible(item, s.opacity) { + built.push(None); + continue; + } + let (area, rule) = region(&s.path, s.rule, item); + #[cfg(test)] + SOLIDS_BUILT.with(|n| n.set(n.get() + 1)); + built.push(facets_and_faces(ROTATE, &area, rule, b, p, true)?.1); + } + } + return cast_built(id, p, shapes, built).map(|_| ()); + } let (parts, bounds) = solid_parts(shapes, b); - built_solids(id, p, &parts, bounds, MAX_OBJECT_FACES).try_for_each(|r| r.map(|_| ())) + if !cast { + return built_solids(id, p, &parts, bounds, MAX_OBJECT_FACES).try_for_each(|r| r.map(|_| ())); + } + let built = built_solids_cast(id, p, &parts, bounds, MAX_OBJECT_FACES, true) + .map(|r| r.map(|solid| solid.and_then(|(_, faces)| faces))) + .collect::, String>>()?; + cast_built(id, p, shapes, built).map(|_| ()) } /// [`profile`], or the error a command reports for object `n`: type with no outlines to build from @@ -733,7 +762,8 @@ thread_local! { /// surfaces count too. pub(crate) static SOLIDS_BUILT: std::cell::Cell = const { std::cell::Cell::new(0) }; /// How many Extrude & Bevel (Classic included) and Inflate solids [`facets`] and - /// [`built_solids`] have built on this thread, for the tests. + /// [`built_solids`] have built on this thread, for the tests. The solids built to cast a shadow + /// ([`cast_shadow`]) count too. static SOLID_GEOMETRY_BUILT: std::cell::Cell = const { std::cell::Cell::new(0) }; } @@ -1435,7 +1465,7 @@ fn art_for(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profile]) -> return Some((vec![], wireframe::wire_surfaces(n.id, fx, shapes)?)); } let p = crate::merged_params(&fx.id, &fx.params); - let cast = !is_classic_three_d(&fx.id) && shadow::options(&p).is_some(); + let cast = casts_shadow(&fx.id, &p); let (art, built) = surfaces_for(doc, n, fx, shapes, cast)?; // A shadow past the limits draws the source path, as a solid past them does; commands report // the error ([`validate_solid_in`]). @@ -1500,12 +1530,16 @@ fn cast_shadow<'a>(id: &str, p: &Value, shapes: &'a [Profile]) -> Result = inks.iter().map(|i| i.casts()).collect(); #[cfg(test)] SOLIDS_BUILT.with(|n| n.set(n.get() + shapes.len())); + #[cfg(test)] + SOLID_GEOMETRY_BUILT.with(|n| n.set(n.get() + casts.iter().filter(|c| **c).count())); caster.inflate(&shapes, &casts, bounds, inflate_options(p), view) } else { let mut added = vec![]; for ((_, _, area, rule, _, _), ink) in parts.iter().zip(&inks) { #[cfg(test)] SOLIDS_BUILT.with(|n| n.set(n.get() + usize::from(ink.casts()))); + #[cfg(test)] + SOLID_GEOMETRY_BUILT.with(|n| n.set(n.get() + usize::from(ink.casts()))); added.push(if ink.casts() { caster.extrude(area, *rule, bounds, extrude_options(p), view) } else { Ok(0..0) }); } added @@ -1529,16 +1563,14 @@ fn cast_shadow<'a>(id: &str, p: &Value, shapes: &'a [Profile]) -> Result(id: &str, p: &Value, shapes: &'a [Profile], built: Vec>) -> Result>, String> { if id == CLASSIC_EXTRUDE || id == CLASSIC_ROTATE { return Ok(None); } let (Some(settings), Some(b)) = (shadow::options(p), union_bounds(shapes)) else { return Ok(None) }; - let view = view_options(p); let mut caster = vectorcraft_three_d::ShadowCaster::new(); let mut cast: Vec = vec![]; let ink = |item: &AppearanceItem, member: f32| { @@ -1555,39 +1587,22 @@ fn cast_built<'a>(id: &str, p: &Value, shapes: &'a [Profile], built: Vec caster.add_solid(kept)?, - None => { - let (area, rule) = region(&s.path, s.rule, item); - #[cfg(test)] - SOLIDS_BUILT.with(|n| n.set(n.get() + 1)); - caster.plane(&area, rule, b, view)? - } - }; - cast.push((s.scopes.as_slice(), ink, faces)); + let Some(kept) = kept else { continue }; + cast.push((s.scopes.as_slice(), ink, caster.add_solid(kept)?)); } return Ok(Some((caster, settings, cast))); } - let (parts, bounds) = solid_parts(shapes, b); - let inks: Vec = parts.iter().map(|(item, member, ..)| ink(item, *member)).collect(); - if parts.len() != built.len() || (id == INFLATE && inks.iter().zip(&built).any(|(ink, kept)| ink.casts() && kept.is_none())) { + let (parts, _) = solid_parts(shapes, b); + if parts.len() != built.len() { return cast_shadow(id, p, shapes); } - for (((item, _, area, rule, scopes, _), ink), kept) in parts.iter().zip(inks).zip(built) { - if !ink.casts() { - continue; - } - let faces = match kept { - Some(kept) => caster.add_solid(kept), - None => { - #[cfg(test)] - SOLIDS_BUILT.with(|n| n.set(n.get() + 1)); - caster.extrude(area, *rule, bounds, extrude_options(p), view) - } - }; + for ((item, member, _, _, scopes, _), kept) in parts.iter().zip(built) { + let ink = ink(item, *member); + // A fully transparent solid, or a stroke's solid left out of the art, casts nothing. + let Some(kept) = kept.filter(|_| ink.casts()) else { continue }; // A stroke whose own solid is past the limits is left out; past the shadow's limit for all // the solids together, the shadow is refused. - let faces = match faces { + let faces = match caster.add_solid(kept) { Ok(faces) => faces, Err(e) if matches!(item, AppearanceItem::Stroke(_)) && e != vectorcraft_three_d::TOO_COMPLEX_SHADOW => continue, Err(e) => return Err(e), diff --git a/crates/effects/src/solids/tests.rs b/crates/effects/src/solids/tests.rs index de1ec75de3..9b57c989c6 100644 --- a/crates/effects/src/solids/tests.rs +++ b/crates/effects/src/solids/tests.rs @@ -1082,7 +1082,8 @@ fn geometry_builds(check: impl FnOnce() -> Result<(), String>) -> (usize, Result /// The check builds each solid the effect draws once, about the bounds it draws it about: one for /// a fill and one for each stroke, on an object, on a group's members and on an appearance item, -/// with the shadow on or off. +/// with the shadow on or off. With the shadow on, the shadow is cast from the faces those builds +/// kept, so no solid is built again for it. #[test] fn the_check_builds_each_drawn_solid_once() { for id in [EXTRUDE, CLASSIC_EXTRUDE, INFLATE] { @@ -1098,6 +1099,11 @@ fn the_check_builds_each_drawn_solid_once() { assert_eq!(geometry_builds(|| validate_three_d_at(&n, id, &json!({}), (Some(0), 0))), (1, Ok(())), "{id}: on the fill"); let shadow = json!({"shadow": true}); assert_eq!(geometry_builds(|| validate_solid(&n, id, &shadow)), (2, Ok(())), "{id}: with the shadow on"); + let mut other = square_node(); + other.id = NodeId(2); + let g = Node::group(NodeId(9999), vec![Arc::new(square_node()), Arc::new(other)]); + assert_eq!(geometry_builds(|| validate_solid(&g, id, &shadow)), (4, Ok(())), "{id}: a group with the shadow on"); + assert_eq!(geometry_builds(|| validate_three_d_at(&n, id, &shadow, (Some(0), 0))), (1, Ok(())), "{id}: the fill with the shadow on"); } } diff --git a/crates/effects/src/solids/tests_shadow.rs b/crates/effects/src/solids/tests_shadow.rs index 7dfd78f28d..d24cd6e86f 100644 --- a/crates/effects/src/solids/tests_shadow.rs +++ b/crates/effects/src/solids/tests_shadow.rs @@ -313,6 +313,68 @@ fn the_shadow_cast_from_the_solids_drawn_is_the_shadow_of_solids_built_for_it() } } +/// A stroke's solid left out of the art (past its own limits) keeps no faces, and the shadow cast +/// from the faces the solids kept leaves it out without building it: it casts nothing, as it draws +/// nothing, and the fill's solid still casts. +#[test] +fn a_stroke_left_out_of_the_art_casts_no_shadow() { + for id in [EXTRUDE, INFLATE] { + let n = stroked_square(1, 0.0, 1.0); + let (path, rule) = profile(&n).unwrap(); + let shapes = [Profile { path, rule, items: solid_paints(&n), opacity: 1.0, scopes: vec![] }]; + let p = crate::merged_params(id, &json!({"shadow": true})); + let (parts, bounds) = solid_parts(&shapes, union_bounds(&shapes).unwrap()); + let mut built: Vec> = + built_solids_cast(id, &p, &parts, bounds, MAX_OBJECT_FACES, true).map(|r| r.unwrap().and_then(|(_, faces)| faces)).collect(); + let stroke = parts.iter().position(|(item, ..)| matches!(item, AppearanceItem::Stroke(_))).unwrap(); + assert!(built.len() == 2 && built.iter().all(Option::is_some), "{id}"); + let (both, _, cast) = cast_built(id, &p, &shapes, built.clone()).unwrap().unwrap(); + assert_eq!(cast.len(), 2, "{id}: the fill and the stroke cast"); + built[stroke] = None; + let start = SOLIDS_BUILT.with(std::cell::Cell::get); + let (fill, _, cast) = cast_built(id, &p, &shapes, built).unwrap().unwrap(); + assert_eq!(SOLIDS_BUILT.with(std::cell::Cell::get), start, "{id}: no solid is built for the shadow"); + assert_eq!(cast.len(), 1, "{id}: the stroke left out casts nothing"); + assert!(!fill.is_empty() && fill.len() < both.len(), "{id}: only the fill's faces are cast"); + } +} + +/// A command accepts each shadowed object that draws with its shadow, and with Rotate builds the +/// plane of each visible fill and stroke once for the shadow: a fully transparent one casts nothing. +#[test] +fn the_check_accepts_the_shadowed_objects_that_draw() { + for id in [EXTRUDE, INFLATE, ROTATE] { + for params in shadow_settings(id) { + for n in shadowed(id, ¶ms) { + let mut drawn = 0; + art(&n, id).unwrap().walk(&mut |c| drawn += usize::from(shadow_opacity(c).is_some())); + assert!(drawn > 0, "{id} {params}"); + assert_eq!(validate_solid(&n, id, ¶ms), Ok(()), "{id} {params}"); + } + } + } + let shadow = json!({"shadow": true}); + for (stroke, planes) in [(1.0, 2), (0.5, 2), (0.0, 1)] { + let n = stroked_square(1, 0.0, stroke); + let start = SOLIDS_BUILT.with(std::cell::Cell::get); + assert_eq!(validate_solid(&n, ROTATE, &shadow), Ok(()), "{stroke}"); + assert_eq!(SOLIDS_BUILT.with(std::cell::Cell::get) - start, planes, "Rotate, a stroke at {stroke}"); + } +} + +/// In wireframe mode no shadow is drawn, so the check casts none: with Shadows on, Rotate builds no +/// plane for a shadow, and Extrude & Bevel and Inflate build each solid once, as with the shadow off. +#[test] +fn the_check_casts_no_shadow_in_wireframe_mode() { + let n = stroked_square(1, 0.0, 1.0); + let wire = json!({"shadow": true, "render": {"mode": "wireframe"}}); + for (id, solids) in [(ROTATE, 0), (EXTRUDE, 2), (INFLATE, 2)] { + let start = SOLIDS_BUILT.with(std::cell::Cell::get); + assert_eq!(validate_solid(&n, id, &wire), Ok(()), "{id}"); + assert_eq!(SOLIDS_BUILT.with(std::cell::Cell::get) - start, solids, "{id}"); + } +} + /// The opacity of each part of the shadow of `n` (its 3D effect's shadow on) and the shadow's art, /// as [`cast_shadow`] casts it from solids built for the shadow alone and as [`cast_built`] casts /// it from the faces the solids drawn kept. diff --git a/crates/engine/src/cmd/buildcmds.rs b/crates/engine/src/cmd/buildcmds.rs index 66c9ec8fc4..95c04e39c7 100644 --- a/crates/engine/src/cmd/buildcmds.rs +++ b/crates/engine/src/cmd/buildcmds.rs @@ -126,7 +126,7 @@ pub fn specs() -> Vec { "Live Paint Bucket (Stroke)", [], None, - "{group: id, point: [x,y], color?|swatch?|none? (default: current stroke), width?: pt (default: current weight), tolerance?: pt (4), scope?: \"one\" (default: the edge alone) | \"connected\" (a double-click: also each edge joined to it, end to end, through edges that draw with stroke paint match) | \"samePaint\" (a triple-click: also every edge of the group that draws with stroke paint match), match?: paint (as the document stores it; scope connected or samePaint only; default: the stroke paint the edge draws with; an edge draws with the paint of its topmost stroke that is shown, with paint, above 0 pt and not fully transparent, and with none when the edge is fully transparent or has no such stroke), tint?: 0..100, keepModel?: bool (both as paint.setFill)} paint the edge nearest point, skipping hidden edges: each edge reached has its strokes replaced by one stroke with the paint and width, shown, fully opaque and blending normally, in the place of its topmost stroke and with the dashes, caps and arrowheads of its topmost shown stroke (a new stroke above the fills when it has none; none leaves one stroke of none), and its fills stay as they are; when every edge it reaches already has only that one stroke (at any width for none), nothing changes (no undo step, and the recent colors stay as they are) → {group, edge, count (edges reached)}", + "{group: id, point: [x,y], color?|swatch?|none? (default: current stroke), width?: pt (default: current weight), tolerance?: pt (4), scope?: \"one\" (default: the edge alone) | \"connected\" (a double-click: also each edge joined to it, end to end, through edges that draw with stroke paint match) | \"samePaint\" (a triple-click: also every edge of the group that draws with stroke paint match), match?: paint (as the document stores it; scope connected or samePaint only; default: the stroke paint the edge draws with; an edge draws with the paint of its topmost stroke that is shown, with paint, above 0 pt and not fully transparent, and with none when the edge is fully transparent or has no such stroke), through?: [id…] (scope connected only; at most 4096 edges counted as drawing with stroke paint match whatever they draw with, such as the edge a double-click's first click painted), tint?: 0..100, keepModel?: bool (both as paint.setFill)} paint the edge nearest point, skipping hidden edges: each edge reached has its strokes replaced by one stroke with the paint and width, shown, fully opaque and blending normally, in the place of its topmost stroke and with the dashes, caps and arrowheads of its topmost shown stroke (a new stroke above the fills when it has none; none leaves one stroke of none), and its fills stay as they are; when every edge it reaches already has only that one stroke (at any width for none), nothing changes (no undo step, and the recent colors stay as they are) → {group, edge, count (edges reached)}", has_doc, lp_stroke_edge ), diff --git a/crates/engine/src/cmd/buildcmds/live_paint.rs b/crates/engine/src/cmd/buildcmds/live_paint.rs index 6784f36294..46a2d37555 100644 --- a/crates/engine/src/cmd/buildcmds/live_paint.rs +++ b/crates/engine/src/cmd/buildcmds/live_paint.rs @@ -567,6 +567,16 @@ pub(super) fn lp_stroke_edge(s: &mut Session, p: &Value) -> Result { let tol = number_or(p, "tolerance", 4.0, C)?.clamp(0.0, 1000.0); let scope = scope_param(p, C)?; let like = match_param(p, C, scope != LpScope::One, "\"connected\" or \"samePaint\"")?; + let through: Vec = match p.get("through") { + None => vec![], + Some(_) if scope != LpScope::Connected => return Err(bad(C, "through applies to scope \"connected\"")), + Some(v) => { + let ids = v.as_array().filter(|ids| ids.len() <= 4096).ok_or_else(|| bad(C, "through must be an array of at most 4096 edge ids"))?; + ids.iter() + .map(|id| id.as_u64().map(NodeId).ok_or_else(|| bad(C, "through must be an array of at most 4096 edge ids"))) + .collect::>()? + } + }; let (eid, count, changed) = { let d = &s.doc()?.doc; let n = d.node(g).filter(|n| is_live_paint(n)).ok_or_else(|| bad(C, format!("{g} is not a Live Paint group")))?; @@ -575,7 +585,7 @@ pub(super) fn lp_stroke_edge(s: &mut Session, p: &Value) -> Result { let like = like.unwrap_or_else(|| b::lp_stroke_paint(start)); let targets = match scope { LpScope::One => vec![eid], - LpScope::Connected => b::connected_edges(n, eid, &like), + LpScope::Connected => b::connected_edges_through(n, eid, &like, &through), LpScope::SamePaint => std::iter::once(eid) .chain(b::edges(n).into_iter().filter(|e| e.visible && e.id != eid && b::lp_stroke_paint(e) == like).map(|e| e.id)) .collect(), diff --git a/crates/engine/src/tests/build.rs b/crates/engine/src/tests/build.rs index 205f922078..c7160f9316 100644 --- a/crates/engine/src/tests/build.rs +++ b/crates/engine/src/tests/build.rs @@ -3908,6 +3908,266 @@ fn live_paint_bucket_triple_click_fills_every_face_of_the_same_fill() { assert_eq!([a, b, c, d].map(|f| fill_of(&s, f)), [green.clone(), green, red.clone(), red]); } +/// A triple-click whose first click is released across an edge, in the face it then clicks twice, +/// matches that face's fill from before the first click: the release painted it too. +#[test] +fn live_paint_bucket_triple_click_after_a_release_across_an_edge_matches_the_fill_before() { + let mut s = session(); + let g = live_squares(&mut s, &[0.0, 50.0, 100.0, 150.0]); + let [a, b, c, d] = faces_at(&s, g, &[(25.0, 25.0), (75.0, 25.0), (125.0, 25.0), (175.0, 25.0)])[..] else { panic!("four faces") }; + let (red, blue) = (Paint::solid(Color::rgb(1.0, 0.0, 0.0)), Paint::solid(Color::rgb(0.0, 0.0, 1.0))); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let all = edges_in(&s, g, Rect::new(-1.0, -1.0, 201.0, 51.0)); + paint_parts(&mut s, &all, &Paint::solid(Color::rgb(0.0, 0.0, 0.0)), &[(a, red.clone()), (b, red.clone()), (c, blue.clone()), (d, red.clone())]); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.fill = green.clone(); + s.pointer(&PointerEvent::new(PointerKind::Down, 45.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 55.0, 25.0), v).unwrap(); + assert_eq!([a, b].map(|f| fill_of(&s, f)), [green.clone(), green.clone()], "the release across x = 50 fills both faces"); + for kind in [PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick, PointerKind::Down, PointerKind::Up, PointerKind::TripleClick] { + s.pointer(&PointerEvent::new(kind, 55.0, 25.0), v).unwrap(); + } + assert_eq!([a, b, c, d].map(|f| fill_of(&s, f)), [green.clone(), green.clone(), blue, green]); +} + +/// A triple-click whose third press lands in another face and is released in the face its first +/// two clicks painted still matches that face's fill from before the first click. +#[test] +fn live_paint_bucket_triple_click_released_from_another_face_matches_the_fill_before() { + let mut s = session(); + let g = live_squares(&mut s, &[0.0, 50.0, 100.0, 150.0]); + let [a, b, c, d] = faces_at(&s, g, &[(25.0, 25.0), (75.0, 25.0), (125.0, 25.0), (175.0, 25.0)])[..] else { panic!("four faces") }; + let (red, blue) = (Paint::solid(Color::rgb(1.0, 0.0, 0.0)), Paint::solid(Color::rgb(0.0, 0.0, 1.0))); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let all = edges_in(&s, g, Rect::new(-1.0, -1.0, 201.0, 51.0)); + paint_parts(&mut s, &all, &Paint::solid(Color::rgb(0.0, 0.0, 0.0)), &[(a, red.clone()), (b, red.clone()), (c, blue.clone()), (d, red.clone())]); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.fill = green.clone(); + for kind in [PointerKind::Down, PointerKind::Up, PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick] { + s.pointer(&PointerEvent::new(kind, 55.0, 25.0), v).unwrap(); + } + s.pointer(&PointerEvent::new(PointerKind::Down, 45.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 55.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::TripleClick, 55.0, 25.0), v).unwrap(); + assert_eq!([a, b, c, d].map(|f| fill_of(&s, f)), [green.clone(), green.clone(), blue, green]); +} + +/// A triple-click whose first click makes the Live Paint group and is released across an edge, in +/// the face it then clicks twice, matches the fill that face was made with. +#[test] +fn live_paint_bucket_triple_click_after_making_the_group_across_an_edge_matches_the_made_fill() { + let mut s = session(); + let ids: Vec = [0.0, 50.0, 200.0, 300.0].iter().map(|&x| rect(&mut s, x, 0.0, 50.0, 50.0)).collect(); + let (red, blue) = (Color::rgb(1.0, 0.0, 0.0), Color::rgb(0.0, 0.0, 1.0)); + for (id, c) in ids.iter().zip([red, red, blue, red]) { + set_fill(&mut s, *id, c); + } + s.execute("select.set", &json!({"ids": ids.iter().map(|i| i.0).collect::>()})).unwrap(); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.fill = green.clone(); + s.pointer(&PointerEvent::new(PointerKind::Down, 45.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 55.0, 25.0), v).unwrap(); + let g = vectorcraft_tools::builder::live_paint_at(&s.doc().unwrap().doc, Point::new(25.0, 25.0)).expect("the click made a group"); + let faces = faces_at(&s, g, &[(25.0, 25.0), (75.0, 25.0), (225.0, 25.0), (325.0, 25.0)]); + assert_eq!(faces[..2].iter().map(|f| fill_of(&s, *f)).collect::>(), [green.clone(), green.clone()], "the release fills both faces"); + for kind in [PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick, PointerKind::Down, PointerKind::Up, PointerKind::TripleClick] { + s.pointer(&PointerEvent::new(kind, 55.0, 25.0), v).unwrap(); + } + assert_eq!(faces.iter().map(|f| fill_of(&s, *f)).collect::>(), [green.clone(), green.clone(), Paint::solid(blue), green]); +} + +/// When the first click makes the Live Paint group and is released in a face covered by a source +/// path with no fill in front of a filled one, the face was made with the filled source's fill, as +/// Make gives it, so the triple-click there matches that fill and not none. +#[test] +fn live_paint_bucket_triple_click_after_making_the_group_under_an_unfilled_path_matches_the_made_fill() { + let mut s = session(); + let red = Color::rgb(1.0, 0.0, 0.0); + let (a, b, d) = (rect(&mut s, 0.0, 0.0, 50.0, 50.0), rect(&mut s, 50.0, 0.0, 50.0, 50.0), rect(&mut s, 200.0, 0.0, 50.0, 50.0)); + for id in [a, b, d] { + set_fill(&mut s, id, red); + } + let (c, e) = (rect(&mut s, 60.0, 10.0, 30.0, 30.0), rect(&mut s, 300.0, 0.0, 50.0, 50.0)); + s.edit("t", |doc, _| { + for id in [c, e] { + doc.node_mut(id).unwrap().appearance.set_fill(Paint::None); + } + Ok(()) + }) + .unwrap(); + s.execute("select.set", &json!({"ids": [a.0, b.0, d.0, c.0, e.0]})).unwrap(); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.fill = green.clone(); + s.pointer(&PointerEvent::new(PointerKind::Down, 45.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 75.0, 25.0), v).unwrap(); + let g = vectorcraft_tools::builder::live_paint_at(&s.doc().unwrap().doc, Point::new(25.0, 25.0)).expect("the click made a group"); + let faces = faces_at(&s, g, &[(75.0, 25.0), (225.0, 25.0), (325.0, 25.0)]); + assert_eq!(fill_of(&s, faces[0]), green, "the release fills the face under the unfilled path"); + assert_eq!([faces[1], faces[2]].map(|f| fill_of(&s, f)), [Paint::solid(red), Paint::None], "Make gave the far faces red and none"); + for kind in [PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick, PointerKind::Down, PointerKind::Up, PointerKind::TripleClick] { + s.pointer(&PointerEvent::new(kind, 75.0, 25.0), v).unwrap(); + } + assert_eq!([faces[1], faces[2]].map(|f| fill_of(&s, f)), [green, Paint::None], "the triple-click matches the red the face was made with"); +} + +/// A triple-click whose first click adds paths to a selected Live Paint group and is released in a +/// face of that group matches the face's fill, not the edge around it. +#[test] +fn live_paint_bucket_triple_click_after_merging_across_an_edge_matches_the_face_fill() { + let mut s = session(); + let g = live_squares(&mut s, &[0.0]); + let [a] = faces_at(&s, g, &[(25.0, 25.0)])[..] else { panic!("one face") }; + let red = Paint::solid(Color::rgb(1.0, 0.0, 0.0)); + let all = edges_in(&s, g, Rect::new(-1.0, -1.0, 51.0, 51.0)); + paint_parts(&mut s, &all, &Paint::solid(Color::rgb(0.0, 0.0, 0.0)), &[(a, red.clone())]); + let (next, far) = (rect(&mut s, 50.0, 0.0, 50.0, 50.0), rect(&mut s, 200.0, 0.0, 50.0, 50.0)); + set_fill(&mut s, next, Color::rgb(0.0, 0.0, 1.0)); + set_fill(&mut s, far, Color::rgb(1.0, 0.0, 0.0)); + s.execute("select.set", &json!({"ids": [g.0, next.0, far.0]})).unwrap(); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.fill = green.clone(); + s.pointer(&PointerEvent::new(PointerKind::Down, 55.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 45.0, 25.0), v).unwrap(); + let g = vectorcraft_tools::builder::live_paint_at(&s.doc().unwrap().doc, Point::new(25.0, 25.0)).expect("the click merged the paths"); + let faces = faces_at(&s, g, &[(25.0, 25.0), (225.0, 25.0)]); + assert_eq!(fill_of(&s, faces[0]), green, "the release fills the group's face"); + for kind in [PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick, PointerKind::Down, PointerKind::Up, PointerKind::TripleClick] { + s.pointer(&PointerEvent::new(kind, 45.0, 25.0), v).unwrap(); + } + assert_eq!(fill_of(&s, faces[1]), green, "the far face had the red the face had"); +} + +/// When the first click merges two selected Live Paint groups, a face of the group in front takes +/// its source path's fill, so a triple-click there after a release across an edge matches that fill +/// and not the paint the face had before the merge. +#[test] +fn live_paint_bucket_triple_click_after_merging_two_groups_matches_the_merged_fill() { + let mut s = session(); + let back = live_squares(&mut s, &[0.0]); + let source = rect(&mut s, 100.0, 0.0, 50.0, 50.0); + set_fill(&mut s, source, Color::rgb(1.0, 0.0, 0.0)); + s.execute("select.set", &json!({"ids": [source.0]})).unwrap(); + let front = NodeId(s.execute("livePaint.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + let [f] = faces_at(&s, front, &[(125.0, 25.0)])[..] else { panic!("one face") }; + let blue = Paint::solid(Color::rgb(0.0, 0.0, 1.0)); + paint_parts(&mut s, &[], &Paint::None, &[(f, blue.clone())]); + let (next, far) = (rect(&mut s, 150.0, 0.0, 50.0, 50.0), rect(&mut s, 300.0, 0.0, 50.0, 50.0)); + set_fill(&mut s, next, Color::rgb(1.0, 1.0, 0.0)); + set_fill(&mut s, far, Color::rgb(1.0, 0.0, 0.0)); + s.execute("select.set", &json!({"ids": [back.0, front.0, next.0, far.0]})).unwrap(); + let merged = NodeId(s.execute("livePaint.merge", &json!({})).unwrap()["id"].as_u64().unwrap()); + let [m] = faces_at(&s, merged, &[(125.0, 25.0)])[..] else { panic!("one face") }; + assert_eq!(fill_of(&s, m), Paint::solid(Color::rgb(1.0, 0.0, 0.0)), "Merge gives the front group's face its source's fill"); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute("select.set", &json!({"ids": [back.0, front.0, next.0, far.0]})).unwrap(); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.fill = green.clone(); + s.pointer(&PointerEvent::new(PointerKind::Down, 155.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 145.0, 25.0), v).unwrap(); + let g = vectorcraft_tools::builder::live_paint_at(&s.doc().unwrap().doc, Point::new(125.0, 25.0)).expect("the click merged the groups"); + let faces = faces_at(&s, g, &[(125.0, 25.0), (325.0, 25.0)]); + assert_eq!(fill_of(&s, faces[0]), green, "the release fills the front group's face"); + for kind in [PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick, PointerKind::Down, PointerKind::Up, PointerKind::TripleClick] { + s.pointer(&PointerEvent::new(kind, 145.0, 25.0), v).unwrap(); + } + assert_eq!(fill_of(&s, faces[1]), green, "the far face had the red the merge gave the face"); +} + +/// When the first click merges paths into a selected Live Paint group whose face has an unplaced +/// gradient, Merge fixes the gradient to the face's fit, so a triple-click there after a release +/// across an edge matches the fixed gradient: a far face whose source has that same fixed gradient +/// takes the bucket's paint. +#[test] +fn live_paint_bucket_triple_click_after_merging_matches_the_fixed_gradient() { + use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop}; + let stops = vec![GradientStop::new(0.0, Color::BLACK), GradientStop::new(1.0, Color::WHITE)]; + let gradient = Paint::Gradient(Box::new(GradientPaint::new(Gradient::new(GradientKind::Linear, stops)))); + let mut s = session(); + let g = live_squares(&mut s, &[0.0]); + let [f] = faces_at(&s, g, &[(25.0, 25.0)])[..] else { panic!("one face") }; + paint_parts(&mut s, &[], &Paint::None, &[(f, gradient.clone())]); + let (next, far) = (rect(&mut s, 50.0, 0.0, 50.0, 50.0), rect(&mut s, 200.0, 0.0, 50.0, 50.0)); + set_fill(&mut s, next, Color::rgb(1.0, 1.0, 0.0)); + s.execute("select.set", &json!({"ids": [g.0, next.0]})).unwrap(); + let merged = NodeId(s.execute("livePaint.merge", &json!({})).unwrap()["id"].as_u64().unwrap()); + let [m] = faces_at(&s, merged, &[(25.0, 25.0)])[..] else { panic!("one face") }; + let fixed = fill_of(&s, m); + assert_ne!(fixed, gradient, "Merge fixes the face's gradient to its fit"); + s.execute("edit.undo", &json!({})).unwrap(); + s.edit("t", |d, _| { + d.node_mut(far).unwrap().appearance.set_fill(fixed.clone()); + Ok(()) + }) + .unwrap(); + s.execute("select.set", &json!({"ids": [g.0, next.0, far.0]})).unwrap(); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + s.paint.fill = green.clone(); + s.pointer(&PointerEvent::new(PointerKind::Down, 55.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 45.0, 25.0), v).unwrap(); + let g = vectorcraft_tools::builder::live_paint_at(&s.doc().unwrap().doc, Point::new(45.0, 25.0)).expect("the click merged the paths"); + let [far_face] = faces_at(&s, g, &[(225.0, 25.0)])[..] else { panic!("the far face") }; + assert_eq!(fill_of(&s, far_face), fixed, "the far face keeps its source's fixed gradient"); + for kind in [PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick, PointerKind::Down, PointerKind::Up, PointerKind::TripleClick] { + s.pointer(&PointerEvent::new(kind, 45.0, 25.0), v).unwrap(); + } + assert_eq!(fill_of(&s, far_face), green, "the far face had the fixed gradient the merge gave the face"); +} + +/// When the first click merges a line that splits a painted face of the selected Live Paint group, +/// Merge keeps the face's paint in one part only and the other part takes its source path's fill; +/// a triple-click in that other part after a release across an edge matches the source's fill. +#[test] +fn live_paint_bucket_triple_click_after_a_merge_splits_a_face_matches_the_part_fill() { + let mut s = session(); + let source = rect(&mut s, 0.0, 0.0, 50.0, 50.0); + set_fill(&mut s, source, Color::rgb(1.0, 0.0, 0.0)); + s.execute("select.set", &json!({"ids": [source.0]})).unwrap(); + let g = NodeId(s.execute("livePaint.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + let [f] = faces_at(&s, g, &[(25.0, 25.0)])[..] else { panic!("one face") }; + paint_parts(&mut s, &[], &Paint::None, &[(f, Paint::solid(Color::rgb(0.0, 0.0, 1.0)))]); + let line = NodeId(s.execute("shape.line", &json!({"x1": 40, "y1": -10, "x2": 40, "y2": 60})).unwrap()["id"].as_u64().unwrap()); + let next = rect(&mut s, 50.0, 0.0, 50.0, 50.0); + set_fill(&mut s, next, Color::rgb(1.0, 1.0, 0.0)); + let (red_far, blue_far) = (rect(&mut s, 200.0, 0.0, 50.0, 50.0), rect(&mut s, 300.0, 0.0, 50.0, 50.0)); + set_fill(&mut s, red_far, Color::rgb(1.0, 0.0, 0.0)); + set_fill(&mut s, blue_far, Color::rgb(0.0, 0.0, 1.0)); + let ids = json!({"ids": [g.0, line.0, next.0, red_far.0, blue_far.0]}); + s.execute("select.set", &ids).unwrap(); + let merged = NodeId(s.execute("livePaint.merge", &json!({})).unwrap()["id"].as_u64().unwrap()); + let parts = faces_at(&s, merged, &[(20.0, 25.0), (45.0, 25.0)]); + assert_eq!( + parts.iter().map(|p| fill_of(&s, *p)).collect::>(), + [Paint::solid(Color::rgb(0.0, 0.0, 1.0)), Paint::solid(Color::rgb(1.0, 0.0, 0.0))], + "Merge keeps the paint in the part that holds the face's inside point" + ); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute("select.set", &ids).unwrap(); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.fill = green.clone(); + s.pointer(&PointerEvent::new(PointerKind::Down, 55.0, 25.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 45.0, 25.0), v).unwrap(); + for kind in [PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick, PointerKind::Down, PointerKind::Up, PointerKind::TripleClick] { + s.pointer(&PointerEvent::new(kind, 45.0, 25.0), v).unwrap(); + } + let g = vectorcraft_tools::builder::live_paint_at(&s.doc().unwrap().doc, Point::new(45.0, 25.0)).expect("the click merged the paths"); + let far = faces_at(&s, g, &[(225.0, 25.0), (325.0, 25.0)]); + assert_eq!(far.iter().map(|p| fill_of(&s, *p)).collect::>(), [green, Paint::solid(Color::rgb(0.0, 0.0, 1.0))]); +} + /// A triple-click whose first click makes the Live Paint group from the selected paths matches the /// fill the face was made with. #[test] @@ -3978,6 +4238,116 @@ fn live_paint_bucket_double_and_triple_click_paint_joined_and_same_stroke_edges( assert_eq!(node(&s, apart[0]).appearance.stroke_paint(), black); } +/// A double-click whose two clicks land on two joined edges paints every edge joined to them that +/// had their stroke: the edge the first click painted still joins the others. +#[test] +fn live_paint_bucket_double_click_across_a_junction_paints_the_joined_edges() { + // A square with a line across its middle, cut at x = 30 and x = 70 by two lines from the top: the + // middle line's three edges join end to end. + let mut s = session(); + let mut ids = vec![rect(&mut s, 0.0, 0.0, 100.0, 100.0).0]; + for anchors in [ + json!([{"x": 0, "y": 50}, {"x": 100, "y": 50}]), + json!([{"x": 30, "y": 0}, {"x": 30, "y": 70}]), + json!([{"x": 70, "y": 0}, {"x": 70, "y": 70}]), + ] { + ids.push(s.execute("path.create", &json!({ "anchors": anchors })).unwrap()["id"].as_u64().unwrap()); + } + s.execute("select.set", &json!({"ids": ids})).unwrap(); + let g = NodeId(s.execute("livePaint.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + let (black, red) = (Paint::solid(Color::rgb(0.0, 0.0, 0.0)), Paint::solid(Color::rgb(1.0, 0.0, 0.0))); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let all = edges_in(&s, g, Rect::new(-1.0, -1.0, 101.0, 101.0)); + paint_parts(&mut s, &all, &red, &[]); + let middle = edges_in(&s, g, Rect::new(-1.0, 49.0, 101.0, 51.0)); + assert_eq!(middle.len(), 3, "the middle line's three edges"); + paint_parts(&mut s, &middle, &black, &[]); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.stroke = green.clone(); + let shift = Mods { shift: true, ..Default::default() }; + for (kind, x) in + [(PointerKind::Down, 50.0), (PointerKind::Up, 50.0), (PointerKind::Down, 85.0), (PointerKind::Up, 85.0), (PointerKind::DoubleClick, 85.0)] + { + s.pointer(&PointerEvent::new(kind, x, 50.0).with_mods(shift), v).unwrap(); + } + assert_eq!(middle.iter().map(|e| node(&s, *e).appearance.stroke_paint()).collect::>(), [green.clone(), green.clone(), green]); + // `through` takes edge ids, with scope "connected" only. + for p in [ + json!({"group": g.0, "point": [15, 50], "scope": "connected", "through": "x"}), + json!({"group": g.0, "point": [15, 50], "scope": "connected", "through": [-1]}), + json!({"group": g.0, "point": [15, 50], "scope": "samePaint", "through": []}), + json!({"group": g.0, "point": [15, 50], "through": []}), + ] { + assert!(s.execute("livePaint.strokeEdge", &p).is_err(), "{p}"); + } +} + +/// A double-click whose second press lands on the next joined edge and is released back on the +/// edge the first click painted (at the end of the line) matches that edge's stroke paint from +/// before the first click, and the edge the second press painted still joins the edge past it. +#[test] +fn live_paint_bucket_double_click_released_back_on_the_first_edge_paints_the_joined_edges() { + let mut s = session(); + let mut ids = vec![rect(&mut s, 0.0, 0.0, 100.0, 100.0).0]; + for anchors in [ + json!([{"x": 0, "y": 50}, {"x": 100, "y": 50}]), + json!([{"x": 30, "y": 0}, {"x": 30, "y": 70}]), + json!([{"x": 70, "y": 0}, {"x": 70, "y": 70}]), + ] { + ids.push(s.execute("path.create", &json!({ "anchors": anchors })).unwrap()["id"].as_u64().unwrap()); + } + s.execute("select.set", &json!({"ids": ids})).unwrap(); + let g = NodeId(s.execute("livePaint.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + let (black, red) = (Paint::solid(Color::rgb(0.0, 0.0, 0.0)), Paint::solid(Color::rgb(1.0, 0.0, 0.0))); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let all = edges_in(&s, g, Rect::new(-1.0, -1.0, 101.0, 101.0)); + paint_parts(&mut s, &all, &red, &[]); + let middle = edges_in(&s, g, Rect::new(-1.0, 49.0, 101.0, 51.0)); + assert_eq!(middle.len(), 3, "the middle line's three edges"); + paint_parts(&mut s, &middle, &black, &[]); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.stroke = green.clone(); + let shift = Mods { shift: true, ..Default::default() }; + for (kind, x) in + [(PointerKind::Down, 15.0), (PointerKind::Up, 15.0), (PointerKind::Down, 50.0), (PointerKind::Up, 15.0), (PointerKind::DoubleClick, 15.0)] + { + s.pointer(&PointerEvent::new(kind, x, 50.0).with_mods(shift), v).unwrap(); + } + assert_eq!(middle.iter().map(|e| node(&s, *e).appearance.stroke_paint()).collect::>(), [green.clone(), green.clone(), green]); +} + +/// A triple-click whose second press holds Cmd (it goes to the selection tool Cmd lends) matches +/// the fill the face had before the first click: the lent press counts as one that paints nothing. +#[test] +fn live_paint_bucket_triple_click_with_a_cmd_press_between_matches_the_fill_before() { + let mut s = session(); + let g = live_squares(&mut s, &[0.0, 50.0, 100.0, 150.0]); + let [a, b, c, d] = faces_at(&s, g, &[(25.0, 25.0), (75.0, 25.0), (125.0, 25.0), (175.0, 25.0)])[..] else { panic!("four faces") }; + let (red, blue) = (Paint::solid(Color::rgb(1.0, 0.0, 0.0)), Paint::solid(Color::rgb(0.0, 0.0, 1.0))); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + let all = edges_in(&s, g, Rect::new(-1.0, -1.0, 201.0, 51.0)); + paint_parts(&mut s, &all, &Paint::solid(Color::rgb(0.0, 0.0, 0.0)), &[(a, red.clone()), (b, red.clone()), (c, blue.clone()), (d, red.clone())]); + let v = ViewInfo::default(); + s.select_tool("livePaintBucket", v).unwrap(); + s.paint.fill = green.clone(); + let cmd = Mods { cmd: true, ..Default::default() }; + for (kind, m) in [ + (PointerKind::Down, Mods::default()), + (PointerKind::Up, Mods::default()), + (PointerKind::Down, cmd), + (PointerKind::Up, cmd), + (PointerKind::Down, Mods::default()), + (PointerKind::Up, Mods::default()), + (PointerKind::TripleClick, Mods::default()), + ] { + s.pointer(&PointerEvent::new(kind, 25.0, 25.0).with_mods(m), v).unwrap(); + } + assert_eq!(s.tool_id(), "livePaintBucket"); + assert_eq!([a, b, c, d].map(|f| fill_of(&s, f)), [green.clone(), green.clone(), blue, green]); +} + /// A `scope` that is not one of the three, a `match` that is not a paint or is given with a scope /// that compares none, and a scope with a drag's points are refused; nothing changes. #[test] diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index 66ed0a41e3..59eb78a51b 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -255,6 +255,9 @@ impl Session { } // The Selection and Group Selection tools act on the instance whole. self.select_whole_instance(id); + // The tool lent to does not see the press: it counts as a press elsewhere for the clicks a + // double-click or triple-click compares. + self.tool.press_elsewhere(); let lent = self.make_tool(id); self.selection_at_lend = self.active().map(|d| (d.uid, d.selection.clone())); self.lender = Some(std::mem::replace(&mut self.tool, lent)); @@ -1086,6 +1089,12 @@ impl Session { self.with_tool_cx(view, |t, cx| t.hover_ended(cx)); } + /// A press on the canvas went to the view tools and not to the active tool + /// ([`vectorcraft_tools::Tool::press_elsewhere`]). + pub fn tool_press_elsewhere(&mut self) { + self.tool.press_elsewhere(); + } + /// Whether the active tool's hover depends on what lies under a still pointer /// ([`vectorcraft_tools::Tool::wants_rehover`]). pub fn tool_wants_rehover(&self) -> bool { diff --git a/crates/tools/src/builder.rs b/crates/tools/src/builder.rs index 00005e3c21..51617935f5 100644 --- a/crates/tools/src/builder.rs +++ b/crates/tools/src/builder.rs @@ -41,9 +41,10 @@ pub use live_paint::{ }; use live_paint::{check_live_paint_options, lp_color, lp_rgb_color}; pub use lookup::{ - EDGE_NAME, FACE_NAME, Face, LIVE_PAINT_NAME, LIVE_PAINT_PREFIX, LP_JOIN_TOL, SOURCES_NAME, builder_members, connected_edges, drawn_outlines, - edge_near, edges, face_at, faces, flood_faces, is_live_paint, leaf_shapes, live_paint_at, live_paint_takes, lp_stroke_paint, node_outline, - outline_snap, path_contains, shape_builder_shapes, shapes_for, sources, visible_edge_near, visible_face_at, + EDGE_NAME, FACE_NAME, Face, LIVE_PAINT_NAME, LIVE_PAINT_PREFIX, LP_JOIN_TOL, SOURCES_NAME, builder_members, connected_edges, + connected_edges_through, drawn_outlines, edge_near, edges, face_at, faces, flood_faces, is_live_paint, leaf_shapes, live_paint_at, + live_paint_takes, lp_stroke_paint, node_outline, outline_snap, path_contains, shape_builder_shapes, shapes_for, sources, visible_edge_near, + visible_face_at, }; pub use map::{ BuilderMap, HATCH, HIGHLIGHT_RED, Hit, MergeGeometry, MergeInput, PreparedMerge, Rest, Touched, hatch, maps_built, merge_geometry, merge_inputs, diff --git a/crates/tools/src/builder/live_paint.rs b/crates/tools/src/builder/live_paint.rs index bdb1ca2e7b..b32535d83e 100644 --- a/crates/tools/src/builder/live_paint.rs +++ b/crates/tools/src/builder/live_paint.rs @@ -1,14 +1,15 @@ use super::cache::RegionCache; use super::lookup::{ - connected_edges, edges, faces, flood_faces, is_live_paint, leaf_shapes, live_paint_at, live_paint_at_where, lp_stroke_paint, node_outline, - visible_edge_near, visible_face_at, + connected_edges, connected_edges_through, edges, face_at, faces, flood_faces, is_live_paint, leaf_shapes, live_paint_at, live_paint_at_where, + lp_stroke_paint, node_outline, visible_edge_near, visible_face_at, }; -use super::map::{HIGHLIGHT_RED, sorted_roots}; +use super::map::{BuilderMap, HIGHLIGHT_RED, sorted_roots}; use super::{ Action, Arc, BezPath, CLICK_TOL_PX, Cursor, Document, EDGE_NAME, FACE_NAME, FillRule, Mods, Node, NodeId, Overlay, Point, PointerEvent, PointerKind, Rect, Tool, ToolContext, ToolKey, Value, color_swatches, json, json_ids, path_contains, pick_swatch, plain, swatch_chips, }; use vectorcraft_color::Paint; +use vectorcraft_pathops as po; // ---------- Live Paint Bucket ---------- @@ -178,10 +179,12 @@ enum LpPaint { /// /// A double-click on a face fills it and the faces reached from it across edges that draw no /// stroke (`scope: "connected"`); on an edge it paints the edges joined to it that have its stroke. -/// A triple-click on a face fills every face of the group with the face's fill, and on an edge it -/// paints every edge of the group with the edge's stroke (`scope: "samePaint"`). Each click of a -/// double-click or triple-click paints as it arrives, as its own undo step, and the paint compared -/// is the one the face or edge had before the first of its clicks that painted it. A first click +/// A triple-click on a face fills every face of the group that has the face's fill, and on an edge +/// it paints every edge of the group that draws with the edge's stroke paint (`scope: +/// "samePaint"`); each of them takes the bucket's paint. Each click of a double-click or +/// triple-click paints as it arrives, as its own undo step when it changes a paint, and the paint +/// compared is the one the face or edge had before the first of its clicks that painted it, +/// including a click whose drag or release crossed it. A first click /// that made the Live Paint group counts when the face it filled is the clicked face. Shift and the /// options choose a face or an edge as for a click; with Alt or Cmd/Ctrl held a double-click or /// triple-click paints nothing. With Space held for the view tools, a click, double-click or triple-click paints @@ -201,6 +204,8 @@ pub struct LivePaintBucketTool { at: Option<(Point, Mods)>, /// The fill command and polyline previewed from the press's snapshot. fill_drag: Option<(Value, Vec>)>, + /// What a fill drag paints, as it was at its press. + drag_from: LpDragFrom, /// The last [`LP_PRESSES`] presses, oldest first: the face or edge each one painted, with its /// paint before that press, or None for a press that painted no face or edge. presses: Vec>, @@ -229,22 +234,128 @@ struct LpPress { /// The other faces or edges the double-click that followed the press reached, each with its /// fill or drawn stroke paint before the double-click. also: Vec<(NodeId, Paint)>, + /// The other faces the press's drag crossed, its release included, each with its fill before + /// the press. + dragged: Vec<(NodeId, Paint)>, + /// For a press that makes the Live Paint group: what the group is made from, with the path + /// chunks of the press's drag, its release included. + dragged_made: Option>)>>, } -/// The fill of the face under `p` in the Live Paint group that `roots` make: the fill of the -/// front-most of their paths whose closed subpaths hold `p`, else none. Open subpaths bound no face. -fn made_face_fill(doc: &Document, roots: &[NodeId], p: Point) -> Paint { - let mut leaves = vec![]; - for n in roots.iter().filter_map(|id| doc.node(*id)) { - leaf_shapes(n, &mut leaves); +/// What a Live Paint Bucket fill drag paints, as it was at the press. +#[derive(Default)] +enum LpDragFrom { + #[default] + None, + /// The faces of an existing Live Paint group. + Faces(Vec>), + /// What the group is made from, for a drag that makes the group. + Made(LpMade), +} + +/// The faces among `faces` (a Live Paint group's faces, back to front) that a drag along the path +/// chunks `chunks` crosses, as `livePaint.fill` finds them, each with its fill. +fn crossed_faces(faces: &[Arc], chunks: &[Vec]) -> Vec<(NodeId, Paint)> { + let mut hit = vec![]; + let mut regions = vec![]; + // Front first, as visible_face_at looks. + for f in faces.iter().rev().filter(|f| f.visible) { + if let Some(path) = f.path_data() + && let Some(bounds) = path.bounds() + { + hit.push(f); + regions.push((po::Region { path: path.clone(), sources: vec![] }, path.to_bezpath(), bounds)); + } } + let map = BuilderMap { regions, ..Default::default() }; + let mut crossed: Vec<(NodeId, Paint)> = vec![]; + for chunk in chunks { + for f in map.hits_along(chunk, None).regions.iter().filter_map(|i| hit.get(*i)) { + if !crossed.iter().any(|(id, _)| *id == f.id) { + crossed.push((f.id, f.appearance.fill_paint())); + } + } + } + crossed +} + +/// What the Live Paint group a fill press makes from the selection is made from, as it was at the +/// press, following Live Paint Make and Merge. +#[derive(Debug, PartialEq)] +struct LpMade { + /// The paint Merge keeps from the faces of the first selected Live Paint group that draw: a + /// point inside each face with its fill, given to the made face that holds the point. + kept: Vec<(Point, Paint)>, + /// The paths the faces are made from, back to front: Merge's group's source paths first, then + /// the other objects', a Live Paint group giving its source paths. + sources: Vec, +} + +/// What the Live Paint group the selected `roots` make is made from ([`LpMade`]). +fn made_leaves(doc: &Document, roots: &[NodeId]) -> LpMade { + let nodes: Vec<&Node> = roots.iter().filter_map(|id| doc.node(*id)).collect(); + let target = nodes.iter().position(|n| is_live_paint(n)); + let mut kept = vec![]; + let mut sources = vec![]; + for i in target.into_iter().chain((0..nodes.len()).filter(|i| Some(*i) != target)) { + let Some(n) = nodes.get(i) else { continue }; + if !is_live_paint(n) { + leaf_shapes(n, &mut sources); + continue; + } + for s in super::lookup::sources(n).and_then(|g| g.children()).into_iter().flatten() { + leaf_shapes(s, &mut sources); + } + if Some(i) == target { + let draws = |f: &&Arc| f.visible && f.opacity > 0.0 && (f.appearance.has_drawn_fill() || f.appearance.has_drawn_stroke()); + // Merge fixes a kept unplaced gradient to its fit on the face it comes from. + let kept_fill = |f: &Arc| { + let mut n = (**f).clone(); + n.pin_gradients(); + n.appearance.fill_paint() + }; + kept.extend(faces(n).into_iter().filter(draws).filter_map(|f| Some((po::interior_point(f.path_data()?)?, kept_fill(f))))); + } + } + LpMade { kept, sources: sources.into_iter().cloned().collect() } +} + +/// The fill a face made at `p` from the source paths of `made` gets: the topmost fill that draws +/// of the front-most source path whose closed subpaths hold `p` and that has such a fill, else +/// none. Open subpaths bound no face. +fn made_face_fill(made: &LpMade, p: Point) -> Paint { let holds = |l: &Node| { node_outline(l).is_some_and(|(path, rule)| { let closed = vectorcraft_geom::PathData::new(path.subpaths.into_iter().filter(|sp| sp.closed && sp.anchors.len() >= 2).collect()); !closed.is_empty() && path_contains(&closed, rule, p) }) }; - leaves.iter().rev().find(|l| holds(l)).map_or(Paint::None, |l| l.appearance.fill_paint()) + // As Make: the front-most covering source with a fill that draws (shown, with paint and an + // opacity above 0, on a source with an opacity above 0) gives the face its topmost such fill, + // an unplaced gradient fixed to its fit on the source. + made.sources + .iter() + .rev() + .filter(|l| l.opacity > 0.0 && l.appearance.has_drawn_fill() && holds(l)) + .find_map(|l| { + let mut n = l.clone(); + n.pin_gradients(); + n.appearance.items.iter().rev().find_map(|i| match i { + vectorcraft_doc::AppearanceItem::Fill(f) if f.visible && !f.paint.is_none() && f.opacity > 0.0 => Some(f.paint.clone()), + _ => None, + }) + }) + .unwrap_or(Paint::None) +} + +/// The fill face `face` of Live Paint group `group` was made with from `made`: the kept paint +/// whose point the face holds (the last one, as Merge applies them in order), else the fill of the +/// source path at a point inside the face. +fn made_part_fill(made: &LpMade, group: &Node, face: &Node) -> Paint { + if let Some((_, paint)) = made.kept.iter().rev().find(|(p, _)| face_at(group, *p).is_some_and(|f| f.id == face.id)) { + return paint.clone(); + } + face.path_data().and_then(po::interior_point).map_or(Paint::None, |p| made_face_fill(made, p)) } /// How many presses the Live Paint Bucket keeps: the three of a triple-click. @@ -260,6 +371,7 @@ impl Default for LivePaintBucketTool { hover: LpHover::None, at: None, fill_drag: None, + drag_from: LpDragFrom::None, presses: Vec::new(), fills: true, strokes: false, @@ -336,7 +448,26 @@ impl LivePaintBucketTool { /// Note a press at `at` that paints face or edge (`edge`) `n`. fn note_part(&mut self, n: &Node, edge: bool, at: Point) { let before = if edge { lp_stroke_paint(n) } else { n.appearance.fill_paint() }; - self.note_press(Some(LpPress { part: Some(n.id), at, before, also: vec![] })); + self.note_press(Some(LpPress { part: Some(n.id), at, before, also: vec![], dragged: vec![], dragged_made: None })); + } + + /// End the fill drag, noting on the last press the other faces its drag crossed, with their + /// fills before the press (for a press that makes the group, what the group is made from and + /// the drag, for [`Self::before`] to look the faces up in the group made). → whether a fill + /// drag was on. + fn end_fill(&mut self) -> bool { + let from = std::mem::take(&mut self.drag_from); + let Some((_, chunks)) = self.fill_drag.take() else { return false }; + let Some(Some(last)) = self.presses.last_mut() else { return true }; + match from { + LpDragFrom::None => {} + LpDragFrom::Faces(faces) => { + let part = last.part; + last.dragged = crossed_faces(&faces, &chunks).into_iter().filter(|(id, _)| part != Some(*id)).collect(); + } + LpDragFrom::Made(made) => last.dragged_made = Some(Arc::new((made, chunks))), + } + true } /// Note that the double-click after the last press also reaches `parts` of group `group`, with @@ -356,12 +487,17 @@ impl LivePaintBucketTool { /// The paint `part` had before the first press of a click sequence of `clicks` presses that /// painted `part`, or before the double-click after a press when that double-click reached it /// (the sequence's first press counts when it made the group `part` is in and the face it - /// filled there is `part`); `now` when the last press did not paint it. + /// filled there is `part`), a press's drag or release crossing `part` included; `now` when the + /// last press did not paint it. fn before(&self, cx: &ToolContext, part: NodeId, clicks: usize, now: Paint) -> Paint { let Some(run) = self.presses.len().checked_sub(clicks).and_then(|from| self.presses.get(from..)) else { return now }; - let made_part = |q: &LpPress| live_paint_at(cx.doc, q.at).and_then(|g| visible_face_at(cx.doc.node(g)?, q.at)).is_some_and(|f| f.id == part); - let on_part = |i: usize, q: &LpPress| q.part == Some(part) || (i == 0 && q.part.is_none() && made_part(q)); - if !run.last().and_then(Option::as_ref).is_some_and(|q| on_part(run.len() - 1, q)) { + let made_part = |at: Point| live_paint_at(cx.doc, at).and_then(|g| visible_face_at(cx.doc.node(g)?, at)).is_some_and(|f| f.id == part); + let on_part = |i: usize, q: &LpPress| q.part == Some(part) || (i == 0 && q.part.is_none() && made_part(q.at)); + let dragged = |q: &LpPress| q.dragged.iter().any(|(id, _)| *id == part); + // An earlier press of the sequence that painted `part` counts too: a press on the next edge + // released back on `part` paints that edge, and the double-click targets `part`. + let painted = run.iter().enumerate().any(|(i, q)| q.as_ref().is_some_and(|q| on_part(i, q))); + if !painted && !run.last().and_then(Option::as_ref).is_some_and(dragged) { return now; } for (i, q) in run.iter().enumerate() { @@ -369,7 +505,17 @@ impl LivePaintBucketTool { if on_part(i, q) { return q.before.clone(); } - if let Some((_, paint)) = q.also.iter().find(|(id, _)| *id == part) { + // A face of the group the press made (the one under the press) that its drag crossed has + // the fill it was made with. + if i == 0 + && let Some(drag) = &q.dragged_made + && let Some(group) = live_paint_at(cx.doc, q.at).and_then(|g| cx.doc.node(g)) + && let Some(face) = faces(group).into_iter().find(|f| f.id == part) + && !crossed_faces(std::slice::from_ref(face), &drag.1).is_empty() + { + return made_part_fill(&drag.0, group, face); + } + if let Some((_, paint)) = q.dragged.iter().chain(&q.also).find(|(id, _)| *id == part) { return paint.clone(); } } @@ -395,7 +541,23 @@ impl LivePaintBucketTool { if clicks == 2 && let Some(group) = cx.doc.node(g) { - self.note_reached(group, connected_edges(group, e.id, &like), true); + // The other edge either click painted joins as the stroke paint it had before. + let through: Vec = self + .presses + .len() + .checked_sub(2) + .and_then(|i| self.presses.get(i..)) + .into_iter() + .flatten() + .flatten() + .filter(|q| q.before == like) + .filter_map(|q| q.part) + .filter(|id| *id != e.id) + .collect(); + self.note_reached(group, connected_edges_through(group, e.id, &like, &through), true); + if !through.is_empty() { + v["through"] = json_ids(&through); + } } if let Ok(like) = serde_json::to_value(like) { v["match"] = like; @@ -495,7 +657,7 @@ impl Tool for LivePaintBucketTool { fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec { let p = ev.pos; // A second press finishes the preceding click, including callers without a release. - if ev.kind == PointerKind::Down && self.fill_drag.take().is_some() { + if ev.kind == PointerKind::Down && self.end_fill() { let mut acts = vec![Action::Commit]; acts.extend(self.pointer(cx, ev)); return acts; @@ -553,11 +715,15 @@ impl Tool for LivePaintBucketTool { Some(f) => self.note_part(f, false, p), None => self.note_press(None), } + self.drag_from = LpDragFrom::Faces(cx.doc.node(g).map(|n| faces(n).into_iter().cloned().collect()).unwrap_or_default()); return self.begin_fill(json!({ "group": g.0, "point": point }), p); } if self.cache.at(cx, p).is_some() { let roots = sorted_roots(cx.doc, &cx.selection.objects); - self.note_press(Some(LpPress { part: None, at: p, before: made_face_fill(cx.doc, &roots, p), also: vec![] })); + let made = made_leaves(cx.doc, &roots); + let before = made_face_fill(&made, p); + self.note_press(Some(LpPress { part: None, at: p, before, also: vec![], dragged: vec![], dragged_made: None })); + self.drag_from = LpDragFrom::Made(made); return self.begin_fill(json!({ "ids": json_ids(&roots), "point": point }), p); } self.note_press(None); @@ -568,7 +734,7 @@ impl Tool for LivePaintBucketTool { // The swatch preview shows again at the release point. self.at = Some((p, ev.mods)); let mut acts = self.drag_fill(p); - if self.fill_drag.take().is_some() { + if self.end_fill() { acts.push(Action::Commit); } acts @@ -586,6 +752,7 @@ impl Tool for LivePaintBucketTool { /// the active paint, while no drag is on. fn key(&mut self, cx: &ToolContext, key: ToolKey, mods: Mods) -> Vec { if key == ToolKey::Escape { + self.drag_from = LpDragFrom::None; return if self.fill_drag.take().is_some() { vec![Action::Cancel] } else { vec![] }; } if !self.claims_key_with(cx, key, mods) { @@ -621,7 +788,7 @@ impl Tool for LivePaintBucketTool { fn deactivate(&mut self, _cx: &ToolContext) -> Vec { self.presses.clear(); - if self.fill_drag.take().is_some() { vec![Action::Commit] } else { vec![] } + if self.end_fill() { vec![Action::Commit] } else { vec![] } } /// The pointer hovers nothing for the tool: its highlight and its swatch preview go. @@ -630,6 +797,12 @@ impl Tool for LivePaintBucketTool { self.at = None; } + /// A press the view tools took counts as a press that paints no face or edge, for the clicks + /// a double-click or triple-click compares. + fn press_elsewhere(&mut self) { + self.note_press(None); + } + fn overlays(&self, cx: &ToolContext) -> Vec { let mut out = lp_overlays(&self.hover, &self.cache, self.color, self.width as f32, (self.width * LP_BUCKET_EDGE_FRACTION) as f32); // No chips during a fill drag, or while Alt makes the tool sample with the eyedropper. diff --git a/crates/tools/src/builder/lookup.rs b/crates/tools/src/builder/lookup.rs index daa9a34f82..7a08deaed3 100644 --- a/crates/tools/src/builder/lookup.rs +++ b/crates/tools/src/builder/lookup.rs @@ -405,8 +405,15 @@ impl LpEdgeGrid { /// end of an edge already reached. /// Empty when `start` is not an edge of `group` that is not hidden. pub fn connected_edges(group: &Node, start: NodeId, paint: &Paint) -> Vec { + connected_edges_through(group, start, paint, &[]) +} + +/// [`connected_edges`], with the edges in `through` counted as drawing with stroke paint `paint` +/// whatever paint they draw with now. +pub fn connected_edges_through(group: &Node, start: NodeId, paint: &Paint, through: &[NodeId]) -> Vec { use std::collections::{HashMap, HashSet}; - let es: Vec<&Arc> = edges(group).into_iter().filter(|e| e.visible && (e.id == start || lp_stroke_paint(e) == *paint)).collect(); + let es: Vec<&Arc> = + edges(group).into_iter().filter(|e| e.visible && (e.id == start || through.contains(&e.id) || lp_stroke_paint(e) == *paint)).collect(); // The first and last points of each subpath of each edge. let ends: Vec> = es .iter() diff --git a/crates/tools/src/builder/tests.rs b/crates/tools/src/builder/tests.rs index 75e15da82d..2143d3b079 100644 --- a/crates/tools/src/builder/tests.rs +++ b/crates/tools/src/builder/tests.rs @@ -1386,6 +1386,39 @@ fn bucket_triple_click_with_a_click_on_another_face_between_matches_the_first_fi ); } +/// A triple-click whose second press the view tools take (held Space) matches the fill the face had +/// before the first click: that press counts as one that paints nothing. The pointer leaving the +/// canvas between three clicks adds no press. +#[test] +fn bucket_triple_click_with_a_view_tool_press_between_matches_the_first_fill() { + use vectorcraft_color::{Color, Paint}; + let red = Paint::solid(Color::rgb(1.0, 0.0, 0.0)); + let (d, gid, f2, _) = live_group_doc(); + let mut painted = d.clone(); + painted.node_mut(f2).unwrap().appearance.set_fill(red.clone()); + let s = Selection::default(); + let p = paint(); + let (cx, later) = (cx(&d, &s, &p), cx(&painted, &s, &p)); + let own = serde_json::to_value(d.node(f2).unwrap().appearance.fill_paint()).unwrap(); + assert_ne!(own, serde_json::to_value(&red).unwrap()); + let want = vec![Action::Exec("livePaint.fill".into(), json!({ "group": gid.0, "point": [75.0, 25.0], "scope": "samePaint", "match": own }))]; + fn click(t: &mut LivePaintBucketTool, ctx: &ToolContext) { + t.pointer(ctx, &ev(PointerKind::Down, 75.0, 25.0)); + t.pointer(ctx, &ev(PointerKind::Up, 75.0, 25.0)); + } + let mut t = LivePaintBucketTool::default(); + click(&mut t, &cx); + t.press_elsewhere(); + click(&mut t, &later); + assert_eq!(t.pointer(&later, &ev(PointerKind::TripleClick, 75.0, 25.0)), want, "a view tool's press between"); + let mut t = LivePaintBucketTool::default(); + click(&mut t, &cx); + click(&mut t, &later); + t.hover_ended(&later); + click(&mut t, &later); + assert_eq!(t.pointer(&later, &ev(PointerKind::TripleClick, 75.0, 25.0)), want, "the pointer leaving between"); +} + /// With Space held for the view tools, the pointer outlines no face or edge, as a press there /// paints nothing. #[test] diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index 7a5650a25b..197d41aaaf 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs @@ -291,6 +291,9 @@ pub trait Tool: Send { /// another document became active. The Blend tool drops its first pick and stops adding to the /// blend it just made. fn history_moved(&mut self) {} + /// A press on the canvas went to the view tools (held Space, the middle button) and not to the + /// tool. The Live Paint Bucket counts it among the clicks a triple-click compares. + fn press_elsewhere(&mut self) {} /// Time passes while the pointer button is held (`dt` seconds since the last tick, whether or /// not the pointer moved): tools that keep working while the brush holds still (Twirl, Pucker, /// Bloat) act on it. The host supplies the time, so tests and agents drive it exactly. diff --git a/crates/ui-egui/src/canvas/input.rs b/crates/ui-egui/src/canvas/input.rs index e7e5c0394b..d811ad3bac 100644 --- a/crates/ui-egui/src/canvas/input.rs +++ b/crates/ui-egui/src/canvas/input.rs @@ -121,6 +121,7 @@ pub(super) fn handle_input(app: &mut VectorcraftApp, ui: &Ui, resp: &egui::Respo { // Middle-button drag pans the view whatever the tool. ui.data_mut(|dd| dd.insert_temp(drag_id(), Drag::Pan { start, center: v.center, middle: true })); + app.session.tool_press_elsewhere(); app.session.tool_hover_ended(view); } else if let Some(d) = drag { // The pointer gone (a pen lifted with its press), the drag ends where it was last seen. @@ -342,6 +343,9 @@ fn begin_drag(app: &mut VectorcraftApp, ui: &Ui, f: &Pointing, p: Pos2) { if !space && matches!(d, Drag::ZoomBox { .. } | Drag::ZoomScrub { .. } | Drag::Pan { .. } | Drag::RotateView { .. }) { crate::shortcuts::note_tool_use(app); } + if !matches!(d, Drag::Tool) { + app.session.tool_press_elsewhere(); + } // Panning, zooming or turning the view takes the pointer from the tool's hover. if !tool_holds(d) { app.session.tool_hover_ended(view); diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs index 8978805ac8..1325794e00 100644 --- a/crates/ui-egui/src/dialogs/revolve.rs +++ b/crates/ui-egui/src/dialogs/revolve.rs @@ -262,7 +262,8 @@ fn extrude_controls(ui: &mut egui::Ui, d: &mut Dialog, unit: Unit) { }); } -/// Rotation presets, rotation and perspective for Extrude & Bevel, Inflate and Rotate. +/// Rotation presets, rotation and perspective for Extrude & Bevel, Inflate and Rotate, and the +/// classic 3D effects, which have the track cube below the presets. fn view_controls(ui: &mut egui::Ui, d: &mut Dialog) { heading(ui, tl!("Rotation")); let names = [ @@ -296,6 +297,9 @@ fn view_controls(ui: &mut egui::Ui, d: &mut Dialog) { d.fields.extend([("rotationX".into(), json!(x)), ("rotationY".into(), json!(y)), ("rotationZ".into(), json!(z))]); } }); + if vectorcraft_effects::is_classic_three_d(&d.str("__effect")) { + super::three_d_classic::track_cube(ui, d); + } for (key, name) in [("rotationX", tl!("Rotation X")), ("rotationY", tl!("Rotation Y")), ("rotationZ", tl!("Rotation Z"))] { number(ui, d, key, name, (-180.0, 180.0), "°", 2, None); } diff --git a/crates/ui-egui/src/dialogs/revolve/tests.rs b/crates/ui-egui/src/dialogs/revolve/tests.rs index fd802f83f0..f76a1dfaa1 100644 --- a/crates/ui-egui/src/dialogs/revolve/tests.rs +++ b/crates/ui-egui/src/dialogs/revolve/tests.rs @@ -61,6 +61,11 @@ impl Harness { self.ctx.read_response(Id::unique(id)).unwrap().rect } + /// The open dialog's track cube. + fn cube_id(&self) -> Id { + super::super::three_d_classic::cube_id(&self.app.ui.dialog.as_ref().unwrap().kind) + } + fn click(&mut self, p: Pos2) { self.frame(vec![Event::PointerMoved(p), button(p, true)]); self.frame(vec![button(p, false)]); @@ -460,6 +465,88 @@ fn classic_rotate_shows_its_options_and_applies_as_one_step() { assert_eq!(h.app.session.doc().unwrap().doc, before); } +/// The classic effects' track cube: a drag on its face turns the object live and the presets show +/// Custom, Escape during a drag puts the angles back, the ring turns Z alone, the arrow keys turn +/// it with the keyboard focus, and OK keeps it all as one undo step. The newer effects have no cube. +#[test] +fn the_track_cube_turns_the_classic_effects_live_in_one_undo_step() { + use vectorcraft_effects::{CLASSIC_EXTRUDE, CLASSIC_REVOLVE, CLASSIC_ROTATE, EXTRUDE, ROTATE}; + let square = "M100 100 L200 100 L200 200 L100 200 Z"; + for effect in [EXTRUDE, ROTATE] { + let mut h = Harness::with(square, effect, vec2(1400.0, 1000.0)); + h.app.ui.dialog.as_mut().unwrap().fields.insert("__tab".into(), json!("rotation")); + h.settle(); + assert!(!h.texts.iter().any(|(t, _)| t == "Track cube"), "{effect} has no track cube"); + } + for effect in [CLASSIC_EXTRUDE, CLASSIC_REVOLVE] { + let mut h = Harness::with(square, effect, vec2(1400.0, 1000.0)); + h.app.ui.dialog.as_mut().unwrap().fields.insert("__tab".into(), json!("rotation")); + h.settle(); + h.rect("Track cube"); + } + let mut h = Harness::with(square, CLASSIC_ROTATE, vec2(1400.0, 1000.0)); + let before = h.app.session.doc().unwrap().doc.clone(); + h.settle(); + h.rect("Off-Axis Front"); + let start = ["rotationX", "rotationY", "rotationZ"].map(|k| h.value(k)); + let cube = h.ctx.read_response(h.cube_id()).unwrap().rect; + // A face, dragged right: the object turns, the document previews it, and the preset is Custom. + h.drag(cube.center(), vec2(30.0, 0.0)); + let turned = ["rotationX", "rotationY", "rotationZ"].map(|k| h.value(k)); + assert_ne!(turned, start, "the drag turned the object"); + h.rect("Custom"); + let fx = |h: &Harness| { + let state = h.app.session.doc().unwrap(); + state.doc.node(state.selection.objects[0]).unwrap().appearance.effects[0].params.clone() + }; + assert_eq!(fx(&h)["rotationY"].as_f64(), Some(turned[1]), "the preview follows the cube"); + // Escape during a drag puts the angles back and keeps the dialog open. + let p = cube.center(); + h.frame(vec![Event::PointerMoved(p), button(p, true)]); + h.frame(vec![Event::PointerMoved(p + vec2(0.0, 30.0))]); + h.frame(vec![Event::PointerMoved(p + vec2(0.0, 40.0))]); + assert_ne!(h.value("rotationX"), turned[0]); + h.frame(vec![Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }]); + h.frame(vec![button(p + vec2(0.0, 40.0), false)]); + h.settle(); + assert!(h.app.ui.dialog.is_some(), "Escape ends the drag, not the dialog"); + assert_eq!(["rotationX", "rotationY", "rotationZ"].map(|k| h.value(k)), turned); + // The ring turns in the screen plane: Z alone. + let top = pos2(cube.center().x, cube.center().y - 53.5); + h.drag(top, vec2(12.0, 2.0)); + assert_eq!((h.value("rotationX"), h.value("rotationY")), (turned[0], turned[1])); + assert!(h.value("rotationZ") > turned[2], "clockwise: {} -> {}", turned[2], h.value("rotationZ")); + // With the keyboard focus (the drags gave it), Right turns about the screen's vertical axis. + let z = h.value("rotationZ"); + assert!(h.ctx.memory(|m| m.has_focus(h.cube_id())), "the drag gave the cube the keyboard focus"); + h.frame(vec![Event::Key { key: egui::Key::PageUp, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }]); + h.settle(); + assert!((h.value("rotationZ") - (z - 1.0)).abs() < 0.011, "Page Up turns 1° counterclockwise"); + let y = h.value("rotationY"); + h.frame(vec![Event::Key { key: egui::Key::ArrowRight, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }]); + h.settle(); + assert_ne!(h.value("rotationY"), y, "Right turns the cube"); + let last = h.value("rotationZ"); + dialogs::confirm(&mut h.app).unwrap(); + assert_eq!(fx(&h)["rotationZ"].as_f64(), Some(last)); + h.app.run("edit.undo", json!({})).unwrap(); + assert_eq!(h.app.session.doc().unwrap().doc, before); +} + +/// A mixed rotation (the 3D and Materials panel's selected effects differ) leaves the cube off. +#[test] +fn the_track_cube_is_off_while_a_rotation_is_mixed() { + use vectorcraft_effects::CLASSIC_ROTATE; + let mut h = Harness::with("M100 100 L200 100 L200 200 L100 200 Z", CLASSIC_ROTATE, vec2(1400.0, 1000.0)); + h.app.ui.dialog.as_mut().unwrap().fields.insert("rotationX".into(), Value::Null); + h.settle(); + let cube = h.ctx.read_response(h.cube_id()).unwrap().rect; + h.drag(cube.center(), vec2(30.0, 0.0)); + let d = h.app.ui.dialog.as_ref().unwrap(); + assert_eq!(d.fields.get("rotationX"), Some(&Value::Null)); + assert!(!h.ctx.read_response(h.cube_id()).unwrap().sense.senses_drag()); +} + #[test] fn extrude_bevel_options_enable_with_a_bevel_shape() { let mut h = Harness::with("M100 100 L200 100 L200 200 L100 200 Z", vectorcraft_effects::EXTRUDE, vec2(1400.0, 1000.0)); diff --git a/crates/ui-egui/src/dialogs/revolve_gizmo.rs b/crates/ui-egui/src/dialogs/revolve_gizmo.rs index c99e7ab83e..a7fe804679 100644 --- a/crates/ui-egui/src/dialogs/revolve_gizmo.rs +++ b/crates/ui-egui/src/dialogs/revolve_gizmo.rs @@ -42,8 +42,10 @@ fn drag_id() -> Id { Id::unique("revolve-gizmo-drag") } +/// Is a rotation or light gesture in progress, on the artboard or on the classic 3D effects' track +/// cube? pub(crate) fn dragging(ctx: &egui::Context) -> bool { - ctx.data(|m| m.get_temp::(drag_id())).is_some() + ctx.data(|m| m.get_temp::(drag_id())).is_some() || super::three_d_classic::cube_dragging(ctx) } pub(super) fn clear(ctx: &egui::Context) { diff --git a/crates/ui-egui/src/dialogs/tests_track_cube.rs b/crates/ui-egui/src/dialogs/tests_track_cube.rs new file mode 100644 index 0000000000..9b99efb105 --- /dev/null +++ b/crates/ui-egui/src/dialogs/tests_track_cube.rs @@ -0,0 +1,184 @@ +//! The track cube's rotations, grips and gestures. +use super::*; +use egui::pos2; +use vectorcraft_effects::ROTATION_PRESETS; + +const SAMPLES: [[f64; 3]; 6] = + [[0.0, 0.0, 0.0], [-21.88, -23.4, 9.06], [27.0, -39.0, 53.0], [170.0, 10.0, -95.5], [-120.0, 75.0, 33.0], [45.0, -35.26, 30.0]]; + +fn close(a: [f64; 3], b: [f64; 3]) -> bool { + a.iter().zip(b).all(|(a, b)| tidy(a - b).abs() < 0.011) +} + +fn same_rotation(a: M3, b: M3) -> bool { + a.iter().flatten().zip(b.iter().flatten()).all(|(a, b)| (a - b).abs() < 1e-3) +} + +/// The cube turns as the 3D effects turn the art: each object axis lands where the effects' own +/// view rotation puts it. +#[test] +fn the_cube_rotates_as_the_effects_do() { + for angles in SAMPLES { + let m = rotation(angles); + let view = vectorcraft_three_d::Revolve { rotation_x: angles[0], rotation_y: angles[1], rotation_z: angles[2], ..Default::default() }; + for (axis, p) in view.view_axes().into_iter().enumerate() { + assert!((m[0][axis] - p.x).abs() < 1e-9 && (m[1][axis] - p.y).abs() < 1e-9, "{angles:?} axis {axis}"); + } + } +} + +/// Reading the angles back gives the same angles, presets included, Back's 180° and the gimbal +/// positions Left and Right (Y at ±90°) among them. +#[test] +fn angles_read_back_as_they_were_set() { + for angles in SAMPLES.into_iter().chain(ROTATION_PRESETS.iter().map(|(_, a)| *a)) { + let back = angles_of(rotation(angles), angles); + assert!(close(back, angles), "{angles:?} read back as {back:?}"); + assert!(same_rotation(rotation(back), rotation(angles))); + } + assert_eq!(angles_of(rotation([0.0, 180.0, 0.0]), [0.0, 180.0, 0.0]), [0.0, 180.0, 0.0], "Back stays Back, not -180°"); +} + +#[test] +fn angles_stay_in_the_fields_range_to_a_hundredth() { + assert_eq!(tidy(180.0), 180.0); + assert_eq!(tidy(-180.0), 180.0); + assert_eq!(tidy(190.004), -170.0); + assert_eq!(tidy(-0.001), 0.0); + assert!(tidy(-0.001).is_sign_positive()); +} + +fn drag(grip: Grip, angles: [f64; 3], from: Pos2, to: Pos2, shift: bool) -> [f64; 3] { + let mut g = + CubeDrag { grip, matrix: rotation(angles), origin: from, last: from, lock: None, fields: Default::default(), pass: 0, owner: Id::NULL }; + // In five steps, as a pointer moves. + let mut near = angles; + for k in 1..=5 { + let p = from + (to - from) * (k as f32 / 5.0); + g.matrix = drag_turn(&mut g, p, pos2(0.0, 0.0), shift); + g.last = p; + near = angles_of(g.matrix, near); + } + near +} + +/// The ring turns in the screen plane, which the effects apply last: only Z changes, by the angle +/// swept, clockwise on the screen. +#[test] +fn the_ring_turns_z_only() { + for angles in SAMPLES { + let after = drag(Grip::Ring, angles, pos2(0.0, -53.0), pos2(53.0, 0.0), false); + assert!(close(after, [angles[0], angles[1], angles[2] + 90.0]), "{angles:?} -> {after:?}"); + } +} + +/// An edge turns about its own object axis. The effects turn X first, so an X edge changes X alone. +#[test] +fn an_x_edge_turns_x_only_and_other_edges_keep_their_axis() { + let start = [-21.88, -23.4, 9.06]; + let after = drag(Grip::Edge(0), start, pos2(0.0, 0.0), pos2(0.0, -40.0), false); + assert!((after[0] - start[0]).abs() > 5.0, "X turned: {after:?}"); + assert!((after[1] - start[1]).abs() < 0.02 && (after[2] - start[2]).abs() < 0.02, "Y and Z kept: {after:?}"); + for axis in 0..3 { + let after = drag(Grip::Edge(axis), start, pos2(0.0, 0.0), pos2(30.0, -30.0), false); + let (m0, m1) = (rotation(start), rotation(after)); + let column = |m: M3| [m[0][axis], m[1][axis], m[2][axis]]; + let (a, b) = (column(m0), column(m1)); + assert!(a.iter().zip(b).all(|(a, b)| (a - b).abs() < 1e-3), "axis {axis} stays put: {a:?} {b:?}"); + assert!(!same_rotation(m0, m1), "axis {axis}: the cube turned"); + } +} + +/// A face drag across the screen turns about the screen's vertical axis, the front toward the +/// drag; Shift keeps a slanted drag to that axis. +#[test] +fn a_face_drag_turns_the_front_toward_the_pointer_and_shift_keeps_one_axis() { + let front = [0.0, 0.0, 0.0]; + let right = drag(Grip::Face, front, pos2(0.0, 0.0), pos2(40.0, 0.0), false); + assert!(close(right, [0.0, 20.0, 0.0]), "{right:?}"); + // The front (+Z) turns toward +X. + assert!(rotation(right)[0][2] > 0.3); + let down = drag(Grip::Face, front, pos2(0.0, 0.0), pos2(0.0, 40.0), false); + assert!(close(down, [-20.0, 0.0, 0.0]), "{down:?}"); + assert!(rotation(down)[1][2] > 0.3, "the front turns down"); + let slanted = drag(Grip::Face, front, pos2(0.0, 0.0), pos2(40.0, 12.0), true); + assert!(close(slanted, [0.0, 20.0, 0.0]), "Shift across: {slanted:?}"); + let steep = drag(Grip::Face, front, pos2(0.0, 0.0), pos2(10.0, -40.0), true); + assert!(close(steep, [20.0, 0.0, 0.0]), "Shift up: {steep:?}"); + let free = drag(Grip::Face, front, pos2(0.0, 0.0), pos2(40.0, 12.0), false); + assert!(free[0].abs() > 1.0, "without Shift a slanted drag also tilts: {free:?}"); +} + +/// A gesture ends when the cube stops being drawn during it (its dialog closed, or the Rotation tab +/// was left), so Escape is not held back for a cube that is no longer there. +#[test] +fn a_drag_ends_when_the_cube_is_no_longer_drawn() { + let ctx = egui::Context::default(); + let run = |draw: &mut dyn FnMut(&mut egui::Ui)| ctx.run_ui(Default::default(), draw).textures_delta.clear(); + run(&mut |ui| { + let pass = ui.ctx().cumulative_pass_nr(); + let drag = CubeDrag { + grip: Grip::Face, + matrix: rotation([0.0; 3]), + origin: Pos2::ZERO, + last: Pos2::ZERO, + lock: None, + fields: Default::default(), + pass, + owner: Id::NULL, + }; + ui.data_mut(|m| m.insert_temp(cube_drag_id(), drag)); + assert!(cube_dragging(ui.ctx())); + }); + assert!(cube_dragging(&ctx), "the next pass still sees the gesture"); + for _ in 0..2 { + run(&mut |_| {}); + } + assert!(!cube_dragging(&ctx), "two passes without the cube end the gesture"); +} + +/// With the 3D and Materials panel and a 3D dialog both showing a cube, a gesture on one cube is +/// left alone by the other: Escape there does not put the first cube's settings into it. +#[test] +fn a_cube_leaves_a_gesture_on_the_other_cube_alone() { + let ctx = egui::Context::default(); + let mut d = Dialog::new("effect", json!({ "rotationX": 10.0, "rotationY": 0.0, "rotationZ": 0.0 })); + let escape = egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }; + let input = egui::RawInput { events: vec![escape], ..Default::default() }; + let mut out = ctx.run_ui(input, |ui| { + let pass = ui.ctx().cumulative_pass_nr(); + let other = CubeDrag { + grip: Grip::Face, + matrix: rotation([50.0, 0.0, 0.0]), + origin: Pos2::ZERO, + last: Pos2::ZERO, + lock: None, + fields: json!({ "rotationX": 50.0, "rotationY": 0.0, "rotationZ": 0.0 }).as_object().cloned().unwrap_or_default(), + pass, + owner: cube_id(crate::panels::three_d::ID), + }; + assert_ne!(cube_id(crate::panels::three_d::ID), cube_id(&d.kind), "each cube has its own focus"); + ui.data_mut(|m| m.insert_temp(cube_drag_id(), other)); + track_cube(ui, &mut d); + }); + out.textures_delta.clear(); + assert_eq!(d.f64("rotationX", 0.0), 10.0, "the dialog keeps its own rotation"); + // The button is up in that pass, and the other cube, drawn later, still has the release to handle. + assert!(ctx.data(|m| m.get_temp::(cube_drag_id())).is_some(), "the other cube's gesture is still there"); +} + +/// The centre is on the front face, the ring's band on the ring, and an edge's middle on that edge. +#[test] +fn grips_follow_what_is_under_the_pointer() { + let m = rotation([-21.88, -23.4, 9.06]); + let center = pos2(100.0, 100.0); + assert_eq!(grip_at(m, center, center), Grip::Face); + assert_eq!(grip_at(m, center, center + vec2(0.0, -(RING_IN + RING_OUT) / 2.0)), Grip::Ring); + for (i, j, axis) in edges().filter(|&(i, _, axis)| edge_visible(m, i, axis)) { + let middle = corner(m, center, i) + (corner(m, center, j) - corner(m, center, i)) * 0.5; + assert_eq!(grip_at(m, center, middle), Grip::Edge(axis), "edge {i}-{j}"); + } + // Facing front: four faces are edge-on and hidden, so only the front's edges show. + let m = rotation([0.0, 0.0, 0.0]); + assert_eq!(edges().filter(|&(i, _, axis)| edge_visible(m, i, axis)).count(), 4); +} diff --git a/crates/ui-egui/src/dialogs/three_d_classic.rs b/crates/ui-egui/src/dialogs/three_d_classic.rs index 22c18df97e..ec3c3c766d 100644 --- a/crates/ui-egui/src/dialogs/three_d_classic.rs +++ b/crates/ui-egui/src/dialogs/three_d_classic.rs @@ -2,14 +2,16 @@ //! compact 3D dialog: the extrude and bevel options, or the revolve options, on the Object tab //! (Rotate (Classic) has none), and the surface with its lights, highlight, blend steps, shading //! color and Preserve Spot Colors on the Lighting tab. Position (presets, rotation, perspective) is the Rotation tab every 3D -//! effect shares. +//! effect shares; the classic effects add the track cube to it ([`track_cube`]). +use egui::{Color32, Id, Pos2, Rect, Sense, Stroke, Vec2, vec2}; use serde_json::{Value, json}; use vectorcraft_doc::Unit; use vectorcraft_effects::{CLASSIC_EXTRUDE, CLASSIC_REVOLVE, CLASSIC_ROTATE}; use super::revolve::{c3, choice, heading, label, light_list, light_record, number, reset_dot, selected_light, store_selected, toggle}; use crate::state::Dialog; +use crate::theme::Tokens; /// Depth and cap, then the bevel: its shape, its height and whether it is added around the shape /// or carved into it. @@ -113,3 +115,403 @@ fn shading_custom(ui: &mut egui::Ui, d: &mut Dialog) { } }); } + +/// The settings the track cube turns, as every 3D effect names them. +const ROTATION_KEYS: [&str; 3] = ["rotationX", "rotationY", "rotationZ"]; +/// The track cube's box side, its cube's half edge, and its ring's inner and outer radius (points). +const CUBE_BOX: f32 = 124.0; +const CUBE_HALF: f32 = 25.0; +const RING_IN: f32 = 47.0; +const RING_OUT: f32 = 60.0; +/// How far an edge reaches for the pointer (points). +const EDGE_REACH: f32 = 5.0; +/// Degrees one point of pointer movement turns the cube. +const DEGREES_PER_POINT: f64 = 0.5; + +/// A 3×3 rotation, rows first. +type M3 = [[f64; 3]; 3]; + +/// The rotation that X, Y and Z angles in degrees make, as the 3D effects apply them: X first, then +/// Y, then Z, in view space (x right, y down, z toward the viewer). +fn rotation(angles: [f64; 3]) -> M3 { + let [(sx, cx), (sy, cy), (sz, cz)] = angles.map(|a| a.to_radians().sin_cos()); + [[cz * cy, cz * sy * sx - sz * cx, cz * sy * cx + sz * sx], [sz * cy, sz * sy * sx + cz * cx, sz * sy * cx - cz * sx], [-sy, cy * sx, cy * cx]] +} + +fn multiply(a: M3, b: M3) -> M3 { + std::array::from_fn(|i| std::array::from_fn(|j| (0..3).map(|k| a[i][k] * b[k][j]).sum())) +} + +/// The unit vector along axis `axis` (0 X, 1 Y, 2 Z). +fn unit(axis: usize) -> [f64; 3] { + std::array::from_fn(|i| if i == axis { 1.0 } else { 0.0 }) +} + +/// A turn of `degrees` about the unit vector `axis`. +fn turn(axis: [f64; 3], degrees: f64) -> M3 { + let (s, c) = degrees.to_radians().sin_cos(); + let t = 1.0 - c; + let [x, y, z] = axis; + [ + [t * x * x + c, t * x * y - s * z, t * x * z + s * y], + [t * x * y + s * z, t * y * y + c, t * y * z - s * x], + [t * x * z - s * y, t * y * z + s * x, t * z * z + c], + ] +} + +/// An angle as the rotation fields hold it: above -180° up to 180°, to a hundredth of a degree. +fn tidy(degrees: f64) -> f64 { + let wrapped = 180.0 - (180.0 - degrees).rem_euclid(360.0); + (wrapped * 100.0).round() / 100.0 + 0.0 +} + +/// The X, Y and Z angles of rotation `m`. Of the two sets of angles that make it, the one nearest +/// `near` (so a turn moves the fields as little as it can); with Y at ±90°, where X and Z turn about +/// the same axis, X keeps its value from `near`. +fn angles_of(m: M3, near: [f64; 3]) -> [f64; 3] { + let y = (-m[2][0]).clamp(-1.0, 1.0).asin().to_degrees(); + let candidates = if m[2][1].hypot(m[2][2]) < 1e-9 { + let x = near[0]; + let z = if y > 0.0 { x - m[0][1].atan2(m[1][1]).to_degrees() } else { (-m[0][1]).atan2(m[1][1]).to_degrees() - x }; + [Some([x, y, z]), None] + } else { + let x = m[2][1].atan2(m[2][2]).to_degrees(); + let z = m[1][0].atan2(m[0][0]).to_degrees(); + [Some([x, y, z]), Some([x + 180.0, 180.0 - y, z + 180.0])] + }; + let distance = |a: &[f64; 3]| a.iter().zip(near).map(|(a, b)| tidy(a - b).abs()).sum::(); + candidates.into_iter().flatten().min_by(|a, b| distance(a).total_cmp(&distance(b))).unwrap_or(near).map(tidy) +} + +/// Where corner `i` of the cube (bit 0 for +X, bit 1 for +Y, bit 2 for +Z) is drawn. +fn corner(m: M3, center: Pos2, i: usize) -> Pos2 { + let p: [f64; 3] = std::array::from_fn(|b| if i >> b & 1 == 1 { 1.0 } else { -1.0 }); + let v: [f64; 3] = std::array::from_fn(|r| (0..3).map(|k| m[r][k] * p[k]).sum()); + center + vec2(v[0] as f32, v[1] as f32) * CUBE_HALF +} + +/// The corners of the face square to `axis` on its positive or negative side, in order round it. +fn face_corners(axis: usize, positive: bool) -> [usize; 4] { + let (b, c) = (1 << ((axis + 1) % 3), 1 << ((axis + 2) % 3)); + let side = if positive { 1 << axis } else { 0 }; + [0, b, b | c, c].map(|k| side | k) +} + +/// Does the face square to `axis` on that side face the viewer? +fn face_visible(m: M3, axis: usize, positive: bool) -> bool { + m[2][axis] * if positive { 1.0 } else { -1.0 } > 1e-6 +} + +/// The 12 edges: (from corner, to corner, the object axis it runs along). +fn edges() -> impl Iterator { + (0..3).flat_map(|axis| (0..8).filter(move |i| i >> axis & 1 == 0).map(move |i| (i, i | 1 << axis, axis))) +} + +/// Is the edge from corner `i` along `axis` on a face the viewer sees? +fn edge_visible(m: M3, i: usize, axis: usize) -> bool { + [(axis + 1) % 3, (axis + 2) % 3].into_iter().any(|other| face_visible(m, other, i >> other & 1 == 1)) +} + +/// What a press on the track cube takes hold of. +#[derive(Clone, Copy, Debug, PartialEq)] +enum Grip { + /// A face: a free turn, or with Shift about the screen's horizontal or vertical axis. + Face, + /// An edge: a turn about the object axis the edge runs along. + Edge(usize), + /// The ring round the cube: a turn in the plane of the screen. + Ring, +} + +/// The z of the cross product of two screen vectors: positive when `b` is clockwise from `a`. +fn cross(a: Vec2, b: Vec2) -> f32 { + a.x * b.y - a.y * b.x +} + +fn segment_distance(p: Pos2, a: Pos2, b: Pos2) -> f32 { + let line = b - a; + let t = ((p - a).dot(line) / line.length_sq().max(1e-6)).clamp(0.0, 1.0); + p.distance(a + line * t) +} + +/// What the pointer at `p` takes hold of on a cube drawn at `m` about `center`: the nearest edge +/// within reach, else a face, else the ring, else (in the box's corners) a face's free turn. +fn grip_at(m: M3, center: Pos2, p: Pos2) -> Grip { + let edge = edges() + .filter(|&(i, _, axis)| edge_visible(m, i, axis)) + .map(|(i, j, axis)| (segment_distance(p, corner(m, center, i), corner(m, center, j)), axis)) + .filter(|(distance, _)| *distance <= EDGE_REACH) + .min_by(|a, b| a.0.total_cmp(&b.0)); + if let Some((_, axis)) = edge { + return Grip::Edge(axis); + } + let on_face = (0..3).flat_map(|axis| [(axis, true), (axis, false)]).filter(|&(axis, side)| face_visible(m, axis, side)).any(|(axis, side)| { + let points = face_corners(axis, side).map(|i| corner(m, center, i)); + let sides: [f32; 4] = std::array::from_fn(|k| cross(points[(k + 1) % 4] - points[k], p - points[k])); + sides.iter().all(|s| *s >= 0.0) || sides.iter().all(|s| *s <= 0.0) + }); + let distance = p.distance(center); + if !on_face && (RING_IN - 3.0..=RING_OUT + 3.0).contains(&distance) { Grip::Ring } else { Grip::Face } +} + +/// The turn in degrees, clockwise on the screen, from `from` to `to` about `center`. +fn sweep(from: Pos2, to: Pos2, center: Pos2) -> f64 { + let (a, b) = (from - center, to - center); + if a.length() < 2.0 || b.length() < 2.0 { + return 0.0; + } + f64::from(cross(a, b)).atan2(f64::from(a.dot(b))).to_degrees() +} + +/// A track cube gesture in progress. +#[derive(Clone)] +struct CubeDrag { + grip: Grip, + /// The rotation so far, kept unrounded so a long drag does not drift. + matrix: M3, + origin: Pos2, + last: Pos2, + /// With Shift, the screen axis the drag keeps to (0 X, 1 Y), chosen once it has moved 3 points. + lock: Option, + /// The settings before the gesture, which Escape puts back. + fields: serde_json::Map, + /// The last pass that drew the cube during the gesture. + pass: u64, + /// The cube the gesture started on. The 3D and Materials panel and a 3D dialog can each show + /// a cube at the same time, and only this one follows the gesture. + owner: Id, +} + +impl CubeDrag { + /// Was the cube drawn in this pass or the one before? When it was not (its dialog closed, or + /// the Rotation tab or the panel was left during the drag), the gesture is over. + fn live(&self, pass: u64) -> bool { + self.pass.saturating_add(1) >= pass + } +} + +/// The track cube of the dialog or panel of kind `kind`. The 3D and Materials panel and a 3D +/// dialog can show a cube at the same time, each with its own keyboard focus. +pub(super) fn cube_id(kind: &str) -> Id { + Id::unique(("three-d-track-cube", kind)) +} + +fn cube_drag_id() -> Id { + Id::unique("three-d-track-cube-drag") +} + +/// Is a track cube gesture in progress? +pub(super) fn cube_dragging(ctx: &egui::Context) -> bool { + let pass = ctx.cumulative_pass_nr(); + ctx.data(|m| m.get_temp::(cube_drag_id())).is_some_and(|g| g.live(pass)) +} + +/// The rotation after the pointer moves from `drag.last` to `p` on a cube about `center`. +fn drag_turn(drag: &mut CubeDrag, p: Pos2, center: Pos2, shift: bool) -> M3 { + let m = drag.matrix; + let delta = p - drag.last; + let (mut dx, mut dy) = (f64::from(delta.x), f64::from(delta.y)); + match drag.grip { + Grip::Face => { + if shift { + let total = p - drag.origin; + if drag.lock.is_none() && total.length() >= 3.0 { + drag.lock = Some(usize::from(total.x.abs() >= total.y.abs())); + } + match drag.lock { + // Across the screen turns about its vertical (Y) axis, up and down about X. + Some(1) => dy = 0.0, + Some(_) => dx = 0.0, + None => return m, + } + } + let length = dx.hypot(dy); + if length < 1e-9 { + return m; + } + // The front follows the pointer: right turns it toward +X, down toward +Y. + multiply(turn([-dy / length, dx / length, 0.0], length * DEGREES_PER_POINT), m) + } + Grip::Ring => multiply(turn(unit(2), sweep(drag.last, p, center)), m), + Grip::Edge(axis) => { + let w = [m[0][axis], m[1][axis], m[2][axis]]; + let across = w[0].hypot(w[1]); + // An axis pointing at the viewer turns like the ring, on the side it points to. + let degrees = + if w[2].abs() > 0.9 { sweep(drag.last, p, center) * w[2].signum() } else { (dx * w[1] - dy * w[0]) / across * DEGREES_PER_POINT }; + multiply(m, turn(unit(axis), degrees)) + } + } +} + +/// The track cube on the Rotation tab of Extrude & Bevel (Classic), Revolve (Classic) and Rotate +/// (Classic): a cube drawn at the current X, Y and Z rotation (the object's front blue, its top and +/// bottom light gray, its sides mid gray and its back dark gray) inside a ring. +/// +/// Dragging a face turns the object freely; with Shift the turn keeps to the screen's vertical axis +/// (a drag across) or its horizontal axis (a drag up or down), whichever the drag follows first. +/// Dragging an edge turns it about the object axis the edge runs along (X red, Y green, Z blue; the +/// edge takes its axis's color while hovered or dragged), and dragging in the ring turns it in the +/// plane of the screen. Escape during a drag puts the angles back. With the keyboard focus, the +/// arrow keys turn it about the screen's axes and Page Up and Page Down in the screen plane, 1° a +/// press (15° with Shift). The angles go to `rotationX`, `rotationY` and `rotationZ` only when they +/// change, and the dialog's preview applies them; OK records them as one undo step. The cube is off +/// while a rotation setting is mixed (the 3D and Materials panel's selected effects differ). +pub(super) fn track_cube(ui: &mut egui::Ui, d: &mut Dialog) { + let defaults = vectorcraft_effects::default_params(&d.str("__effect")).unwrap_or(json!({})); + let mixed = ROTATION_KEYS.iter().any(|k| d.fields.get(*k).is_some_and(Value::is_null)); + let now = ROTATION_KEYS.map(|k| d.f64(k, defaults.get(k).and_then(Value::as_f64).unwrap_or(0.0))); + let mut next = None; + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 6.0; + let name = tl!("Track cube"); + label(ui, name); + let (rect, _) = ui.allocate_exact_size(Vec2::splat(CUBE_BOX), Sense::hover()); + let enabled = ui.is_enabled() && !mixed; + let id = cube_id(&d.kind); + let resp = ui.interact(rect, id, if enabled { Sense::click_and_drag() } else { Sense::hover() }); + let center = rect.center(); + let value = format!("X {:.2}°, Y {:.2}°, Z {:.2}°", now[0], now[1], now[2]); + resp.widget_info(|| egui::WidgetInfo { + current_text_value: Some(value.clone()), + ..egui::WidgetInfo::labeled(egui::Role::Slider, enabled, name) + }); + if enabled + && resp.drag_started() + && let Some(origin) = ui.input(|i| i.pointer.press_origin()) + { + // A value being typed ends first; the cube then takes the keyboard focus below. + ui.ctx().memory_mut(|m| m.stop_text_input()); + let matrix = rotation(now); + let pass = ui.ctx().cumulative_pass_nr(); + let drag = CubeDrag { + grip: grip_at(matrix, center, origin), + matrix, + origin, + last: origin, + lock: None, + fields: d.fields.clone(), + pass, + owner: id, + }; + ui.data_mut(|m| m.insert_temp(cube_drag_id(), drag)); + } + if enabled && (resp.drag_started() || resp.clicked()) { + resp.request_focus(); + } + let pass = ui.ctx().cumulative_pass_nr(); + // A gesture on the other cube (the panel's or the dialog's) is left to that cube. + let mut drag = ui.data(|m| m.get_temp::(cube_drag_id())).filter(|g| g.owner == id); + if drag.as_ref().is_some_and(|g| !g.live(pass)) { + ui.data_mut(|m| m.remove::(cube_drag_id())); + drag = None; + } + if let Some(current) = &mut drag { + current.pass = pass; + if ui.input_mut(|i| i.consume_key(i.modifiers, egui::Key::Escape)) { + d.fields = current.fields.clone(); + d.fields.remove(super::form::PREVIEWED); + ui.data_mut(|m| m.remove::(cube_drag_id())); + drag = None; + } else { + if let Some(p) = resp.interact_pointer_pos() { + let shift = ui.input(|i| i.modifiers.shift); + current.matrix = drag_turn(current, p, center, shift); + current.last = p; + next = Some(angles_of(current.matrix, now)); + } + ui.data_mut(|m| m.insert_temp(cube_drag_id(), current.clone())); + } + } + // Only this cube's gesture ends here; the other cube may still have the release to handle. + if drag.is_some() && (resp.drag_stopped() || !ui.input(|i| i.pointer.primary_down())) { + ui.data_mut(|m| m.remove::(cube_drag_id())); + } + if enabled && resp.has_focus() { + use egui::{Key, Modifiers}; + ui.memory_mut(|m| { + m.set_focus_lock_filter(id, egui::EventFilter { horizontal_arrows: true, vertical_arrows: true, ..Default::default() }) + }); + let mut m = rotation(now); + let mut turned = false; + for (key, axis, sign) in [ + (Key::ArrowRight, 1, 1.0), + (Key::ArrowLeft, 1, -1.0), + (Key::ArrowUp, 0, 1.0), + (Key::ArrowDown, 0, -1.0), + (Key::PageDown, 2, 1.0), + (Key::PageUp, 2, -1.0), + ] { + // Shift first: a key without modifiers also matches the key with Shift. + for (modifiers, step) in [(Modifiers::SHIFT, 15.0), (Modifiers::NONE, 1.0)] { + while ui.input_mut(|i| i.consume_key(modifiers, key)) { + m = multiply(turn(unit(axis), sign * step), m); + turned = true; + } + } + } + if turned { + next = Some(angles_of(m, now)); + } + } + let shown = next.unwrap_or(now); + let hovered = drag.as_ref().map(|g| g.grip).or_else(|| resp.hover_pos().filter(|_| enabled).map(|p| grip_at(rotation(shown), center, p))); + if enabled && (resp.hovered() || drag.is_some()) { + ui.ctx().set_cursor_icon(match (hovered, drag.is_some()) { + (Some(Grip::Edge(_)), _) => egui::CursorIcon::ResizeHorizontal, + (_, true) => egui::CursorIcon::Grabbing, + _ => egui::CursorIcon::Grab, + }); + } + paint_cube(ui, rect, rotation(shown), hovered, enabled, resp.has_focus()); + resp.on_hover_text(tl!("Drag a face, an edge or the ring to rotate. Shift turns about one screen axis.")); + }); + if let Some(angles) = next + && angles.iter().zip(now).any(|(a, b)| (a - b).abs() > 1e-9) + { + for (key, angle) in ROTATION_KEYS.into_iter().zip(angles) { + d.fields.insert(key.into(), json!(angle)); + } + } +} + +/// Draws the track cube at rotation `m` in `rect`, with the grip under the pointer or in hand lit. +fn paint_cube(ui: &egui::Ui, rect: Rect, m: M3, active: Option, enabled: bool, focused: bool) { + let t = Tokens::get(ui.ctx()); + let fade = |c: Color32| if enabled { c } else { c.gamma_multiply(0.4) }; + let painter = ui.painter_at(rect); + let center = rect.center(); + painter.rect_filled(rect, 2.0, t.input); + let ring = if active == Some(Grip::Ring) { 0.6 } else { 0.3 }; + painter.circle_stroke(center, (RING_IN + RING_OUT) / 2.0, Stroke::new(RING_OUT - RING_IN, fade(t.axis_z.gamma_multiply(ring)))); + // Front blue; top and bottom light, sides mid and back dark gray. Only faces turned to the + // viewer are drawn, and on a cube those never overlap. + for (axis, side) in (0..3).flat_map(|axis| [(axis, true), (axis, false)]) { + if !face_visible(m, axis, side) { + continue; + } + let fill = match (axis, side) { + (2, true) => t.axis_z, + (2, false) => Color32::from_gray(90), + (1, _) => Color32::from_gray(205), + _ => Color32::from_gray(155), + }; + let points: Vec = face_corners(axis, side).iter().map(|&i| corner(m, center, i)).collect(); + painter.add(egui::Shape::convex_polygon(points, fade(fill), Stroke::NONE)); + } + let colors = [t.axis_x, t.axis_y, t.axis_z]; + for (i, j, axis) in edges() { + if !edge_visible(m, i, axis) { + continue; + } + let lit = active == Some(Grip::Edge(axis)); + let stroke = if lit { Stroke::new(2.5, fade(colors[axis])) } else { Stroke::new(1.0, fade(t.text_dim)) }; + painter.line_segment([corner(m, center, i), corner(m, center, j)], stroke); + } + let border = if focused { t.accent } else { t.input_border }; + painter.rect_stroke(rect, 2.0, Stroke::new(1.0, border), egui::StrokeKind::Inside); +} + +#[cfg(test)] +#[path = "tests_track_cube.rs"] +mod tests; diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 7fe34ac38e..ad15e3023c 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -5193,6 +5193,8 @@ effect Soft Меко Step up or down Стъпка нагоре или надолу Drag values or labels. Double-click a value to type. Плъзнете стойности или етикети. Кликнете двукратно върху стойност за въвеждане. Drag rings to rotate. Shift snaps to 15°. Плъзнете пръстените за завъртане. Shift прилепва към 15°. + Track cube Куб за завъртане + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Плъзнете стена, ръб или пръстена за завъртане. Shift завърта около една ос на екрана. Drag the light, or its rings. Shift snaps to 15°. Плъзнете светлината или нейните пръстени. Shift прилепва към 15°. Keep visible surfaces only when expanding Запазване само на видимите повърхности при разширяване Trim covered geometry on Expand Appearance. Live preview keeps the full surface. Transparent paints and surfaces exceeding visibility limits retain all faces. Изрязване на закритата геометрия при разширяване на оформлението. Живият преглед запазва цялата повърхност. Прозрачните бои и повърхности, надвишаващи границите на видимост, запазват всички лица. diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index d3baf100fd..d4a00452bd 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -1035,6 +1035,8 @@ Step up or down Korak gore ili dolje Drag values or labels. Double-click a value to type. Prevucite vrijednosti ili oznake. Dvostruki klik na vrijednost za upis. Drag rings to rotate. Shift snaps to 15°. Prevucite prstenove za rotaciju. Shift hvata na 15°. + Track cube Kocka za rotaciju + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Prevucite stranu, ivicu ili prsten za rotaciju. Shift rotira oko jedne ose ekrana. Drag the light, or its rings. Shift snaps to 15°. Prevucite svjetlo ili njegove prstenove. Shift hvata na 15°. lighting Light Svjetlo Keep visible surfaces only when expanding Pri proširivanju zadrži samo vidljive površine diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 269f9dacee..7f62efbdd5 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -1347,6 +1347,8 @@ antiAlias Sharp Nítid Drag out from a corner, or click two straight lines, then click to place. Arrossega cap enfora des d’una cantonada, o fes clic en dues línies rectes i després fes clic per col·locar-ho. Drag out from a segment, or click two points, then click to place. Arrossega cap enfora des d’un segment, o fes clic en dos punts i després fes clic per col·locar-ho. Drag rings to rotate. Shift snaps to 15°. Arrossega els anells per girar. La tecla Maj ajusta a 15°. + Track cube Cub de rotació + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Arrossega una cara, una aresta o l'anell per girar. La tecla Maj gira al voltant d'un eix de la pantalla. Drag the art to move it on the paper Arrossega la il·lustració per moure-la sobre el paper Drag the light, or its rings. Shift snaps to 15°. Arrossega el llum o els seus anells. La tecla Maj ajusta a 15°. Drag to float as a toolbar Arrossega per surar com a barra d’eines diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 8690e0f981..a04d74e475 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -1057,6 +1057,8 @@ Step up or down O krok nahoru nebo dolů Drag values or labels. Double-click a value to type. Upravte hodnoty přetažením čísel nebo popisků. Dvojím kliknutím na hodnotu ji zadáte. Drag rings to rotate. Shift snaps to 15°. Otáčejte přetažením prstenců. Shift nastaví kroky po 15°. + Track cube Otočná krychle + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Otáčejte přetažením stěny, hrany nebo prstence. Shift otáčí kolem jedné osy obrazovky. Drag the light, or its rings. Shift snaps to 15°. Přetáhněte světlo nebo jeho prstence. Shift nastaví kroky po 15°. lighting Light Světlo Keep visible surfaces only when expanding Při rozložení ponechat pouze viditelné povrchy diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index c04189ac84..e28336b405 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -1600,6 +1600,8 @@ Reset all Revolve settings to their defaults. Nulstil alle indstillinger for omdrejning til standardværdierne. Drag values or labels. Double-click a value to type. Træk i værdier eller etiketter. Dobbeltklik på en værdi for at indtaste. Drag rings to rotate. Shift snaps to 15°. Træk i ringe for at rotere. Shift fastgør til 15°. + Track cube Rotationsterning + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Træk i en flade, en kant eller ringen for at rotere. Shift roterer om én skærmakse. Drag the light, or its rings. Shift snaps to 15°. Træk i lyset eller dets ringe. Shift fastgør til 15°. lighting Light Lys Keep visible surfaces only when expanding Behold kun synlige flader ved udvidelse diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 80bb39f877..d29fb20c49 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5532,6 +5532,8 @@ theme Appearance Erscheinungsbild # 3D and Materials › Revolve: its options dialog and gizmos. Axis side Achsenseite Drag rings to rotate. Shift snaps to 15°. Ziehen Sie die Ringe, um zu drehen. Mit Shift in 15°-Schritten. + Track cube Rotationswürfel + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Ziehen Sie eine Fläche, eine Kante oder den Ring, um zu drehen. Mit Shift um eine Bildschirmachse. Drag the light, or its rings. Shift snaps to 15°. Ziehen Sie das Licht oder seine Ringe. Mit Shift in 15°-Schritten. lighting Light Licht Drag values or labels. Double-click a value to type. Ziehen Sie Werte oder Beschriftungen. Doppelklicken Sie auf einen Wert, um ihn einzugeben. diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 62d341b53e..1f52c5ff68 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -5434,6 +5434,8 @@ digits Malayalam Μαλαγιάλαμ Step up or down Ένα βήμα πάνω ή κάτω Drag values or labels. Double-click a value to type. Σύρετε τιμές ή ετικέτες. Κάντε διπλό κλικ σε μια τιμή για πληκτρολόγηση. Drag rings to rotate. Shift snaps to 15°. Σύρετε τους δακτυλίους για περιστροφή. Με Shift γίνεται προσκόλληση ανά 15°. + Track cube Κύβος περιστροφής + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Σύρετε μια έδρα, μια ακμή ή τον δακτύλιο για περιστροφή. Με Shift η περιστροφή γίνεται γύρω από έναν άξονα της οθόνης. Drag the light, or its rings. Shift snaps to 15°. Σύρετε την πηγή φωτός ή τους δακτυλίους της. Με Shift γίνεται προσκόλληση ανά 15°. Keep visible surfaces only when expanding Διατήρηση μόνο ορατών επιφανειών κατά την ανάπτυξη Trim covered geometry on Expand Appearance. Live preview keeps the full surface. Transparent paints and surfaces exceeding visibility limits retain all faces. Αποκοπή καλυμμένης γεωμετρίας κατά την Ανάπτυξη εμφάνισης. Η ζωντανή προεπισκόπηση διατηρεί ολόκληρη την επιφάνεια. Διαφανή γεμίσματα και επιφάνειες που υπερβαίνουν τα όρια ορατότητας διατηρούν όλες τις έδρες. diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 55aebf5942..e37d4c236c 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5554,6 +5554,8 @@ axis Both Ambos Step up or down Subir o bajar un paso Drag values or labels. Double-click a value to type. Arrastra los valores o las etiquetas. Haz doble clic en un valor para escribir. Drag rings to rotate. Shift snaps to 15°. Arrastra los anillos para girar. Shift ajusta a pasos de 15°. + Track cube Cubo de rotación + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Arrastra una cara, una arista o el anillo para girar. Shift gira sobre un eje de la pantalla. Drag the light, or its rings. Shift snaps to 15°. Arrastra la luz o sus anillos. Shift ajusta a pasos de 15°. lighting Light Luz Keep visible surfaces only when expanding Conservar solo superficies visibles al expandir diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 19a1876131..42410e4fce 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -1038,6 +1038,8 @@ Step up or down Askel ylös tai alas Drag values or labels. Double-click a value to type. Vedä arvoja tai nimiöitä. Kirjoita arvo kaksoisnapsauttamalla. Drag rings to rotate. Shift snaps to 15°. Kierrä vetämällä renkaita. Vaihto kohdistaa 15°:n välein. + Track cube Kiertokuutio + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Kierrä vetämällä tahkoa, särmää tai rengasta. Vaihto kiertää yhden näytön akselin ympäri. Drag the light, or its rings. Shift snaps to 15°. Vedä valoa tai sen renkaita. Vaihto kohdistaa 15°:n välein. lighting Light Valo Keep visible surfaces only when expanding Säilytä laajennettaessa vain näkyvät pinnat diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 225154d196..6e95291365 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5548,6 +5548,8 @@ effect Soft Doux Step up or down Augmenter ou diminuer d’un cran Drag values or labels. Double-click a value to type. Faites glisser les valeurs ou les libellés. Double-cliquez sur une valeur pour la saisir. Drag rings to rotate. Shift snaps to 15°. Faites glisser les anneaux pour tourner. Maj contraint par pas de 15°. + Track cube Cube de rotation + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Faites glisser une face, une arête ou l'anneau pour tourner. Maj fait tourner autour d'un axe de l'écran. Drag the light, or its rings. Shift snaps to 15°. Faites glisser la lumière ou ses anneaux. Maj contraint par pas de 15°. Keep visible surfaces only when expanding Conserver uniquement les surfaces visibles lors de la décomposition Trim covered geometry on Expand Appearance. Live preview keeps the full surface. Transparent paints and surfaces exceeding visibility limits retain all faces. Découpe la géométrie masquée lors de la décomposition de l’aspect. L’aperçu conserve toute la surface. Les peintures transparentes et les surfaces dépassant les limites de visibilité conservent toutes les faces. diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 421aab5598..b4f69ef178 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -1067,6 +1067,8 @@ Drag art or swatches here, or use + to add the selection's colors and text styles. અહીં આર્ટ અથવા સ્વેચ ખેંચો, અથવા પસંદગીના રંગો અને ટેક્સ્ટ સ્ટાઇલ ઉમેરવા + વાપરો. Drag onto art to apply this appearance આ દેખાવ લાગુ કરવા આર્ટ પર ખેંચો Drag rings to rotate. Shift snaps to 15°. ફેરવવા રિંગ્સ ખેંચો. Shift 15° પર સ્નેપ કરે છે. + Track cube ફેરવવાનો ઘન + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. ફેરવવા ફલક, ધાર અથવા રિંગ ખેંચો. Shift સ્ક્રીનની એક અક્ષની આસપાસ ફેરવે છે. Drag the art to move it on the paper કાગળ પર ખસેડવા આર્ટ ખેંચો Drag the light, or its rings. Shift snaps to 15°. લાઇટ અથવા તેની રિંગ્સ ખેંચો. Shift 15° પર સ્નેપ કરે છે. Drag to float as a toolbar ટૂલબાર તરીકે ફ્લોટ કરવા ખેંચો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index cba4dad432..d7033c5ece 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -1508,6 +1508,8 @@ antiAlias Sharp शार्प Drag out from a corner, or click two straight lines, then click to place. एक कोने से बाहर खींचें, या दो सीधी रेखाओं पर क्लिक करें, फिर जगह पर क्लिक करें। Drag out from a segment, or click two points, then click to place. एक खंड से बाहर खींचें, या दो बिंदुओं पर क्लिक करें, फिर जगह पर क्लिक करें। Drag rings to rotate. Shift snaps to 15°. घुमाने के लिए रिंग ड्रैग करें। Shift से 15° पर स्नैप होता है। + Track cube घुमाने का घन + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. घुमाने के लिए फलक, किनारा या रिंग ड्रैग करें। Shift से स्क्रीन के एक अक्ष के चारों ओर घूमता है। Drag the art to move it on the paper इसे कागज पर स्थानांतरित करने के लिए कला को खींचें Drag the light, or its rings. Shift snaps to 15°. लाइट या उसकी रिंग ड्रैग करें। Shift से 15° पर स्नैप होता है। Drag to float as a toolbar एक टूलबार के रूप में तैरने के लिए खींचें diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index b8f19c6250..bb08f2b3d1 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -1208,6 +1208,8 @@ font-technology Variable Változó Drag art, colors and text styles here to reuse them across documents. Libraries are stored on this machine — no account required. Húzz ide grafikát, színeket és szövegstílusokat, hogy más dokumentumokban is használhasd őket. A könyvtárak ezen a gépen tárolódnak, fiók nem kell hozzájuk. Drag onto art to apply this appearance Grafikára húzva alkalmazza ezt a megjelenést Drag rings to rotate. Shift snaps to 15°. Forgatáshoz húzd a gyűrűket. Shift: illesztés 15°-onként. + Track cube Forgatókocka + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Forgatáshoz húzz egy lapot, egy élt vagy a gyűrűt. Shift: forgatás egy képernyőtengely körül. Drag the art to move it on the paper Húzd a grafikát a papíron való áthelyezéshez Drag the light, or its rings. Shift snaps to 15°. Húzd a fényt vagy a gyűrűit. Shift: illesztés 15°-onként. Drag to float as a toolbar Húzd el, hogy önálló eszköztárként lebegjen diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index a74d9433ee..53cc2196e9 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -976,6 +976,8 @@ Reset all Revolve settings to their defaults. Atur ulang semua pengaturan Revolusi ke defaultnya. Drag values or labels. Double-click a value to type. Seret nilai atau label. Klik dua kali pada nilai untuk mengetik. Drag rings to rotate. Shift snaps to 15°. Seret cincin untuk memutar. Shift mengunci ke kelipatan 15°. + Track cube Kubus putar + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Seret sisi, tepi, atau cincin untuk memutar. Shift memutar pada satu sumbu layar. Drag the light, or its rings. Shift snaps to 15°. Seret cahaya atau cincinnya. Shift mengunci ke kelipatan 15°. lighting Light Cahaya Keep visible surfaces only when expanding Pertahankan hanya permukaan yang terlihat saat memperluas diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index c2667e1163..1fd478d87b 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5595,6 +5595,8 @@ effect Regular Normale Step up or down Aumenta o riduci di un passo Drag values or labels. Double-click a value to type. Trascina i valori o le etichette. Fai doppio clic su un valore per digitarlo. Drag rings to rotate. Shift snaps to 15°. Trascina gli anelli per ruotare. Shift usa incrementi di 15°. + Track cube Cubo di rotazione + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Trascina una faccia, uno spigolo o l'anello per ruotare. Shift ruota attorno a un asse dello schermo. Drag the light, or its rings. Shift snaps to 15°. Trascina la luce o i suoi anelli. Shift usa incrementi di 15°. lighting Light Luce Keep visible surfaces only when expanding Mantieni solo le superfici visibili durante l’espansione diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 07852ef2ca..75927fb376 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5638,6 +5638,8 @@ effect Vertical 垂直 Step up or down 1 段階ずつ増減 Drag values or labels. Double-click a value to type. 数値やラベルをドラッグして調整。数値をダブルクリックすると入力できます。 Drag rings to rotate. Shift snaps to 15°. リングをドラッグして回転。Shiftで15°刻みに調整。 + Track cube 回転キューブ + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. 面、辺、またはリングをドラッグして回転。Shiftで画面の1つの軸を中心に回転。 Drag the light, or its rings. Shift snaps to 15°. ライトやリングをドラッグ。Shiftで15°刻みに調整。 lighting Light ライト Keep visible surfaces only when expanding アピアランス分割時に見える面だけを保持 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 7da30a7c4c..d1ab9631df 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -3027,6 +3027,8 @@ Reset all Revolve settings to their defaults. ბრუნვის ყველა პარამეტრის ნაგულისხმევზე დაბრუნება. Drag values or labels. Double-click a value to type. გადაათრიეთ მნიშვნელობები ან წარწერები. მნიშვნელობის ასაკრეფად ორჯერ დაწკაპეთ. Drag rings to rotate. Shift snaps to 15°. შესაბრუნებლად გადაათრიეთ რგოლები. Shift მიაბამს 15°-ის ჯერად კუთხეებზე. + Track cube შემობრუნების კუბი + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. შესაბრუნებლად გადაათრიეთ წახნაგი, წიბო ან რგოლი. Shift აბრუნებს ეკრანის ერთი ღერძის გარშემო. Drag the light, or its rings. Shift snaps to 15°. გადაათრიეთ სინათლე ან მისი რგოლები. Shift მიაბამს 15°-ის ჯერად კუთხეებზე. lighting Light სინათლე Keep visible surfaces only when expanding გაშლისას მხოლოდ ხილული ზედაპირების შენარჩუნება diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 2b75e8ed93..0040a1341c 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5559,6 +5559,8 @@ effect Vertical 세로 Step up or down 한 단계 올리기 또는 내리기 Drag values or labels. Double-click a value to type. 값이나 레이블을 드래그하세요. 값을 더블클릭하면 입력할 수 있습니다. Drag rings to rotate. Shift snaps to 15°. 링을 드래그해 회전하세요. Shift를 누르면 15°씩 스냅됩니다. + Track cube 회전 큐브 + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. 면, 모서리 또는 링을 드래그해 회전하세요. Shift를 누르면 화면의 한 축을 중심으로 회전합니다. Drag the light, or its rings. Shift snaps to 15°. 조명이나 링을 드래그하세요. Shift를 누르면 15°씩 스냅됩니다. lighting Light 광원 Keep visible surfaces only when expanding 확장 시 보이는 표면만 유지 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 7f886bcc1f..188c1a9ae5 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -1496,6 +1496,8 @@ Reset all Revolve settings to their defaults. Stelt alle draai-instellingen opnieuw in op de standaardwaarden. Drag values or labels. Double-click a value to type. Sleep waarden of labels. Dubbelklik op een waarde om te typen. Drag rings to rotate. Shift snaps to 15°. Sleep de ringen om te roteren. Shift lijnt uit op 15°. + Track cube Rotatiekubus + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Sleep een vlak, een rand of de ring om te roteren. Shift roteert om één schermas. Drag the light, or its rings. Shift snaps to 15°. Sleep het licht of de ringen ervan. Shift lijnt uit op 15°. lighting Light Licht Keep visible surfaces only when expanding Alleen zichtbare oppervlakken behouden bij het uitbreiden diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 08b8b0f52a..83af606c60 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -995,6 +995,8 @@ Step up or down Zwiększ lub zmniejsz o krok Drag values or labels. Double-click a value to type. Przeciągaj wartości lub etykiety. Kliknij dwukrotnie wartość, aby ją wpisać. Drag rings to rotate. Shift snaps to 15°. Przeciągaj pierścienie, aby obracać. Shift przyciąga co 15°. + Track cube Kostka obrotu + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Przeciągnij ścianę, krawędź lub pierścień, aby obracać. Shift obraca wokół jednej osi ekranu. Drag the light, or its rings. Shift snaps to 15°. Przeciągaj światło lub jego pierścienie. Shift przyciąga co 15°. lighting Light Światło Keep visible surfaces only when expanding Przy rozszerzaniu zachowaj tylko widoczne powierzchnie diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 99bbffe3d6..0c155729c7 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -3564,6 +3564,8 @@ imageTrace Outline Contorno Step up or down Aumentar ou diminuir um passo Drag values or labels. Double-click a value to type. Arraste os valores ou rótulos. Clique duas vezes em um valor para digitá-lo. Drag rings to rotate. Shift snaps to 15°. Arraste os anéis para girar. Shift ajusta em incrementos de 15°. + Track cube Cubo de rotação + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Arraste uma face, uma aresta ou o anel para girar. Shift gira em torno de um eixo da tela. Drag the light, or its rings. Shift snaps to 15°. Arraste a luz ou seus anéis. Shift ajusta em incrementos de 15°. lighting Light Luz Keep visible surfaces only when expanding Manter apenas as superfícies visíveis ao expandir diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index f1551b009d..1496ded0d8 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5593,6 +5593,8 @@ axis Both Оба Step up or down Шаг вверх или вниз Drag values or labels. Double-click a value to type. Перетаскивайте значения или подписи. Для ввода дважды щёлкните значение. Drag rings to rotate. Shift snaps to 15°. Перетаскивайте кольца для вращения. Shift задаёт шаг 15°. + Track cube Куб вращения + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Перетащите грань, ребро или кольцо для вращения. Shift вращает вокруг одной оси экрана. Drag the light, or its rings. Shift snaps to 15°. Перетаскивайте источник света или кольца. Shift задаёт шаг 15°. lighting Light Свет Keep visible surfaces only when expanding При разборе сохранять только видимые поверхности diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index e3293f4e55..e529fe863f 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -5458,6 +5458,8 @@ effect Soft Mjuk Step up or down Ett steg upp eller ned Drag values or labels. Double-click a value to type. Dra i värden eller etiketter. Dubbelklicka på ett värde för att skriva. Drag rings to rotate. Shift snaps to 15°. Dra i ringarna för att rotera. Shift fäster i steg om 15°. + Track cube Rotationskub + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Dra i en sida, en kant eller ringen för att rotera. Shift roterar runt en skärmaxel. Drag the light, or its rings. Shift snaps to 15°. Dra i ljuset eller dess ringar. Shift fäster i steg om 15°. Keep visible surfaces only when expanding Behåll endast synliga ytor vid expandering Trim covered geometry on Expand Appearance. Live preview keeps the full surface. Transparent paints and surfaces exceeding visibility limits retain all faces. Trimma dold geometri vid Expandera utseende. Live-förhandsgranskningen behåller hela ytan. Transparenta färger och ytor som överskrider synlighetsgränserna behåller alla sidoytor. diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 7e7b18b184..b3635380ee 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -5330,6 +5330,8 @@ effect Soft Yumuşak Reset all Revolve settings to their defaults. Tüm Revolve ayarlarını varsayılan değerlerine sıfırlayın. Drag values or labels. Double-click a value to type. Değerleri veya etiketleri sürükleyin. Yazmak için bir değeri çift tıklayın. Drag rings to rotate. Shift snaps to 15°. Döndürmek için halkaları sürükleyin. Kaydırma 15°'ye sabitlenir. + Track cube Döndürme küpü + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Döndürmek için bir yüzü, kenarı veya halkayı sürükleyin. Shift tek bir ekran ekseni etrafında döndürür. Drag the light, or its rings. Shift snaps to 15°. Işığı veya halkalarını sürükleyin. Kaydırma 15°'ye sabitlenir. Keep visible surfaces only when expanding Görünür yüzeyleri yalnızca genişletirken koruyun Trim covered geometry on Expand Appearance. Live preview keeps the full surface. Transparent paints and surfaces exceeding visibility limits retain all faces. Görünümü Genişlet'te kapsanan geometriyi kırpın. Canlı önizleme tüm yüzeyi korur. Şeffaf boyalar ve görünürlük sınırlarını aşan yüzeyler tüm yüzleri korur. diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index bcf2f37f49..91fc866e2f 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5575,6 +5575,8 @@ axis Both Обидві Step up or down Крок угору або вниз Drag values or labels. Double-click a value to type. Перетягуйте значення або підписи. Двічі клацніть значення, щоб увести його. Drag rings to rotate. Shift snaps to 15°. Перетягуйте кільця для обертання. Shift задає крок 15°. + Track cube Куб обертання + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Перетягніть грань, ребро або кільце для обертання. Shift обертає навколо однієї осі екрана. Drag the light, or its rings. Shift snaps to 15°. Перетягуйте джерело світла або його кільця. Shift задає крок 15°. Keep visible surfaces only when expanding Під час розгортання зберігати лише видимі поверхні Trim covered geometry on Expand Appearance. Live preview keeps the full surface. Transparent paints and surfaces exceeding visibility limits retain all faces. Обрізає приховану геометрію під час розгортання оформлення. Попередній перегляд зберігає всю поверхню. Прозорі заливки та поверхні, що перевищують обмеження видимості, зберігають усі грані. diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 74612d7ad4..6a606f6812 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -1100,6 +1100,8 @@ font-technology Variable Biến thiên Drag art, colors and text styles here to reuse them across documents. Libraries are stored on this machine — no account required. Kéo tác phẩm, màu và kiểu chữ vào đây để tái sử dụng trong các tài liệu. Thư viện được lưu trên máy này — không cần tài khoản. Drag onto art to apply this appearance Kéo lên tác phẩm để áp dụng diện mạo này Drag rings to rotate. Shift snaps to 15°. Kéo vòng để xoay. Shift khớp ở 15°. + Track cube Khối xoay + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. Kéo một mặt, một cạnh hoặc vòng để xoay. Shift xoay quanh một trục màn hình. Drag the art to move it on the paper Kéo tác phẩm để di chuyển trên trang Drag the light, or its rings. Shift snaps to 15°. Kéo đèn hoặc vòng của nó. Shift khớp ở 15°. Drag to float as a toolbar Kéo để thả nổi thanh công cụ diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 9cce5e9612..21446e7494 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5855,6 +5855,8 @@ effect Vertical 垂直 Step up or down 逐级增减 Drag values or labels. Double-click a value to type. 拖动数值或标签。双击数值即可输入。 Drag rings to rotate. Shift snaps to 15°. 拖动圆环旋转。按住 Shift 以 15° 为步长调整。 + Track cube 旋转立方体 + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. 拖动面、边或圆环进行旋转。按住 Shift 绕一个屏幕轴旋转。 Drag the light, or its rings. Shift snaps to 15°. 拖动光源或圆环。按住 Shift 以 15° 为步长调整。 lighting Light 光源 Keep visible surfaces only when expanding 扩展时仅保留可见表面 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index ff44d850c4..8134a6366f 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -5691,6 +5691,8 @@ effect Soft 柔和 Step up or down 逐級增減 Drag values or labels. Double-click a value to type. 拖曳數值或標籤。按兩下數值即可輸入。 Drag rings to rotate. Shift snaps to 15°. 拖曳圓環旋轉。按住 Shift 以 15° 為間距調整。 + Track cube 旋轉立方體 + Drag a face, an edge or the ring to rotate. Shift turns about one screen axis. 拖曳面、邊或圓環進行旋轉。按住 Shift 繞一個螢幕軸旋轉。 Drag the light, or its rings. Shift snaps to 15°. 拖曳光源或圓環。按住 Shift 以 15° 為間距調整。 lighting Light 光源 Keep visible surfaces only when expanding 展開時僅保留可見表面 diff --git a/docs/effects-parity.md b/docs/effects-parity.md index 290148b89d..f108bb328d 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -181,7 +181,7 @@ VectorCraft choices; an original approximation, never compared with another appl | Revolve | initial: live, editable profile, rotation and light gizmos, default-on Cap with continuous curved rims, smooth vector shading and round seam joins, overlapping faces drawn in the order of their depths where they overlap, SVG/PDF output, Expand Appearance ([revolve.md](revolve.md), #846) | | Extrude & Bevel, Inflate, Rotate | initial: live, round seam joins, depth, twist, taper, solid or hollow caps, five original bevel shapes, Inflate volume, both sides, twist, taper and cap, Rotate of every fill and stroke, groups and layers turned about one shared axis (#4506), contours that cross, touch or overlap merged first ([three-d.md](three-d.md)), Position presets, rotation and light gizmos, SVG/PDF output, Expand Appearance ([three-d.md](three-d.md)) | | Materials panel, lighting, ray-traced render | Window › 3D and Materials panel with the object types (Plane, Extrude, Revolve, Inflate) and the Object, Rotation and Lighting settings of the applied effect, Render Settings › Wireframe, which draws the live effect as the edges of its faces, and Quick Actions › Expand as Wireframes ([three-d.md](three-d.md#3d-and-materials-panel)); one to ten directional lights with per-light Color (opaque RGB, white by default), Intensity, Rotation, Height, Softness and neutral Ambient Light, Revolve and colored Inflate use smooth vector shading; Extrude & Bevel and Rotate retain planar shading; original Standard, Diffuse, Top Left and Right lighting rigs; hard-edged shadows behind or below the object from the first light ([three-d.md](three-d.md#shadows)); the Materials tab's Graphics, document symbols mapped onto Extrude & Bevel's caps and onto a plane, moved with an artboard handle, and wrapped around Revolve's side ([three-d.md](three-d.md#graphics)); no base materials, graphics on Inflate or on Extrude & Bevel's walls and bevels, soft shadows or ray tracing | -| 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, round seam joins, Extrude Depth, Cap, five original bevel shapes with Height and Bevel Extent In or Out, Position presets and rotation gizmo, Perspective, Wireframe, No Shading, Diffuse and Plastic surfaces with one to ten lights, Light Intensity, Ambient Light, Highlight Intensity and Size, Blend Steps, Black, Custom or no Shading Color, Draw Hidden Faces ([create 3D objects](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html)); Revolve (Classic) initial: live, round seam joins, Angle, Cap, Offset from the left or right edge, Position presets and rotation gizmo, Perspective, the same four surfaces, lights, highlight, Blend Steps and Shading Color, groups and layers revolved about one shared axis (same page); Rotate (Classic) initial: live, round seam joins, every fill and stroke turned as one plane, Position presets and rotation gizmo, Perspective, No Shading and Diffuse surfaces with lights, Ambient Light, Blend Steps and Shading Color ([rotate objects in 3D](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/rotate-objects-in-3d.html)); Preserve Spot Colors in all three, unavailable with a Custom Shading Color ([Preserve Spot Color](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)); Map Art: none | +| 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, round seam joins, Extrude Depth, Cap, five original bevel shapes with Height and Bevel Extent In or Out, Position presets and rotation gizmo, Perspective, Wireframe, No Shading, Diffuse and Plastic surfaces with one to ten lights, Light Intensity, Ambient Light, Highlight Intensity and Size, Blend Steps, Black, Custom or no Shading Color, Draw Hidden Faces ([create 3D objects](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html)); Revolve (Classic) initial: live, round seam joins, Angle, Cap, Offset from the left or right edge, Position presets and rotation gizmo, Perspective, the same four surfaces, lights, highlight, Blend Steps and Shading Color, groups and layers revolved about one shared axis (same page); Rotate (Classic) initial: live, round seam joins, every fill and stroke turned as one plane, Position presets and rotation gizmo, Perspective, No Shading and Diffuse surfaces with lights, Ambient Light, Blend Steps and Shading Color ([rotate objects in 3D](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/rotate-objects-in-3d.html)); Preserve Spot Colors in all three, unavailable with a Custom Shading Color ([Preserve Spot Color](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)); all three: the track cube (face, edge, Shift and ring drags, keyboard steps; [three-d.md](three-d.md#track-cube)); Map Art: none | | Turntable (30.0 beta) | none | | Export 3D objects (OBJ, USDA, glTF) | initial: Asset Export's Export 3D Object collects an object with Extrude & Bevel, Revolve, Inflate or Rotate as a 3D asset, and Export writes its solids as a USDA (the default), USDZ, glTF or OBJ mesh with a material in each solid's paint color (`assets.add3D`, `assets.set3DFormat`, `assets.export3D`); no textures, map art or shading ([3D export help](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/export-3d-vector-artwork.html)) | diff --git a/docs/mcp.md b/docs/mcp.md index ac0a768306..b7b4905ef4 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3957,8 +3957,9 @@ already walks Image Trace. Short agent entry points: group that draws with that stroke paint; the stroke's weight is not compared. An edge draws with the paint of its topmost stroke that is shown, with paint, above 0 pt and not fully transparent, and with none when the edge is fully transparent or has no such stroke. Each click of a double-click or triple-click runs as it - arrives and is its own undo step. `match` is the paint the face or edge had before the first of the double-click's - two clicks or the triple-click's three that painted it, or before the double-click when the triple-click's double-click + arrives and is its own undo step when it changes a paint. `match` is the paint the face or edge had before the first of + the double-click's two clicks or the triple-click's three that painted it (including a click whose drag or release crossed it), or + before the double-click when the triple-click's double-click reached it, so the clicks before the last do not change what it matches; a first click that made the Live Paint group counts when the face it filled is the clicked face. Hidden faces and edges are not painted. A face that the Bucket fills has all its fills replaced by one fill with the paint, shown, fully opaque and blending normally, in the @@ -3972,8 +3973,10 @@ already walks Image Trace. Short agent entry points: `livePaint.fill {scope}` and `livePaint.strokeEdge {scope}` take `scope` as `"one"` (the default), `"connected"` or `"samePaint"`; any other value is an error and changes nothing. `match` is a paint in the model JSON that `document.node {id}` writes for an appearance's paints (`{"type": "none"}` for none), taken only with a scope that compares paints, and - defaults to the face's fill or the stroke paint the edge draws with. `livePaint.fill` refuses a `scope` other than `"one"` with - `points`. Both replies add `count`, the number of faces or edges the click reaches, including those that already had the + defaults to the face's fill or the stroke paint the edge draws with. `livePaint.strokeEdge {scope: "connected", through}` + takes `through`, at most 4096 edge ids that the join counts as drawing with `match` whatever they draw with now; the tool + passes the edge the double-click's first click painted when that edge drew with `match` before the click. `through` with another scope, or one that is not an array of ids, is an error. `livePaint.fill` refuses + a `scope` other than `"one"` with `points`. Both replies add `count`, the number of faces or edges the click reaches, including those that already had the paint. With the Live Paint Bucket selected and no drag in progress, Left and Right without Shift, Alt or Cmd/Ctrl (which keep their shortcuts) run `paint.setFill {swatch, ids: []}` (or diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index bf3dbf0a0c..490f78a7fe 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -592,6 +592,7 @@ since 2026-10-01. - 3D lighting widget: the Lighting tab of the 3D and Materials panel shows every light on a sphere at its Rotation and Height; a drag moves a light in one undo step, a press selects it, Move Light to Back and Move Light to Front change its side, and the arrow keys move the focused light ([three-d.md](three-d.md#lighting-widget)). `crates/ui-egui/src/panels/tests_three_d.rs` covers the drag, selection, side and keyboard. - 3D shadows: Revolve, Extrude & Bevel, Inflate and Rotate take a Shadows switch with Position (Behind Object or Below Object), Distance from Object (0–100 %) and Shadow Bounds (10–400 %) on the Lighting tab ([three-d.md](three-d.md#shadows)); the first light casts one hard-edged vector shadow, drawn behind the solids, in exports and kept by Expand Appearance. Evidence: `crates/three-d/src/shadow/tests.rs`, `crates/effects/src/solids/tests_shadow.rs`, `effectcmd::tests::a_3d_shadow_is_one_undo_step_saved_exported_and_expanded`. Softness and the shadows of lights after the first are not built. Scores unchanged. - 3D shadows: with Shadows on, Revolve, Extrude & Bevel, Inflate and Rotate cast the shadow from the faces kept by the build that draws each solid, so drawing an object builds each of its solids once. The art and the shadow are unchanged. Evidence: `crates/three-d/src/shadow/tests.rs` (`a_solid_and_its_shadow_are_built_once` and the tests that compare each solid and its shadow with the two built apart), `solids::tests_shadow::a_shadowed_3d_object_builds_each_solid_once`, `solids::tests_shadow::the_shadow_cast_from_the_solids_drawn_is_the_shadow_of_solids_built_for_it`, `revolve::tests::the_shadow_cast_from_the_surfaces_drawn_is_the_shadow_of_surfaces_swept_for_it`. Scores unchanged. +- 3D shadows: a command that applies or edits Extrude & Bevel, Inflate or Rotate with Shadows on checks the shadow from the faces kept by the builds that check the solids, as drawing casts it, so it builds each solid once instead of building it again for the shadow. A stroke whose solid is left out of the art past its own limits casts no shadow. Evidence: `solids::tests::the_check_builds_each_drawn_solid_once`, `solids::tests_shadow::a_stroke_left_out_of_the_art_casts_no_shadow`, `solids::tests_shadow::the_check_accepts_the_shadowed_objects_that_draw`. Scores unchanged. - 3D shadows: in Revolve, Extrude & Bevel, Inflate and Rotate, a fill, stroke or member whose opacity is NaN or infinite casts no part of the shadow, as one at 0 % does, whether the shadow is cast from the solids drawn or from solids built for it alone; the art beside it still casts. This is VectorCraft's own rule. Evidence: `solids::tests_shadow::art_whose_opacity_is_not_a_finite_number_casts_no_shadow`, `revolve::tests::a_surface_whose_opacity_is_not_a_finite_number_casts_no_shadow`. Scores unchanged. - Window › 3D and Materials panel: `crates/ui-egui/src/panels/three_d.rs` applies a 3D effect by object type (Plane, Extrude, Revolve, Inflate), changes an applied one in place (`effect.setParams` `threeDType`) and edits it with the options dialog's Object, Rotation and Lighting controls, one undo step per change; `crates/engine/src/cmd/effectcmd/three_d_type_tests.rs` and `crates/ui-egui/src/panels/tests_three_d.rs` cover it. No Materials tab. - 3D and Materials › Quick Actions › Expand as Wireframes (#6354): `effect.expandAsWireframes` replaces each selected 3D object with a group of 0.5 pt black stroked paths, the edges of the faces its effect draws, each edge once and joined end to end, curves kept, in one undo step ([three-d.md](three-d.md#3d-and-materials-panel)); `crates/effects/src/solids/wireframe/tests.rs`, `crates/engine/src/cmd/wireframe/tests.rs` and `crates/ui-egui/src/panels/tests_three_d.rs` cover it. Scores and hours unchanged. @@ -1574,7 +1575,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Object › Live Paint › Merge adds the other selected paths and Live Paint groups to the bottom selected Live Paint group ([Live Paint groups](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/live-paint-groups.html)), which keeps its id, the paint of its faces and edges, and its name, lock, visibility, transparency, appearance, opacity mask and graphic style link. Object › Live Paint › Make with a Live Paint group selected, and a Live Paint Bucket click on a selected path beside a selected Live Paint group, add the paths to that group the same way. Make, Merge and the Live Paint Bucket take paths, compound paths and groups of them; with type, an image or another object among the selection they report that it has to be converted to paths first and change nothing, as type and raster images can't go into a Live Paint group directly ([Create Live Paint groups](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/create-live-paint-groups.html)); before, such an object went among the group's hidden sources and vanished from the canvas. Evidence: `tests_build::live_paint_refuses_type_and_images_and_changes_nothing`. With the Live Paint Bucket selected, Alt-click on vector art samples its fill, stroke and stroke weight into the paint defaults ([Paint with the Live Paint Bucket tool](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html)). On a placed image it samples the image pixel as a solid fill with no stroke. Alt+Shift-click samples only the color under the pointer, including an intermediate gradient color or image pixels, into the active fill or stroke ([Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)). Neither click paints or changes the selection or selected art, and the next Bucket click paints with the sampled paint. Evidence: `tests_build::live_paint_bucket_alt_sample_paints_next_face_without_changing_selection`. Double-clicking the Live Paint Bucket opens Live Paint Bucket Options ([Paint with the Live Paint Bucket tool](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html)): Paint Fills (on) and Paint Strokes (off) set whether a click paints faces, edges or both, Highlight turns the outline of the face or edge under the pointer on or off, and Color and Width set it (red and 4 px by default). Faces are outlined at the Width and edges at half of it, as the page says faces are highlighted with a thick line and edges with a thin line. With both on, a click paints the edge within 4 px of the pointer, else the face, and Shift switches to Paint Fills only; with one on, Shift switches to the other. The options last across tool switches and are saved with the preferences (`tool.setOption {tool: "livePaintBucket"}`). Evidence: `builder::tests::{bucket_options_choose_what_a_click_paints, bucket_options_set_the_highlight, bucket_highlights_an_edge_thinner_than_a_face}`, `dialogs::live_paint_bucket::tests::double_clicking_the_tool_opens_its_options_and_ok_sets_them`. - Live Paint Bucket double-click and triple-click, as [the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html) describes them: a double-click on a face fills it and the faces reached across edges that draw no stroke, and on an edge it paints the edges joined to it with the same stroke; a triple-click fills every face of the group with the face's fill, or paints every edge with the edge's stroke (`livePaint.fill` and `livePaint.strokeEdge` `{scope: "connected" | "samePaint", match?}`; `pointer_gesture` and `ui.pointer` take `tripleclick`). Each click paints as it arrives, as its own undo step, and the paint compared is the one the face or edge had before the first of its clicks that painted it; a first click that made the Live Paint group counts when the face it filled is the clicked face. With Space held for the view tools, a click, double-click or triple-click paints nothing and no face or edge is outlined, and with Cmd/Ctrl held a double-click or triple-click paints nothing. Which faces and edges join and which paints match are VectorCraft's own rules. Evidence: `tests_build::{live_paint_bucket_double_click_floods_across_unstroked_edges, live_paint_bucket_double_click_floods_curved_and_narrow_faces, live_paint_bucket_double_click_floods_across_hidden_edges_and_past_gaps, live_paint_bucket_triple_click_fills_every_face_of_the_same_fill, live_paint_bucket_triple_click_after_making_the_group_matches_the_made_fill, live_paint_bucket_double_and_triple_click_paint_joined_and_same_stroke_edges, live_paint_scope_and_match_are_checked}`, `builder::tests::{bucket_double_and_triple_click_widen_what_a_click_paints, bucket_triple_click_after_making_the_group_on_another_face_matches_its_own_face, bucket_triple_click_with_a_click_on_another_face_between_matches_the_first_fill, bucket_highlights_nothing_with_space_held}`, `tests::build::{live_paint_scoped_fill_and_stroke_skip_parts_with_the_paint, live_paint_bucket_cmd_double_and_triple_click_paint_nothing}`, `tests::livepaint::{a_triple_click_fills_every_face_of_the_same_fill, clicks_with_space_held_paint_nothing}` (MCP). + Live Paint Bucket double-click and triple-click, as [the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html) describes them: a double-click on a face fills it and the faces reached across edges that draw no stroke, and on an edge it paints the edges joined to it with the same stroke; a triple-click fills every face of the group that has the face's fill, or paints every edge that draws with the edge's stroke paint, each with the bucket's paint (`livePaint.fill` and `livePaint.strokeEdge` `{scope: "connected" | "samePaint", match?}`; `pointer_gesture` and `ui.pointer` take `tripleclick`). Each click paints as it arrives, as its own undo step when it changes a paint, and the paint compared is the one the face or edge had before the first of its clicks that painted it, including a click whose drag or release crossed it; a first click that made the Live Paint group counts when the face it filled is the clicked face. With Space held for the view tools, a click, double-click or triple-click paints nothing and no face or edge is outlined, and with Cmd/Ctrl held a double-click or triple-click paints nothing. Which faces and edges join and which paints match are VectorCraft's own rules. Evidence: `tests_build::{live_paint_bucket_double_click_floods_across_unstroked_edges, live_paint_bucket_double_click_floods_curved_and_narrow_faces, live_paint_bucket_double_click_floods_across_hidden_edges_and_past_gaps, live_paint_bucket_triple_click_fills_every_face_of_the_same_fill, live_paint_bucket_triple_click_after_a_release_across_an_edge_matches_the_fill_before, live_paint_bucket_triple_click_released_from_another_face_matches_the_fill_before, live_paint_bucket_triple_click_after_making_the_group_across_an_edge_matches_the_made_fill, live_paint_bucket_triple_click_after_making_the_group_under_an_unfilled_path_matches_the_made_fill, live_paint_bucket_triple_click_after_merging_across_an_edge_matches_the_face_fill, live_paint_bucket_triple_click_after_merging_two_groups_matches_the_merged_fill, live_paint_bucket_triple_click_after_a_merge_splits_a_face_matches_the_part_fill, live_paint_bucket_triple_click_after_merging_matches_the_fixed_gradient, live_paint_bucket_triple_click_after_making_the_group_matches_the_made_fill, live_paint_bucket_double_and_triple_click_paint_joined_and_same_stroke_edges, live_paint_bucket_double_click_across_a_junction_paints_the_joined_edges, live_paint_scope_and_match_are_checked}`, `builder::tests::{bucket_double_and_triple_click_widen_what_a_click_paints, bucket_triple_click_after_making_the_group_on_another_face_matches_its_own_face, bucket_triple_click_with_a_click_on_another_face_between_matches_the_first_fill, bucket_triple_click_with_a_view_tool_press_between_matches_the_first_fill, bucket_highlights_nothing_with_space_held}`, `tests::build::{live_paint_scoped_fill_and_stroke_skip_parts_with_the_paint, live_paint_bucket_cmd_double_and_triple_click_paint_nothing}`, `tests::livepaint::{a_triple_click_fills_every_face_of_the_same_fill, clicks_with_space_held_paint_nothing}` (MCP). Live Paint Bucket Options has Cursor Swatch Preview, as the [help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html) lists: with the Bucket selected, the active fill or stroke shows above the pointer between the color swatches before and after it in the Swatches panel, and the Left and Right arrow keys pick the swatch before or after it, as the page describes. The selected art keeps its paint. As VectorCraft's own rules, the option is on at first, the arrows step the stroke when the Stroke proxy is in front, they wrap around at the ends and still step with the preview off, a color that is no swatch shows alone until Right picks the first swatch or Left the last, and the arrows do nothing during a fill drag or with no color swatch. Evidence: `tests::build::{live_paint_bucket_arrow_keys_step_the_active_paint_through_the_swatches, live_paint_bucket_arrow_keys_handle_unmatched_paint_few_swatches_and_drags, live_paint_bucket_arrow_keys_pass_swatches_of_the_same_color_for_fill_and_stroke, swatch_arrow_keys_leave_modified_arrows_to_the_shortcuts}`. Object › Live Paint › Make turns the selected paths into a Live Paint group of faces and edges ([the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/create-live-paint-groups.html)). As VectorCraft's own rule, each face takes every fill row that draws (shown, with paint and an opacity above 0) of its front-most covering source that has one and an opacity above 0, and each edge every stroke row that draws (also with a weight above 0) of its source, in order with their opacity, blending mode, effects and stroke settings, with gradients kept at their fit on the source and with the source's opacity and blending mode. Where a path is cut into several edges, each edge's dashes go on from where it starts along the path with the lengths set (dashes aligned to corners and path ends are not fitted to the cut edges), the arrowheads stay at the path's own ends, and a width profile or brush stays only on an edge that runs the whole path; each edge runs the way its path does, a gradient applied along a stroke starts again on each cut edge, and an inside or outside stroke is drawn centered on an open piece of a closed path. A painted lower row under an unpainted or hidden top row is kept, a hidden top row does not become visible, and a source in front whose fill does not draw does not hide the fill behind it. Rows that do not draw stay with the stored sources, which Release returns unchanged; the source's object effects are not carried. Evidence: `tests::build::{live_paint_make_keeps_lower_drawn_stroke_rows, live_paint_make_fits_dashes_and_arrowheads_to_each_edge, live_paint_make_starts_a_closed_edge_where_its_path_starts, live_paint_make_keeps_the_direction_of_gradient_strokes, live_paint_make_keeps_all_drawn_fill_rows_and_attributes, live_paint_make_uses_frontmost_source_with_drawn_fill}`. Live Paint Make preserves the front-most covering source's fill when compound paths share a curved boundary, and Expand keeps the face fills. Regression evidence: `planar::tests::coincident_curves_keep_their_source_faces` checks source order, winding, fill rules and nearby boundaries; `tests::build::live_paint_make_and_expand_keep_abutting_compound_colors` checks native compound paths, Make, Expand and Undo/Redo. This preserves VectorCraft's source-fill rule without changing arrangement precision. diff --git a/docs/three-d.md b/docs/three-d.md index 2861bee0b7..e30d0ee4b8 100644 --- a/docs/three-d.md +++ b/docs/three-d.md @@ -275,6 +275,29 @@ of an isometric view (each visible axis foreshortened equally). These are our ow each view; the dialog shows a preset's name when the angles match it and **Custom** otherwise. The new effects open at Off-Axis Front. +## Track cube + +The Rotation tab of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic) has a track cube below the +presets, drawn at the current X, Y and Z rotation inside a ring +([set 3D rotation position options](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=249)): + +- Dragging a face turns the object freely. With Shift, a drag across turns it about the screen's vertical axis and a + drag up or down about its horizontal axis, whichever the drag follows first. +- Dragging an edge turns it about the object axis that edge runs along. The edge under the pointer shows its axis's + color: red for X, green for Y, blue for Z. +- Dragging in the ring turns it in the plane of the screen. +- The front face is blue, the top and bottom are light gray, the sides are mid gray and the back is dark gray, as + the help page above describes, along with the red, green and blue axis edges. +- Escape during a drag puts the angles back. With the keyboard focus, the arrow keys turn it about the screen's + horizontal and vertical axes, and Page Up and Page Down turn it in the screen plane, 1° a press or 15° with Shift. + +The drag changes the effect's `rotationX`, `rotationY` and `rotationZ` and previews live; X, Y and Z and the +presets follow it (**Custom** off a preset). OK keeps the change as one undo step. The angles stay between -180° +and 180°: of the two sets of angles that give the same turn, the cube writes the one nearest the current values. +In the 3D and Materials panel, a drag is one undo step when the pointer is released, and the cube is off while the +selected effects hold different rotations. The cube's 0.5° per point of drag, Escape during a drag and its keyboard +steps are VectorCraft's own. + ## Perspective **Perspective** runs 0° to 160°, as the public panel options give it ("how close or far the object appears"), @@ -397,7 +420,9 @@ Our reading: - Softness is not applied to the shadow, and only the first light casts one. - A shadow is cast from at most 327,680 faces, the solids of one object together (our own limit). Past it, a command is refused with "The 3D shadow is too complex; turn Shadows off or simplify the art", and a loaded - file draws the source path. + file draws the source path. A command checks the shadow from the same builds that check the solids, as + drawing casts it, so each solid is built once. A stroke whose solid is left out of the art (past its own + limits) casts no shadow. - Canvas, SVG and PDF exports draw the shadow, the art's bounds take it in, and Expand Appearance keeps it as a path below the faces. Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic) have no shadow. @@ -553,8 +578,8 @@ out, perspective). No Adobe software, assets, presets or bevel shapes were used. face that darkens gets black over it, multiplied and overprinting, so a spot color stays on its own plate. The checkbox is unavailable while Shading Color is Custom ([Preserve Spot Color](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)); how - the faces are shaded with it is VectorCraft's own. The track cube, map art, Turntable and 3D export are separate, - unbuilt items. + the faces are shaded with it is VectorCraft's own. Their Rotation tab has the track cube + ([Track cube](#track-cube)). Map art, Turntable and 3D export are separate, unbuilt items. Release measurements and a repeatable CLI scene are in [3D lighting performance](3d-lighting-performance.md).