mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 14:34:34 +00:00
Merge main into feat/color-profile-ask-prompts
This commit is contained in:
@@ -252,11 +252,12 @@ speaks English, German, Japanese, Korean, Vietnamese, Traditional and Simplified
|
||||
The scores are self-assessed from our code against public documentation;
|
||||
[target-app-parity.md](docs/target-app-parity.md#how-this-was-measured-2026-10-10) explains how far to trust them.
|
||||
|
||||
All 57 approximated Photoshop-style raster filters are available. The Effect Gallery includes filter thumbnails and an in-dialog preview.
|
||||
|
||||
**What's missing:**
|
||||
- reliable exchange of .ai files (layer structure in real files; the editing copy a save writes keeps live effects only on paths, compound paths and groups that qualify (at most a fill and a stroke, a non-zero fill rule when filled, no large canvas) and whose appearance and effects the art-style writer supports (see [docs/file-format-parity.md](docs/file-format-parity.md)), leaves out other objects' effects other than geometry effects, and writes live objects as their art);
|
||||
- an interaction-fidelity pass covering every tool's modifiers and small behaviours;
|
||||
- 3D and Materials beyond the initial live Revolve (Extrude & Bevel, Inflate, Rotate, materials);
|
||||
- filter thumbnails and a preview area inside the Effect Gallery (the gallery itself and all 57 Photoshop-style raster filters, approximated, are in);
|
||||
- CJK composition for vertical type (vertical type itself has initial support, with a Japanese interface);
|
||||
- scripting, and the rest of Variables (image and graph kinds, dataset import);
|
||||
- generative AI features.
|
||||
|
||||
@@ -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::<Result<Vec<_>, 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<usize> = 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<usize> = 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<Option<
|
||||
let casts: Vec<bool> = 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<Option<
|
||||
|
||||
/// [`cast_shadow`] from `built`, the faces the solids drawn kept ([`surfaces_for`] with its shadow
|
||||
/// cast), one entry for each solid in the order they are built: for Rotate each fill and stroke of
|
||||
/// each shape, otherwise each part ([`solid_parts`]). A stroke's solid left out of the art (past its
|
||||
/// own limits) kept no faces. Its Extrude & Bevel solid is built for the shadow alone, as
|
||||
/// [`cast_shadow`] builds it, and when an Inflate solid of visible art kept no faces the whole
|
||||
/// shadow is cast as [`cast_shadow`] casts it, since Inflate's solids share one eye.
|
||||
/// each shape, otherwise each part ([`solid_parts`]). No solid is built here: an entry with no faces
|
||||
/// (a stroke's solid left out of the art, past its own limits) casts nothing, as it draws nothing.
|
||||
/// Only `built` of another length than the solids is cast as [`cast_shadow`] casts it.
|
||||
fn cast_built<'a>(id: &str, p: &Value, shapes: &'a [Profile], built: Vec<Option<SolidFaces>>) -> Result<Option<Cast<'a>>, 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<shadow::Cast> = vec![];
|
||||
let ink = |item: &AppearanceItem, member: f32| {
|
||||
@@ -1555,39 +1587,22 @@ fn cast_built<'a>(id: &str, p: &Value, shapes: &'a [Profile], built: Vec<Option<
|
||||
if !ink.casts() {
|
||||
continue;
|
||||
}
|
||||
let faces = match kept {
|
||||
Some(kept) => 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<shadow::Ink> = 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),
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Option<SolidFaces>> =
|
||||
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.
|
||||
|
||||
@@ -126,7 +126,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"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
|
||||
),
|
||||
|
||||
@@ -567,6 +567,16 @@ pub(super) fn lp_stroke_edge(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
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<NodeId> = 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::<Result<_>>()?
|
||||
}
|
||||
};
|
||||
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<Value> {
|
||||
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(),
|
||||
|
||||
@@ -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<NodeId> = [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::<Vec<_>>()})).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::<Vec<_>>(), [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::<Vec<_>>(), [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::<Vec<_>>(),
|
||||
[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::<Vec<_>>(), [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::<Vec<_>>(), [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::<Vec<_>>(), [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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -4108,20 +4108,21 @@ fn predefined_mojikumi_sets_are_reported_as_left_out() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The text document has no Bunri-Kinshi: a paragraph with it on and an inseparable pair in it is
|
||||
/// reported as left out, and comes back off; with it off, or with no pair, nothing is reported.
|
||||
/// Bunri-Kinshi comes back on or off, with or without an inseparable pair in the paragraph, and
|
||||
/// nothing is reported.
|
||||
#[test]
|
||||
fn bunri_kinshi_is_reported_only_for_paragraphs_with_a_pair() {
|
||||
fn bunri_kinshi_comes_back_with_or_without_a_pair() {
|
||||
use vectorcraft_doc::TextObject;
|
||||
for (text, on, reported) in [
|
||||
("Wait——now", true, true),
|
||||
("Wait——now", false, false),
|
||||
("Wait—now", true, false),
|
||||
("Wait……now", true, true),
|
||||
("Wait‥‥now", true, true),
|
||||
("あ〳〵い", true, true),
|
||||
("あ〴〵い", true, true),
|
||||
("あ〵〳い", true, false),
|
||||
for (text, on) in [
|
||||
("Wait——now", true),
|
||||
("Wait——now", false),
|
||||
("Wait—now", true),
|
||||
("Wait……now", true),
|
||||
("Wait‥‥now", true),
|
||||
("あ〳〵い", true),
|
||||
("あ〴〵い", true),
|
||||
("あ〵〳い", true),
|
||||
("あ〵〳い", false),
|
||||
] {
|
||||
let mut t = TextObject::point(vectorcraft_geom::Point::new(20.0, 40.0), text, style(14.0, Color::BLACK));
|
||||
t.para.bunri_kinshi = on;
|
||||
@@ -4130,7 +4131,7 @@ fn bunri_kinshi_is_reported_only_for_paragraphs_with_a_pair() {
|
||||
let n = text_node(&mut doc, t);
|
||||
doc.insert(Some(layer), usize::MAX, n).unwrap();
|
||||
let out = export_ai_editing(&doc, &opts()).unwrap();
|
||||
assert_eq!(!out.warnings.is_empty(), reported, "{text} {on}: {:?}", out.warnings);
|
||||
assert!(out.warnings.is_empty(), "{text} {on}: {:?}", out.warnings);
|
||||
let mut all = vec![];
|
||||
paths(&read_back(&doc).layers, &mut all);
|
||||
let paras: Vec<bool> = all
|
||||
@@ -4140,10 +4141,87 @@ fn bunri_kinshi_is_reported_only_for_paragraphs_with_a_pair() {
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(paras, [false], "{text} {on}");
|
||||
assert_eq!(paras, [on], "{text} {on}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Each paragraph's Kinsoku set, Kinsoku Shori Type, Burasagari and Bunri-Kinshi come back, and
|
||||
/// nothing is reported: every value of each, mixed across the paragraphs of one object, Burasagari
|
||||
/// and Bunri-Kinshi kept under Kinsoku None. The text document lists the Hard and Soft sets, and
|
||||
/// every paragraph, the normal paragraph style and the document's defaults write all four keys.
|
||||
/// Another attribute the text document leaves out is still reported.
|
||||
#[test]
|
||||
fn kinsoku_settings_come_back_on_each_paragraph() {
|
||||
use vectorcraft_doc::{Burasagari, Kinsoku, KinsokuShoriType, ParaStyle, TextObject};
|
||||
let cases = [
|
||||
(Kinsoku::None, KinsokuShoriType::PushInFirst, Burasagari::Forced, true),
|
||||
(Kinsoku::Soft, KinsokuShoriType::PushOutFirst, Burasagari::Standard, false),
|
||||
(Kinsoku::Hard, KinsokuShoriType::PushOutOnly, Burasagari::None, true),
|
||||
(Kinsoku::Hard, KinsokuShoriType::PushInFirst, Burasagari::Standard, false),
|
||||
(Kinsoku::Soft, KinsokuShoriType::PushOutOnly, Burasagari::Forced, true),
|
||||
];
|
||||
let mut t = TextObject::point(vectorcraft_geom::Point::new(20.0, 40.0), "かな。\n「かな」、\nあ——い\nかな\nかな。", style(14.0, Color::BLACK));
|
||||
t.set_paragraph_styles(
|
||||
cases
|
||||
.iter()
|
||||
.map(|&(kinsoku, kinsoku_type, burasagari, bunri_kinshi)| ParaStyle {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
burasagari,
|
||||
bunri_kinshi,
|
||||
..ParaStyle::default()
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
let mut doc = Document::new(200.0, 200.0);
|
||||
let layer = doc.layers[0].id;
|
||||
let n = text_node(&mut doc, t);
|
||||
doc.insert(Some(layer), usize::MAX, n).unwrap();
|
||||
let out = export_ai_editing(&doc, &opts()).unwrap();
|
||||
assert!(out.warnings.is_empty(), "{:?}", out.warnings);
|
||||
let back = read_back(&doc);
|
||||
same_lines(&type_lines(&back), &type_lines(&doc));
|
||||
let mut all = vec![];
|
||||
paths(&back.layers, &mut all);
|
||||
let read: Vec<_> = all
|
||||
.iter()
|
||||
.filter_map(|n| match &n.kind {
|
||||
NodeKind::Text(t) => {
|
||||
Some(t.paragraph_styles().iter().map(|p| (p.kinsoku, p.kinsoku_type, p.burasagari, p.bunri_kinshi)).collect::<Vec<_>>())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(read, [cases.to_vec()]);
|
||||
let decoded = text_document(&program(&doc));
|
||||
let hard = decoded.find("PhotoshopKinsokuHard").unwrap_or_else(|| panic!("{decoded}"));
|
||||
let soft = decoded.find("PhotoshopKinsokuSoft").unwrap_or_else(|| panic!("{decoded}"));
|
||||
assert!(hard < soft, "{decoded}");
|
||||
// Five paragraphs, then the normal paragraph style and the document's defaults (Hard, Push Out
|
||||
// Only, no Burasagari, Bunri-Kinshi off).
|
||||
for (key, count) in [
|
||||
("/27 /nil", 1),
|
||||
("/27 0", 4),
|
||||
("/27 1", 2),
|
||||
("/25 0", 2),
|
||||
("/25 1", 1),
|
||||
("/25 2", 4),
|
||||
("/24 0", 3),
|
||||
("/24 1", 2),
|
||||
("/24 2", 2),
|
||||
("/23 true", 3),
|
||||
("/23 false", 4),
|
||||
] {
|
||||
assert_eq!(decoded.matches(key).count(), count, "{key}: {decoded}");
|
||||
}
|
||||
let mut lossy = doc.clone();
|
||||
let id = lossy.layers[0].children().unwrap()[0].id;
|
||||
if let Some(NodeKind::Text(t)) = lossy.node_mut(id).map(|n| &mut n.kind) {
|
||||
t.runs[0].style.underline = true;
|
||||
}
|
||||
assert_eq!(export_ai_editing(&lossy, &opts()).unwrap().warnings, [writer::TYPE_ATTRIBUTES]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_is_written_again_as_the_same_bytes() {
|
||||
let doc = typed();
|
||||
|
||||
@@ -22,15 +22,15 @@ use kurbo::{ParamCurveArclen, PathSeg};
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::text::MAX_AKI;
|
||||
use vectorcraft_doc::{
|
||||
AreaOptions, Burasagari, CharStyle, Document, FirstBaseline, Justify, LineCap, LineJoin, Mojikumi, Node, NodeId, NodeKind, ParaDirection,
|
||||
ParaStyle, PathAlign, PathEffect, TextKind, TextObject, VerticalAlign,
|
||||
AreaOptions, Burasagari, CharStyle, Document, FirstBaseline, Justify, Kinsoku, KinsokuShoriType, LineCap, LineJoin, Mojikumi, Node, NodeId,
|
||||
NodeKind, ParaDirection, ParaStyle, PathAlign, PathEffect, TextKind, TextObject, VerticalAlign,
|
||||
};
|
||||
use vectorcraft_geom::{Affine, PathData, Point};
|
||||
|
||||
use crate::ps;
|
||||
|
||||
/// What the text document holds of type, and what it leaves out.
|
||||
pub(in crate::ai_editing) const TYPE_ATTRIBUTES: &str = "attributes of type other than its font, size, leading, tracking, baseline shift, horizontal and vertical scale, solid fill, solid stroke and its weight, cap, join and miter limit, capitals, small capitals at the document's size, Tate-chu-yoko, Standard Vertical Roman Alignment, Insert Aki, paragraph alignment, indents, space before and after, hyphenation on or off and right-to-left direction (for example underline, kerning, OpenType features, swatch links of its colors, character and paragraph styles, tabs, lists, optical margin alignment, area type's inset spacing, vertical alignment and flow, a minimum first baseline with the Ascent first baseline, and type on a path's effect, alignment and spacing and an end bracket at the very end of an open path) are left out of the editing data for other apps";
|
||||
pub(in crate::ai_editing) const TYPE_ATTRIBUTES: &str = "attributes of type other than its font, size, leading, tracking, baseline shift, horizontal and vertical scale, solid fill, solid stroke and its weight, cap, join and miter limit, capitals, small capitals at the document's size, Tate-chu-yoko, Standard Vertical Roman Alignment, Insert Aki, paragraph alignment, indents, space before and after, hyphenation on or off, right-to-left direction, Kinsoku set, Kinsoku Shori Type, Burasagari and Bunri-Kinshi (for example underline, kerning, OpenType features, swatch links of its colors, character and paragraph styles, tabs, lists, optical margin alignment, area type's inset spacing, vertical alignment and flow, a minimum first baseline with the Ascent first baseline, and type on a path's effect, alignment and spacing and an end bracket at the very end of an open path) are left out of the editing data for other apps";
|
||||
|
||||
/// The version of the text document's form (`/98 << /0 n >>`), as the newest files users sent have it.
|
||||
const STREAM_VERSION: u32 = 14;
|
||||
@@ -161,6 +161,10 @@ fn dict(pairs: Vec<(u32, V)>) -> V {
|
||||
V::Dict(pairs)
|
||||
}
|
||||
|
||||
/// The document's Kinsoku sets, in order, each by its name: a paragraph's key 27 is its set's index
|
||||
/// here (0 Hard, 1 Soft), as the reader's `kinsoku_sets` reads them.
|
||||
const KINSOKU_SETS: [&str; 2] = ["PhotoshopKinsokuHard", "PhotoshopKinsokuSoft"];
|
||||
|
||||
/// A resource set: its resources, each `<< /0 resource >>`, and its display list.
|
||||
fn set(resources: Vec<V>, display: bool) -> V {
|
||||
let mut d = vec![(0, V::List(resources.into_iter().map(|r| dict(vec![(0, r)])).collect()))];
|
||||
@@ -401,7 +405,6 @@ pub(in crate::ai_editing) fn loses(t: &TextObject) -> bool {
|
||||
}
|
||||
let hangul =
|
||||
text.chars().any(|c| matches!(c, '\u{1100}'..='\u{11FF}' | '\u{3130}'..='\u{318F}' | '\u{A960}'..='\u{A97F}' | '\u{AC00}'..='\u{D7FF}' | '\u{FFA0}'..='\u{FFDC}'));
|
||||
let pairs = text.chars().zip(text.chars().skip(1)).any(|(a, b)| vectorcraft_text::inseparable(a, b));
|
||||
let held = ParaStyle {
|
||||
justify: p.justify,
|
||||
left_indent: p.left_indent,
|
||||
@@ -411,16 +414,16 @@ pub(in crate::ai_editing) fn loses(t: &TextObject) -> bool {
|
||||
space_after: p.space_after,
|
||||
hyphenate: p.hyphenate,
|
||||
direction: p.direction.filter(|d| *d == ParaDirection::RightToLeft),
|
||||
// The composition of Japanese punctuation new type gets (Line-end Punctuation Half
|
||||
// Width, Standard burasagari) isn't reported: it changes no other script's lines.
|
||||
// The Mojikumi set new type gets (Line-end Punctuation Half Width) isn't reported: it
|
||||
// changes no other script's lines.
|
||||
mojikumi: if p.mojikumi == Mojikumi::LineEndHalf { p.mojikumi } else { ParaStyle::default().mojikumi },
|
||||
burasagari: if p.burasagari == Burasagari::Standard { p.burasagari } else { ParaStyle::default().burasagari },
|
||||
kinsoku: p.kinsoku,
|
||||
kinsoku_type: p.kinsoku_type,
|
||||
burasagari: p.burasagari,
|
||||
bunri_kinshi: p.bunri_kinshi,
|
||||
// The text document has no Korean Line Break Anywhere: it reads back off, which
|
||||
// changes only the lines of a paragraph with Hangul in it.
|
||||
korean_line_break_anywhere: p.korean_line_break_anywhere && !hangul,
|
||||
// Nor Bunri-Kinshi: it reads back off, which changes only the lines of a paragraph
|
||||
// with an inseparable pair in it.
|
||||
bunri_kinshi: p.bunri_kinshi && !pairs,
|
||||
..ParaStyle::default()
|
||||
};
|
||||
*p != held
|
||||
@@ -756,6 +759,32 @@ impl TextDoc {
|
||||
(4, len(p.space_before)),
|
||||
(5, len(p.space_after)),
|
||||
(9, V::Bool(p.hyphenate)),
|
||||
(23, V::Bool(p.bunri_kinshi)),
|
||||
(
|
||||
24,
|
||||
V::Int(match p.burasagari {
|
||||
Burasagari::None => 0,
|
||||
Burasagari::Standard => 1,
|
||||
Burasagari::Forced => 2,
|
||||
}),
|
||||
),
|
||||
(
|
||||
25,
|
||||
V::Int(match p.kinsoku_type {
|
||||
KinsokuShoriType::PushInFirst => 0,
|
||||
KinsokuShoriType::PushOutFirst => 1,
|
||||
KinsokuShoriType::PushOutOnly => 2,
|
||||
}),
|
||||
),
|
||||
// The Kinsoku set: `/nil` for None, else its index in the document's sets ([`KINSOKU_SETS`]).
|
||||
(
|
||||
27,
|
||||
match p.kinsoku {
|
||||
Kinsoku::None => V::Name("nil"),
|
||||
Kinsoku::Hard => V::Int(0),
|
||||
Kinsoku::Soft => V::Int(1),
|
||||
},
|
||||
),
|
||||
];
|
||||
if rtl {
|
||||
d.push((33, V::Int(1)));
|
||||
@@ -1110,7 +1139,7 @@ impl TextDoc {
|
||||
(1, set(fonts, true)),
|
||||
(2, empty()),
|
||||
(3, empty()),
|
||||
(4, empty()),
|
||||
(4, set(KINSOKU_SETS.iter().map(|name| dict(vec![(0, V::Str((*name).into()))])).collect(), false)),
|
||||
(5, set(vec![normal_char], true)),
|
||||
(6, set(vec![normal_para], true)),
|
||||
(8, set(self.frames.iter().map(clone_v).collect(), false)),
|
||||
|
||||
@@ -581,6 +581,10 @@ struct Reader<'a> {
|
||||
blend_budget: usize,
|
||||
/// The group on `%_` lines an envelope's dictionary just took (see [`Reader::drop_envelope_art`]).
|
||||
envelope_art: Option<Node>,
|
||||
/// The envelope dictionaries whose `AIDeformArtKey` block (`X=` … `X+`) is being read, as how
|
||||
/// many frames were open with each one innermost, innermost last. The block's art is art: a
|
||||
/// dictionary in it is read as it is in a container ([`Reader::end_obj`]).
|
||||
envelope_blocks: Vec<usize>,
|
||||
/// Envelopes waiting for their drawn art, innermost last.
|
||||
envelopes: Vec<PendingEnvelope>,
|
||||
/// How many more envelopes and warped text objects this import may draw to check
|
||||
@@ -813,6 +817,7 @@ impl<'a> Reader<'a> {
|
||||
blend_record: None,
|
||||
blend_budget: BLEND_BUDGET,
|
||||
envelope_art: None,
|
||||
envelope_blocks: Vec::new(),
|
||||
envelopes: Vec::new(),
|
||||
envelope_checks: super::envelope::MAX_CHECKED,
|
||||
envelope_spent: super::envelope::Spent::default(),
|
||||
|
||||
@@ -482,6 +482,13 @@ impl<'a> Reader<'a> {
|
||||
return Ok(());
|
||||
}
|
||||
let Some(f) = self.frames.pop() else { return Ok(()) };
|
||||
let depth = self.frames.len();
|
||||
// A block left open ends with its dictionary, and envelopes still waiting in it keep their
|
||||
// drawn art: nothing after the dictionary is theirs.
|
||||
self.envelope_blocks.retain(|d| *d <= depth);
|
||||
while let Some(p) = self.envelopes.pop_if(|p| p.depth > depth) {
|
||||
self.warn(crate::import::ai::envelope::drawn_note(p.typed));
|
||||
}
|
||||
let Frame { kind, children, base, hidden, gs, pending_unread_fill, pending_unread_stroke, after, mesh_ended, state, .. } = f;
|
||||
let Kind::Obj(mut o) = kind else { return Ok(()) };
|
||||
obj::close(&mut o, &mut self.stack, base);
|
||||
@@ -496,7 +503,10 @@ impl<'a> Reader<'a> {
|
||||
}
|
||||
self.after_object = after;
|
||||
self.mesh_ended = mesh_ended;
|
||||
if matches!(self.frames.last(), Some(Frame { kind: Kind::Obj(_), .. })) {
|
||||
// An object's dictionary in an envelope's `AIDeformArtKey` block is about the art before it
|
||||
// there, as it is in a container: an envelope there is one of the outer envelope's contents.
|
||||
let in_block = o.ty == "ArtDictionary" && self.envelope_blocks.last() == Some(&depth);
|
||||
if !in_block && matches!(self.frames.last(), Some(Frame { kind: Kind::Obj(_), .. })) {
|
||||
return self.push(V::Obj(Rc::new(*o)));
|
||||
}
|
||||
match o.ty.as_str() {
|
||||
|
||||
@@ -41,8 +41,19 @@ impl<'a> Reader<'a> {
|
||||
}
|
||||
|
||||
/// `X=` in a `/Mask` dictionary: the opacity mask's art starts, read until its `X+`
|
||||
/// ([`Self::end_mask`]).
|
||||
/// ([`Self::end_mask`]). In an envelope's dictionary, its `AIDeformArtKey` block starts
|
||||
/// ([`Reader::envelope_blocks`]).
|
||||
fn open_mask_object(&mut self, hidden: bool) -> Result<(), String> {
|
||||
if let Some(Frame { kind: Kind::Obj(o), .. }) = self.frames.last()
|
||||
&& o.ty == "ArtDictionary"
|
||||
&& o.get("AIDeformOptionsKey").is_some()
|
||||
{
|
||||
// One entry for each open dictionary, however many `X=` it has.
|
||||
if self.envelope_blocks.last() != Some(&self.frames.len()) {
|
||||
self.envelope_blocks.push(self.frames.len());
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
if !matches!(self.frames.last(), Some(Frame { kind: Kind::Obj(o), .. }) if o.ty == "Mask") {
|
||||
// `X=` also introduces legacy text frame art, read by `text_frames`.
|
||||
return Ok(());
|
||||
@@ -63,6 +74,22 @@ impl<'a> Reader<'a> {
|
||||
self.open(Kind::Mask, hidden)
|
||||
}
|
||||
|
||||
/// `X+`: a dictionary's art block ends. The block of a dictionary whose `X=` opened no frame (an
|
||||
/// envelope's, in an opacity mask's art too) ends with the dictionary still innermost; an opacity
|
||||
/// mask's ends its art ([`Self::end_mask`]).
|
||||
fn end_block(&mut self) -> Result<(), String> {
|
||||
if matches!(self.frames.last(), Some(Frame { kind: Kind::Obj(_), .. })) {
|
||||
if self.envelope_blocks.last() == Some(&self.frames.len()) {
|
||||
self.envelope_blocks.pop();
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
if self.frames.iter().any(|f| matches!(f.kind, Kind::Mask)) {
|
||||
return self.end_mask();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `LB`: a graph started in this layer that hasn't ended doesn't go on past it; the layer ends.
|
||||
fn layer_end(&mut self) -> Result<(), String> {
|
||||
if self.graph.as_ref().is_some_and(|g| g.frames >= self.frames.len()) {
|
||||
@@ -159,8 +186,7 @@ impl<'a> Reader<'a> {
|
||||
}
|
||||
";" => return self.end_obj(),
|
||||
"X=" => return self.open_mask_object(hidden),
|
||||
"X+" if self.frames.iter().any(|f| matches!(f.kind, Kind::Mask)) => return self.end_mask(),
|
||||
"X+" => return Ok(()),
|
||||
"X+" => return self.end_block(),
|
||||
_ => {}
|
||||
}
|
||||
self.state_block_continues(w);
|
||||
|
||||
@@ -8620,6 +8620,224 @@ fn an_envelope_off_the_page_opens_live_when_it_draws_close_to_its_drawn_art() {
|
||||
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
|
||||
}
|
||||
|
||||
/// `art` on `%_` lines, as the editing data writer hides it: a line already on one stays as it is.
|
||||
fn hidden_once(art: &str) -> String {
|
||||
art.lines().map(|l| if l.starts_with("%_") { format!("{l}\n") } else { format!("%_{l}\n") }).collect()
|
||||
}
|
||||
|
||||
/// A mesh envelope of `content` shaped by the grid `shape`, with Edit Contents on (`editing`: the
|
||||
/// contents in the group before the dictionary, the grid in its `AIDeformArtKey` block) or off (the
|
||||
/// other way round, the contents in a plain group), then `drawn` and the plugin's `XP`. An envelope
|
||||
/// record in `content` keeps its own `%_` lines.
|
||||
fn mesh_envelope(shape: &str, editing: bool, content: &str, drawn: &str) -> String {
|
||||
let keys = ENVELOPE_KEYS.replace("0 /Bool (AIDeformEditModeKey)", &format!("{} /Bool (AIDeformEditModeKey)", u8::from(editing)));
|
||||
let (before, block) = if editing { (content.to_string(), shape.to_string()) } else { (shape.to_string(), format!("u\n{content}U\n9 () XW\n")) };
|
||||
format!(
|
||||
"{}%_/ArtDictionary :\n{}%_X=\n{}%_X+\n%_ (AIDeformArtKey) ,\n%_2 /Int (AIDeformStyle) ,\n%_;\n%_\n%_9 () XW\nu\n{drawn}U\n9 () XW\n(Adobe Deform Plugin) 1 0 0 XP\n",
|
||||
hidden_once(&format!("u\n{before}U\n")),
|
||||
commented(&keys),
|
||||
hidden_once(&block),
|
||||
)
|
||||
}
|
||||
|
||||
/// The mesh envelope that maps the box 40 20 160 80 onto itself, and what it draws of
|
||||
/// [`envelope_content`].
|
||||
fn flat_mesh() -> (String, vectorcraft_doc::live::EnvelopeKind, String) {
|
||||
let flat = vectorcraft_doc::live::EnvelopeKind::Mesh {
|
||||
rows: 1,
|
||||
cols: 1,
|
||||
points: vec![Point::new(40.0, 20.0), Point::new(160.0, 20.0), Point::new(40.0, 80.0), Point::new(160.0, 80.0)],
|
||||
handles: vec![],
|
||||
};
|
||||
let drawn = drawn_content(&flat);
|
||||
(straight_mesh(1, 1, (120.0, 60.0)), flat, drawn)
|
||||
}
|
||||
|
||||
/// An envelope inside another envelope's contents opens as a live envelope inside the live outer
|
||||
/// one, with Edit Contents on or off at either level: each keeps its own kind, contents and Edit
|
||||
/// Contents, and neither leaves a copy of its contents drawn beside it.
|
||||
#[test]
|
||||
fn an_envelope_in_an_envelope_s_contents_opens_live_inside_it() {
|
||||
use vectorcraft_doc::live::EnvelopeKind;
|
||||
let (shape, flat, drawn) = flat_mesh();
|
||||
let EnvelopeKind::Mesh { points, .. } = &flat else { panic!("{flat:?}") };
|
||||
for (outer_editing, inner_editing) in [(false, false), (false, true), (true, false), (true, true)] {
|
||||
let why = format!("outer editing {outer_editing}, inner editing {inner_editing}");
|
||||
let inner = mesh_envelope(&shape, inner_editing, &envelope_content(), &drawn);
|
||||
let r = read_ok(&layer(&mesh_envelope(&shape, outer_editing, &hidden_once(&inner), &format!("u\n{drawn}U\n"))));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "{why}: {a:#?}");
|
||||
let flat_points = |kind: &EnvelopeKind| match kind {
|
||||
EnvelopeKind::Mesh { rows: 1, cols: 1, points, .. } => Some(points.clone()),
|
||||
_ => None,
|
||||
};
|
||||
let (content, kind, _, editing, _) = live_envelope(&a[0]);
|
||||
assert_eq!((flat_points(kind), editing), (Some(points.clone()), outer_editing), "{why}: {kind:?}");
|
||||
assert_eq!(content.len(), 1, "{why}: {content:#?}");
|
||||
let (inner, kind, _, editing, _) = live_envelope(&content[0]);
|
||||
assert_eq!((flat_points(kind), editing), (Some(points.clone()), inner_editing), "{why}: {kind:?}");
|
||||
assert_eq!(inner.len(), 1, "{why}: {inner:#?}");
|
||||
assert!(matches!(inner[0].kind, NodeKind::Path { .. }), "{why}: {inner:#?}");
|
||||
assert_eq!(fill(&inner[0]).color(), Some(Color::rgb(1.0, 0.0, 0.0)), "{why}");
|
||||
assert!(r.warnings.is_empty(), "{why}: {:?}", r.warnings);
|
||||
}
|
||||
}
|
||||
|
||||
/// An outer envelope, Edit Contents off, whose `AIDeformArtKey` block holds `block` as it is, with no
|
||||
/// plain group around it, shaped by the grid `shape` and drawn as `drawn`.
|
||||
fn bare_block_envelope(shape: &str, block: &str, drawn: &str) -> String {
|
||||
format!(
|
||||
"{}%_/ArtDictionary :\n{}%_X=\n{}%_X+\n%_ (AIDeformArtKey) ,\n%_2 /Int (AIDeformStyle) ,\n%_;\n%_\n%_9 () XW\nu\n{drawn}U\n9 () XW\n(Adobe Deform Plugin) 1 0 0 XP\n",
|
||||
hidden_once(&format!("u\n{shape}U\n")),
|
||||
commented(ENVELOPE_KEYS),
|
||||
hidden_once(block),
|
||||
)
|
||||
}
|
||||
|
||||
/// An envelope record straight in another envelope's `AIDeformArtKey` block, with no group around
|
||||
/// it, opens live inside the live outer envelope too. Two of them there are both its contents.
|
||||
#[test]
|
||||
fn an_envelope_straight_in_an_envelope_s_block_opens_live_inside_it() {
|
||||
let (shape, _, drawn) = flat_mesh();
|
||||
let inner = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn));
|
||||
let r = read_ok(&layer(&bare_block_envelope(&shape, &inner, &format!("u\n{drawn}U\n"))));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "{a:#?}");
|
||||
let (content, ..) = live_envelope(&a[0]);
|
||||
assert_eq!(content.len(), 1, "{content:#?}");
|
||||
let (inner_content, ..) = live_envelope(&content[0]);
|
||||
assert!(matches!(inner_content[0].kind, NodeKind::Path { .. }), "{inner_content:#?}");
|
||||
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
|
||||
// Two envelopes side by side in the block: both are the outer envelope's contents, each live.
|
||||
let two = format!("{inner}{inner}");
|
||||
let r = read_ok(&layer(&bare_block_envelope(&shape, &two, &format!("u\n{drawn}U\nu\n{drawn}U\n"))));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "{a:#?}");
|
||||
let (content, ..) = live_envelope(&a[0]);
|
||||
assert_eq!(content.len(), 2, "{content:#?}");
|
||||
content.iter().for_each(|c| _ = live_envelope(c));
|
||||
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
|
||||
}
|
||||
|
||||
/// An object's own dictionary straight in an envelope's block, with no group around them, names it
|
||||
/// there.
|
||||
#[test]
|
||||
fn an_object_s_dictionary_straight_in_an_envelope_s_block_names_it() {
|
||||
let (shape, _, drawn) = flat_mesh();
|
||||
let block = format!("{}/ArtDictionary :\n(Box) /String (AIArtName) ,\n;\n", envelope_content());
|
||||
let r = read_ok(&layer(&bare_block_envelope(&shape, &block, &format!("u\n{drawn}U\n"))));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "{a:#?}");
|
||||
let (content, ..) = live_envelope(&a[0]);
|
||||
assert_eq!(content.len(), 1, "{content:#?}");
|
||||
assert_eq!(content[0].name.as_deref(), Some("Box"), "{content:#?}");
|
||||
}
|
||||
|
||||
/// An inner envelope that doesn't open live keeps its drawn art inside the live outer envelope,
|
||||
/// drawn once, without its own source art: one whose drawn art differs from what it draws, and one
|
||||
/// whose record doesn't read (a style number past the list). The outer envelope maps that drawn
|
||||
/// art's box onto its grid. An outer envelope that doesn't match its drawn art keeps that drawn
|
||||
/// art, and nothing of its record is drawn.
|
||||
#[test]
|
||||
fn a_nested_envelope_that_doesn_t_open_live_keeps_its_drawn_art() {
|
||||
let (shape, _, drawn) = flat_mesh();
|
||||
let shifted = format!("{RED}{}f\n", rect_path(42.0, 20.0, 162.0, 80.0));
|
||||
let unread = mesh_envelope(&shape, false, &envelope_content(), &drawn).replace("%_2 /Int (AIDeformStyle)", "%_9 /Int (AIDeformStyle)");
|
||||
for (why, inner) in [("drawn elsewhere", mesh_envelope(&shape, false, &envelope_content(), &shifted)), ("unread", unread)] {
|
||||
for bare in [false, true] {
|
||||
let inner = hidden_once(&inner);
|
||||
let outer_drawn = format!("u\n{drawn}U\n");
|
||||
let body = if bare { bare_block_envelope(&shape, &inner, &outer_drawn) } else { mesh_envelope(&shape, false, &inner, &outer_drawn) };
|
||||
let r = read_ok(&layer(&body));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "{why}, bare {bare}: {a:#?}");
|
||||
assert!(matches!(a[0].kind, NodeKind::Envelope { .. }), "{why}, bare {bare}: {:?}", r.warnings);
|
||||
let (content, ..) = live_envelope(&a[0]);
|
||||
assert_eq!(content.len(), 1, "{why}, bare {bare}: {content:#?}");
|
||||
// The inner envelope's drawn art: its group of one path, or, straight in the block, the
|
||||
// path, as the plain group around a block's only object is the block's own.
|
||||
let drawn_path = if bare {
|
||||
&content[0]
|
||||
} else {
|
||||
let kids = content[0].children().unwrap_or_else(|| panic!("{why}: {content:#?}"));
|
||||
assert_eq!(kids.len(), 1, "{why}: {content:#?}");
|
||||
&kids[0]
|
||||
};
|
||||
assert!(matches!(drawn_path.kind, NodeKind::Path { .. }), "{why}, bare {bare}: {content:#?}");
|
||||
assert_eq!(r.warnings, [super::envelope::DRAWN], "{why}, bare {bare}");
|
||||
}
|
||||
}
|
||||
// The outer envelope's drawn art lies elsewhere: it stays, as one group, the inner record with it.
|
||||
let inner = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn));
|
||||
for bare in [false, true] {
|
||||
let outer_drawn = format!("u\n{shifted}U\n");
|
||||
let body = if bare { bare_block_envelope(&shape, &inner, &outer_drawn) } else { mesh_envelope(&shape, false, &inner, &outer_drawn) };
|
||||
let r = read_ok(&layer(&body));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "bare {bare}: {a:#?}");
|
||||
assert!(matches!(a[0].kind, NodeKind::Group { .. }), "bare {bare}: {a:#?}");
|
||||
assert_eq!(a[0].geometric_bounds(), Some(Rect::new(42.0, 20.0, 162.0, 80.0)), "bare {bare}");
|
||||
assert_eq!(r.warnings, [super::envelope::DRAWN], "bare {bare}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Broken nested records read without taking another record's place: an inner `X=` with no `X+`
|
||||
/// (the inner envelope still opens live), an inner dictionary with no group before it (its drawn art
|
||||
/// stays), and an `XP` repeated after the inner one. The outer envelope, whose own record is whole,
|
||||
/// still opens live around what the inner one left.
|
||||
#[test]
|
||||
fn broken_nested_envelope_records_keep_the_outer_envelope() {
|
||||
let (shape, _, drawn) = flat_mesh();
|
||||
let inner = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn));
|
||||
let no_end = inner.replacen("%_X+\n", "", 1);
|
||||
let no_group = inner.replacen(&hidden_once(&format!("u\n{shape}U\n")), "", 1);
|
||||
let twice = inner.replace("%_(Adobe Deform Plugin) 1 0 0 XP\n", "%_(Adobe Deform Plugin) 1 0 0 XP\n%_(Adobe Deform Plugin) 1 0 0 XP\n");
|
||||
for (why, inner, live) in [("no X+", no_end, true), ("no group", no_group, false), ("XP twice", twice, true)] {
|
||||
for bare in [false, true] {
|
||||
let outer_drawn = format!("u\n{drawn}U\n");
|
||||
let body = if bare { bare_block_envelope(&shape, &inner, &outer_drawn) } else { mesh_envelope(&shape, false, &inner, &outer_drawn) };
|
||||
let r = read_ok(&layer(&body));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "{why}, bare {bare}: {a:#?}");
|
||||
let (content, ..) = live_envelope(&a[0]);
|
||||
assert_eq!(content.len(), 1, "{why}, bare {bare}: {content:#?}");
|
||||
assert_eq!(matches!(content[0].kind, NodeKind::Envelope { .. }), live, "{why}, bare {bare}: {content:#?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An inner envelope whose `XP` is missing stops waiting when the outer envelope's dictionary ends:
|
||||
/// a stray `XP` in a later group leaves that group's art as it is.
|
||||
#[test]
|
||||
fn an_inner_envelope_without_its_xp_does_not_take_later_art() {
|
||||
let (shape, _, drawn) = flat_mesh();
|
||||
let inner = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn)).replace("%_(Adobe Deform Plugin) 1 0 0 XP\n", "");
|
||||
let later = format!("u\nu\n{drawn}U\n(Adobe Deform Plugin) 1 0 0 XP\nU\n");
|
||||
let r = read_ok(&layer(&format!("{}{later}", bare_block_envelope(&shape, &inner, &format!("u\n{drawn}U\n")))));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 2, "{a:#?}");
|
||||
live_envelope(&a[0]);
|
||||
let kids = a[1].children().unwrap_or_else(|| panic!("{a:#?}"));
|
||||
assert!(matches!(kids[0].kind, NodeKind::Group { .. }), "{a:#?}");
|
||||
assert_eq!(r.warnings, [super::envelope::DRAWN], "{:?}", r.warnings);
|
||||
}
|
||||
|
||||
/// An envelope in an opacity mask's art reads: its block's `X+` ends the block, not the mask's art.
|
||||
#[test]
|
||||
fn an_envelope_in_an_opacity_mask_s_art_reads() {
|
||||
let (shape, _, drawn) = flat_mesh();
|
||||
let owner = format!("{RED}{}f\n", rect_path(10.0, 20.0, 170.0, 90.0));
|
||||
let envelope = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn));
|
||||
let mask = format!(
|
||||
"%_/ArtDictionary :\n%_/Mask :\n%_1 /Bool (Linked) ,\n%_X=\n%_u\n{envelope}%_U\n%_X+\n%_(Art) ,\n%_1 /Bool (Clipping) ,\n%_0 /Bool (Inverted) ,\n%_0 /Bool (Disabled) ,\n%_; (AI9_Mask) ,\n%_;\n"
|
||||
);
|
||||
let r = read_ok(&layer(&format!("{owner}{mask}")));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "{a:#?}");
|
||||
let m = a[0].extras().mask.as_ref().unwrap_or_else(|| panic!("{a:#?}"));
|
||||
assert_eq!(m.art.geometric_bounds(), Some(Rect::new(40.0, 20.0, 160.0, 80.0)), "{:#?}", m.art);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_gradient_mesh_reads_as_a_patch() {
|
||||
let corner = |rgb: &str, x: i32, y: i32, next: (i32, i32), prev: (i32, i32)| {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<Vec<Point>>)>,
|
||||
/// 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<Option<LpPress>>,
|
||||
@@ -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<Arc<(LpMade, Vec<Vec<Point>>)>>,
|
||||
}
|
||||
|
||||
/// 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<Arc<Node>>),
|
||||
/// 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<Node>], chunks: &[Vec<Point>]) -> 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<Node>,
|
||||
}
|
||||
|
||||
/// 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<Node>| 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<Node>| {
|
||||
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<NodeId> = 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<Action> {
|
||||
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<Action> {
|
||||
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<Action> {
|
||||
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<Overlay> {
|
||||
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.
|
||||
|
||||
@@ -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<NodeId> {
|
||||
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<NodeId> {
|
||||
use std::collections::{HashMap, HashSet};
|
||||
let es: Vec<&Arc<Node>> = edges(group).into_iter().filter(|e| e.visible && (e.id == start || lp_stroke_paint(e) == *paint)).collect();
|
||||
let es: Vec<&Arc<Node>> =
|
||||
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<Vec<Point>> = es
|
||||
.iter()
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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>(drag_id())).is_some()
|
||||
ctx.data(|m| m.get_temp::<Drag>(drag_id())).is_some() || super::three_d_classic::cube_dragging(ctx)
|
||||
}
|
||||
|
||||
pub(super) fn clear(ctx: &egui::Context) {
|
||||
|
||||
@@ -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::<CubeDrag>(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);
|
||||
}
|
||||
@@ -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::<f64>();
|
||||
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<Item = (usize, usize, usize)> {
|
||||
(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<usize>,
|
||||
/// The settings before the gesture, which Escape puts back.
|
||||
fields: serde_json::Map<String, Value>,
|
||||
/// 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::<CubeDrag>(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::<CubeDrag>(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::<CubeDrag>(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::<CubeDrag>(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::<CubeDrag>(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<Grip>, 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<Pos2> = 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;
|
||||
|
||||
@@ -5210,6 +5210,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. Изрязване на закритата геометрия при разширяване на оформлението. Живият преглед запазва цялата повърхност. Прозрачните бои и повърхности, надвишаващи границите на видимост, запазват всички лица.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1054,6 +1054,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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1366,6 +1366,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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1076,6 +1076,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
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1619,6 +1619,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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5549,6 +5549,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.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5451,6 +5451,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. Αποκοπή καλυμμένης γεωμετρίας κατά την Ανάπτυξη εμφάνισης. Η ζωντανή προεπισκόπηση διατηρεί ολόκληρη την επιφάνεια. Διαφανή γεμίσματα και επιφάνειες που υπερβαίνουν τα όρια ορατότητας διατηρούν όλες τις έδρες.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5571,6 +5571,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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1057,6 +1057,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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5565,6 +5565,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.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1086,6 +1086,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 ટૂલબાર તરીકે ફ્લોટ કરવા ખેંચો
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -1527,6 +1527,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 एक टूलबार के रूप में तैरने के लिए खींचें
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1227,6 +1227,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
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -995,6 +995,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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 953 and column 34.
|
@@ -5612,6 +5612,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
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5655,6 +5655,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 アピアランス分割時に見える面だけを保持
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3046,6 +3046,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 გაშლისას მხოლოდ ხილული ზედაპირების შენარჩუნება
|
||||
@@ -6725,7 +6727,6 @@ font-technology Variable ცვლადი
|
||||
@msg plug-in failed: {0} პლაგინის შეცდომა: {0}
|
||||
@msg plug-in manifest: {0} პლაგინის მანიფესტი: {0}
|
||||
@msg plug-in output: {0} პლაგინის შედეგი: {0}
|
||||
@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why}
|
||||
@msg plug-in parameters: {0} პლაგინის პარამეტრები: {0}
|
||||
@msg plug-in trapped: {0} პლაგინი ავარიულად შეჩერდა: {0}
|
||||
@msg print settings are not an object ბეჭდვის პარამეტრები ობიექტი არ არის
|
||||
@@ -7823,17 +7824,6 @@ imageTrace Outline კონტური
|
||||
@msg `name` must be the name of a script engine `name` უნდა იყოს სკრიპტის ძრავის სახელი
|
||||
@msg the main script engine is new for each run and is never kept, so it cannot be dropped მთავარი სკრიპტის ძრავა ყოველი გაშვებისთვის ახალია და არასოდეს ინახება, ამიტომ მისი მოცილება შეუძლებელია
|
||||
@msg there is no script engine named {name} სკრიპტის ძრავა სახელით {name} არ არსებობს
|
||||
@msg `answers` must be a list of answers `answers` უნდა იყოს პასუხების სია
|
||||
@msg `answers` has more than {MAX_ANSWERS} answers `answers`-ში {MAX_ANSWERS}-ზე მეტი პასუხია
|
||||
@msg `answers` is larger than 1 MiB `answers` 1 MiB-ზე დიდია
|
||||
@msg `answers[{i}]` {e} `answers[{i}]`: {e}
|
||||
@msg must be an object with `kind` and `value` უნდა იყოს ობიექტი `kind`-ითა და `value`-ით
|
||||
@msg must have exactly `kind` and `value` უნდა ჰქონდეს ზუსტად `kind` და `value`
|
||||
@msg is an alert's answer, whose `value` must be "ok" alert-ის პასუხია, ამიტომ მისი `value` უნდა იყოს "ok"
|
||||
@msg is a confirm's answer, whose `value` must be true or false confirm-ის პასუხია, ამიტომ მისი `value` უნდა იყოს true ან false
|
||||
@msg is longer than 16 KiB 16 KiB-ზე გრძელია
|
||||
@msg is a prompt's answer, whose `value` must be a string or null prompt-ის პასუხია, ამიტომ მისი `value` უნდა იყოს სტრიქონი ან null
|
||||
@msg must have `kind` alert, confirm or prompt `kind` უნდა იყოს alert, confirm ან prompt
|
||||
@msg `answers` is only for a run with nobody to ask: in the app, the person answers each dialog `answers` მხოლოდ ისეთი გაშვებისთვისაა, სადაც შესაკითხი არავინაა: აპში თითოეულ დიალოგს ადამიანი პასუხობს
|
||||
@msg Running a script სკრიპტი მუშაობს
|
||||
@msg Copied the script report კოპირებულია სკრიპტის ანგარიში
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5576,6 +5576,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 확장 시 보이는 표면만 유지
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1515,6 +1515,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
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1014,6 +1014,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
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3583,6 +3583,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
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5610,6 +5610,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 При разборе сохранять только видимые поверхности
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5475,6 +5475,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.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5347,6 +5347,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.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5592,6 +5592,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. Обрізає приховану геометрію під час розгортання оформлення. Попередній перегляд зберігає всю поверхню. Прозорі заливки та поверхні, що перевищують обмеження видимості, зберігають усі грані.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1119,6 +1119,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ụ
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 205 and column 5.
|
@@ -5872,6 +5872,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 扩展时仅保留可见表面
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5708,6 +5708,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 展開時僅保留可見表面
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1,6 +1,6 @@
|
||||
# Control protocol
|
||||
|
||||
> **Last updated:** 2026-11-07 · **Change:** text style commands take a feature with a value (`"features": ["salt=2"]`), the font's alternate number, and shape runs that differ only in features as one piece of text; previously: Confining file access refuses a `:` in a name after the drive on Windows, an NTFS alternate data stream such as `x.svg:evil` (#3604); previously: Object → Expand… dimmed while the selection has an appearance Expand Appearance expands (`object.expand.info`'s `appearance`, #3089); previously: brush library panels (`window.brushLibrary`, `window.brushLibrary.other`, `ui.saveBrushLibrary`); previously: Transform Each opens on the values it was last confirmed with; its Copy button confirms with `copy: true` (#1732); previously: panel docking on craft-ui's layout: `ui.docking`, the parameters of `window.panel.float` and `window.panel.dock`; previously: `ui.screenshot`'s 64 MiB inline-PNG cap and its path-plus-data downgrade; symbol library panels (`window.symbolLibrary`, `window.symbolLibrary.other`, `ui.saveSymbolLibrary`); synthetic input budgets (#1709); bounded transport waits (#1726).
|
||||
> **Last updated:** 2026-11-15 · **Change:** completed the `ui.resize` and `ui.focus` entries and removed a duplicate `ui.render` row; previously: text style commands take a feature with a value (`"features": ["salt=2"]`), the font's alternate number, and shape runs that differ only in features as one piece of text; previously: Confining file access refuses a `:` in a name after the drive on Windows, an NTFS alternate data stream such as `x.svg:evil` (#3604); previously: Object → Expand… dimmed while the selection has an appearance Expand Appearance expands (`object.expand.info`'s `appearance`, #3089); previously: brush library panels (`window.brushLibrary`, `window.brushLibrary.other`, `ui.saveBrushLibrary`); previously: Transform Each opens on the values it was last confirmed with; its Copy button confirms with `copy: true` (#1732); previously: panel docking on craft-ui's layout: `ui.docking`, the parameters of `window.panel.float` and `window.panel.dock`; previously: `ui.screenshot`'s 64 MiB inline-PNG cap and its path-plus-data downgrade; symbol library panels (`window.symbolLibrary`, `window.symbolLibrary.other`, `ui.saveSymbolLibrary`); synthetic input budgets (#1709); bounded transport waits (#1726).
|
||||
|
||||
`vectorcraft --control <port>` listens on `127.0.0.1:<port>` (loopback only). The port must be a number
|
||||
from 1 to 65535 (`--control=<port>` works too), given once; otherwise the app prints an error and exits
|
||||
@@ -105,8 +105,8 @@ the two can still win that race.
|
||||
| `ui.dialog.set` / `.confirm` / `.cancel` | `{field, value, action?}` or `{fields: [{field, value}…], action?}` | fill and submit the open dialog. `ui.dialog.set` takes the fields the dialog has (`ui.inspect`) other than its `__` fields, the `__` fields that are controls of the dialog (such as `__section` and `__allArtboards` in Save PDF, `__constrain` in Transform Each and the shape dialogs, and `__search` and `__category` in Preferences; Save PDF's and Print's `__savePresetAs`, the preset name, only while Save Preset… asks for it, since OK then saves a preset), `discard` on a dialog with a discard button, `preview` on one with a live preview, the fields that the dialog reads but adds only when a control changes (such as `searchFolder`, or `copy` in the Transform dialogs), and the fields it passes to the command it runs: every parameter of the `command` dialog's command (`ui.paramDialog`), and the `textureImage` that Load Texture… sets in the Glass, Texturizer and Rough Pastels effects; any other field is an error that lists the dialog's fields, and the dialog stays as it was. Any other `__` field, held or not, holds what the dialog's OK acts on (such as the `__command` and `__params` of a `confirm` or `command` dialog) or the dialog's own state: setting it is the error "the `<kind>` dialog cannot set protected field `<field>`", and the dialog stays as it was. `fields` sets the list (at most 256 items) in order (a missing `value` is `null`) and checks every item first: when one is refused, the call is an error and no field changes. `action: "confirm"` or `"cancel"` on `ui.dialog.set` then confirms or cancels the same dialog in the same request, as `ui.dialog.confirm` and `ui.dialog.cancel` do, and the reply is `{dialog, result}`: the dialog after the fields were set and the reply to confirm (`null` for cancel); any other `action` is an error and no field changes |
|
||||
| `ui.screenshot` | `{path?, data?}` | capture the window (PNG), written to `path`; `data: true` sends it back as `pngBase64` too. The inline PNG is capped at 64 MiB: with a `path` the file is still written and `pngBase64` is omitted when the image is larger, while a path-less `data: true` request fails if either the raw RGBA image or the encoded PNG exceeds the cap. Needs a presented frame: with the screen locked or the window minimized/covered it fails after ~8 s with an explanatory error |
|
||||
| `ui.render` | `{path?, scale?, artboard?, data?, traceViews?}` | render an artboard headlessly (PNG with the pixels of `app.export {format: "png", background: "white"}` at the same scale; `artboard`: its 0-based index, default the first; `traceViews: true`: Image Trace objects draw in their View, as on the canvas, instead of their tracing result): written to `path`, else (or with `data: true` as well) sent back as `pngBase64` |
|
||||
| `ui.render` | `{path?, scale?, artboard?, data?}` | render an artboard headlessly (PNG with the pixels of `app.export {format: "png", background: "white"}` at the same scale; `artboard`: its 0-based index, default the first): written to `path`, else (or with `data: true` as well) sent back as `pngBase64` |
|
||||
| `ui.resize` / `ui.focus` | | |
|
||||
| `ui.resize` | `{width?, height?}` | request the window's inner size; omitted or null `width` and `height` default to 1440 and 900. Returns `null` |
|
||||
| `ui.focus` | `{}` | request keyboard focus for the window. Returns `null` |
|
||||
| `app.open` / `app.save` / `app.export` / `app.quit` | `{path, importer?, params?}` / `{path?}` / `{path?, format?, artboard?, range?, scale?, …}` | `app.open` reads every format `document.open` reads (see `document.formats`) and returns its result (`{index, title, format, warnings, …}`; `warnings` say what didn't come in as it was, such as an EPS shown as its preview image and why its PostScript couldn't be read), or null when a dialog asks first or a library loads. The status bar (`ui.inspect` → `ui.status`), after a line about the document's linked files when there is one (Missing linked files below), counts the `warnings` and names the first that says reading the file left something out (the notes that make Save ask before writing over it), else the first; with several, hovering it lists them in that order, as many as fit in the window (at most 30), then how many more. After `app.save`, and `app.export` with a `path`, the status bar counts the reply's `warnings` and names the first, and with several, hovering it lists them in the reply's order (a save's notes start with what the format loses). With `importer` (an importer plug-in's format id, `plugin.<id>`) it runs `file.openWith`: the file opens with that importer, also when a built-in format reads its extension, with the importer's parameters `params` (their defaults when omitted; no dialog asks for them). Without `importer`, `params` go to the importer that opens the file, and a built-in format does not read them. `app.export` encodes through the engine's `document.export` (same options; the document keeps its path) and writes `path` through the host; without `path` it returns `{dataBase64, format, bytes}`, as headless mode does. It refuses a key that no format takes, and an unknown key inside a PDF or EPS option object, before it writes anything (`docs/mcp.md`, Parameter keys). It accepts a key that only another format takes and does not use it: the reply's `warnings` and the status bar name the key ("`quality` was not used: PDF files don't read it"). `app.save` refuses a key that no save format takes, beside the path or in `options`, the same way. `app.quit`, `file.close` and `file.closeAll` first open a `saveChanges` dialog for each modified document (they return `{"pending": "saveChanges"}`): `ui.dialog.confirm` saves, `ui.dialog.set {field: "discard", value: true}` then confirm discards, `ui.dialog.cancel` cancels the whole close or quit |
|
||||
| `app.export` with `useArtboards` | `{path, useArtboards: true, range? \| artboards?, …}` | Export As: PNG, JPEG and WebP write one file per chosen artboard (default all; SVG does so for a `range`), `<path stem>-<artboard>.<ext>`, and return `{path, files: [path…]}`; a PDF keeps them as pages of `path`. `useArtboards: false` covers the bounds of the visible art. The menu's Export As… is `file.exportAs`: the `exportAs` dialog (`format`, `useArtboards`, `all`, `range`), then a save dialog and the format's options: `pngOptions` / `jpgOptions` / `webpOptions`, `svgOptions`, or `savePdf` for a PDF |
|
||||
| `ui.dialog.*` on `gradientStop` | `{field: "color" \| "opacity" \| "location", value}` | double-clicking a stop on the Gradient tool's annotator opens its popover (fields `index`, `x`, `y`, `tab`); set `color` (hex), `opacity` or `location` (percentages) and `ui.dialog.confirm` to apply them to the selected stop. `gradient.selectStop {index}` picks the stop the annotator, the panels and Delete/←/→ (`ui.key`) act on |
|
||||
@@ -1137,6 +1137,7 @@ hidden tab (whose frames the browser pauses) answers when it is shown again.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-15 | minor | Completed the `ui.resize` defaults and `ui.focus` contract; kept one `ui.render` entry, including `traceViews`. Documentation only. |
|
||||
| 2026-11-07 | minor | Documented OpenType feature values in text commands (`"salt=2"`, the font's alternate number) and that runs differing only in features shape as one piece of text. |
|
||||
| 2026-10-31 | minor | Confining file access: on Windows a `:` in a name after the drive (an NTFS alternate data stream) is refused with the device names (#3604). |
|
||||
| 2026-10-25 | minor | Panel docking on craft-ui's layout: `ui.docking`, the floating and dock parameters, native floating windows. |
|
||||
|
||||
@@ -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)) |
|
||||
|
||||
|
||||
+8
-5
@@ -3973,8 +3973,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
|
||||
@@ -3988,8 +3989,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
|
||||
@@ -9460,7 +9463,7 @@ a pair. The setting works only with a Kinsoku Set: with Kinsoku Set None the par
|
||||
and the menu item is unavailable. Off by default, for new type and for paragraphs saved before the option. It is saved
|
||||
with the paragraph (`bunri_kinshi` in `para`) only when on, paragraph styles carry it (Paragraph Style Options › East
|
||||
Asian Composition Settings), and Reset Panel turns it off. A value that is not true or false is refused. One undo
|
||||
step. `.ai` editing data does not hold it, and a save reports a paragraph with it on and a pair in it as left out. The help page:
|
||||
step. An `.ai` save writes it with each paragraph, under Kinsoku Set None too, and it reopens as set. The help page:
|
||||
https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html
|
||||
|
||||
```json
|
||||
|
||||
@@ -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.
|
||||
@@ -1461,7 +1462,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Type on a path with right-to-left text that does not fit shows the longest start of its text whose glyphs fit, also where tracking gives a letter a negative advance and a shorter start does not fit; the rest overflows or flows to the next threaded object (VectorCraft's own rule). Without hanging punctuation, and on a straight path or with no spacing, every start is measured without arranging it on the path again. With hanging punctuation, or spacing on a curve, when a letter has a negative advance, at most 32 of the starts that could fit are arranged one by one from the longest; when none of them fits, a binary search over the rest shows a start that fits, which is not always the longest (`overflowing_rtl_type_on_a_path_shows_the_longest_start_that_fits`, `the_longest_rtl_start_on_a_path_is_found_without_arranging_each_start`, `the_longest_rtl_start_on_a_path_is_the_one_each_start_gives` and `rtl_type_on_a_curve_whose_letters_take_the_line_back_is_arranged_a_bounded_number_of_times` in `crates/text/src/tests/bidi.rs`). Right-aligned and centered type on a curve with Spacing is placed by what its glyphs take where the line ends up, so text that fits is not cut off at the end bracket (`on_path_aligned_spaced_text_that_fits_shows_whole` in `crates/text/src/tests.rs`).
|
||||
The Paragraph panel menu's Kinsoku Shori Type (`text.setFormat {kinsokuType}`, with the East Asian options) picks Push In First, Push Out First or Push Out Only for each paragraph: a character the Kinsoku Set keeps off a line's start or end is set on the line, with the line's gaps next to CJK characters closed by at most a tenth of an em each to fit, or moved to the next line with the character before it. Push Out First pushes in only when pushing out would leave the line more than an em short. Push Out Only is the default, the setting is saved only when it is not, and paragraph styles carry it.
|
||||
The Paragraph panel menu's Bunri-Kinshi (`text.setFormat {bunriKinshi}`, with the East Asian options, and the East Asian Composition Settings section of Paragraph Style Options) keeps inseparable pairs on one line in each paragraph that has it: two em dashes, two ellipses, two two-dot leaders and the two halves of a vertical kana repeat mark (the pairs of W3C JLREQ's class cl-08, VectorCraft's set). Both composers and vertical type follow it, and justification adds no space inside a pair. It works with a Kinsoku Set only, is off by default and is saved only when on; editing the set of pairs is not available.
|
||||
`.ai` import reads each paragraph's Kinsoku Set (None, Hard or Soft), Kinsoku Shori Type, Burasagari and Bunri-Kinshi from the file's editable text: the paragraph's own setting, else its paragraph style's or a style that one is based on, else the document's default. A paragraph with a custom Kinsoku set takes its paragraph style's set, and the importer warns about it. A value it cannot read takes its paragraph style's value too. `.ai` export does not write these settings.
|
||||
`.ai` import reads each paragraph's Kinsoku Set (None, Hard or Soft), Kinsoku Shori Type, Burasagari and Bunri-Kinshi from the file's editable text: the paragraph's own setting, else its paragraph style's or a style that one is based on, else the document's default. A paragraph with a custom Kinsoku set takes its paragraph style's set, and the importer warns about it. A value it cannot read takes its paragraph style's value too. An `.ai` save writes all four settings for every paragraph, the normal paragraph style and the document's defaults, and lists the Hard and Soft sets, in the form that reader reads, so they reopen as set and are not reported as left out; Burasagari and Bunri-Kinshi keep their values under Kinsoku None.
|
||||
The Paragraph panel menu's Korean Line Break Anywhere (`text.setFormat {koreanLineBreakAnywhere}`, with the East Asian options, and the East Asian Composition Settings section of Paragraph Style Options) sets for each paragraph whether a line may break between any two Hangul syllables. When it is off, a word that contains Hangul breaks only at its spaces and after punctuation, or where the word is wider than the line, and takes no hyphen. New type has it off; paragraphs saved before the option read as on, so their lines do not move.
|
||||
The Paragraph panel menu's Reset Panel (`text.setStyle`, `text.setFormat` and `text.tabs.clear`) gives the selected type's paragraphs, or the paragraphs the Type tool's selection touches, Auto alignment, no indents or paragraph spacing, Hyphenate off with the default Hyphenation and Justification options, Auto direction, Bottom-to-Bottom Leading, the Line-end Punctuation Half Width Mojikumi Set, Regular burasagari, the Hard kinsoku set, Push Out Only, the Every-line Composer, Bunri-Kinshi, Roman Hanging Punctuation and Korean Line Break Anywhere off, no kashidas and no tab stops, as one undo step.
|
||||
The Paragraph panel menu's Hyphenation… (`ui.hyphenation`, `text.setFormat {wordsLongerThan, afterFirst, beforeLast, hyphenLimit, hyphenationZone, hyphenateCapitalized}`) sets each paragraph's hyphenation limits: the shortest word that breaks, the fewest letters on each side of the hyphen, the most hyphenated lines in a row, a zone at the right edge where the Single-line Composer breaks before a word instead of hyphenating it, and whether capitalized words break. The defaults are words longer than 5 letters, 3 letters on each side, no limit or zone, and capitalized words hyphenated; paragraph styles and the native file keep the options.
|
||||
@@ -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.
|
||||
@@ -1842,6 +1843,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
A `.ai` or EPS opened from its editing data with one object on a shown layer that the reader can't read (an unknown operator inside a group, a pattern fill whose pattern it doesn't have, a symbol instance, a placed file without a usable preview) keeps its layers and groups: in that object's place, its layer gets a group of the page's objects inside the object's box, named after it, with a warning that lists what came in as the page's art and an export or Save As to its own path asking first (`acknowledgeLoss`). The file still opens from its page or PDF part when no box can be found, when live art or another unread object shares the page art inside it, when the object spans two artboards or lies on an artboard that has no page, when no page art lies inside its box, when that page art is inside a page group with a clip, mask, transparency or appearance, when the object holds a frame of threaded type, when the page art uses a pattern, image or swatch that the page lacks or that differs from the editing data's, or when the page art doesn't carry the object's transparency (#4806; `crates/eps/src/import/tests_native.rs`, `crates/engine/src/cmd/fileio/tests_aiimport.rs`).
|
||||
A `.ai` or EPS opened from its editing data with one object on a shown layer that the reader can't read (an unknown operator inside a group, a pattern fill whose pattern it doesn't have, a symbol instance, a placed file without a usable preview) keeps its layers and groups: in that object's place, its layer gets a group of the page's objects inside the object's box, named after it, with a warning that lists what came in as the page's art and an export or Save As to its own path asking first (`acknowledgeLoss`). The file still opens from its page or PDF part when no box can be found, when live art or another unread object shares the page art inside it, when the object spans two artboards, or when the page art doesn't carry the object's transparency (#4806; `crates/eps/src/import/tests_native.rs`, `crates/engine/src/cmd/fileio/tests_aiimport.rs`).
|
||||
In a `.ai` opened from its editing data, an envelope made with a warp, a mesh or a top object opens as a live envelope of its contents, with its warp style, bend and distortions, its mesh points and handles or its top object's outline, its Envelope Options, its Fidelity and whether its contents are being edited. When Distort Appearance is on and the size the file saves for the contents matches their bounds with strokes, the contents map from that stroked box, until an edit in Edit Contents changes how far the strokes reach; VectorCraft's new envelopes map from the geometric box, as do contents with no width or no height, such as a single straight line. An envelope that can't be read, or that VectorCraft draws differently from the file's drawn art, keeps that drawn art, with a note. An envelope of type opens live, its type laid out from the text document as its contents, where VectorCraft's own envelope of that type draws as the drawn art the file saves (compared as for the other envelopes, seen on white and on black, so white type counts, and only where the layers with it are compared with the page and draw as it, the envelope weighed as the art it draws; where they don't, even with the drawn art of every live envelope put back, and are used all the same, trusted, with the objects that differ coming in as the page's art, or opened alone, it stays live where, in the pixels it and its drawn art ink (drawn together without the rest of the layers), the layers with it differ from the page in no more than its own check allows and the envelopes that stay differ there in no more than half of what the page check allows, and nothing above it clips, masks or moves it); elsewhere, and where the type's font isn't available, a text or visibility variable binds the type, or the envelope is in a symbol's or a pattern's art, it keeps its drawn art, with its type hidden and a note that says the type isn't editable (#3179; `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/tests_native.rs`). A warp of type whose own warp, VectorCraft's, doesn't draw as its drawn art is tried again as a mesh envelope on the grid the file saves for it: its type stays editable and keeps the file's shape, but the warp's settings (style, bend) are lost, as the document has no place for them on a mesh. Type with strokes in an envelope with Distort Appearance on is also tried mapped from its glyphs grown by as far as its strokes paint along a side (half the weight of a centred stroke), without what miter joins add at corners, where the size the file saves for it doesn't already give that box; after those tries (and before a grid moved onto its drawn art), it is also tried mapped from the box of what it paints, where that is another box, as users' files map some such type: its glyph outlines with their fills and strokes baked as the envelope bakes them, so geometry effects on them count (a stroke a Transform effect moves paints where it is moved to), each measured by its visual bounds (exact for miter joins, a tip counting where the miter limit keeps it, and for round joins; an upper bound for bevel joins, miters the limit cuts, width profiles and square-capped dashes), and a contour of zero length, which paints nothing, left out; effects on the type object itself are left out, as VectorCraft applies them after the envelope bends the type. The drawn-art check decides which one opens. An envelope's grid reads its way round from all its rows and columns, so a mesh bent far round reads the way it runs. While an envelope's contents are edited, its mesh is kept in its dictionary, and in some files that mesh lies away from the drawn art by a move, the contents with the drawn art (as if the mesh hadn't followed the envelope when it moved): a mesh or top object saved in Edit Contents whose mesh draws the contents as large as the drawn art but elsewhere is tried again, after every other way, with its mesh moved onto that art, and opens there where it then draws as it. The drawn art of these files strokes type in an envelope along its bent outlines at the stroke's own weight, Distort Appearance on or off, and VectorCraft draws it so (#6644): an envelope of stroked type whose grid squeezes or stretches it opens live where it draws as that art.
|
||||
In a `.ai` opened from its editing data, an envelope in another envelope's contents opens as a live envelope inside the live outer one, with Edit Contents on or off at either level, also where its record lies straight in the outer envelope's `AIDeformArtKey` block with no group around it; each level edits its own contents without removing its distortion, as the help page describes for one envelope (https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/edit-the-contents-of-envelopes.html). Each envelope is compared with its own drawn art: an inner one that doesn't match keeps its drawn art as the outer envelope's contents, and an outer one that doesn't match keeps its own drawn art. An inner record left without its `XP` stops waiting when the outer dictionary ends, and an envelope in an opacity mask's art reads as part of the mask (`an_envelope_in_an_envelope_s_contents_opens_live_inside_it` and the tests after it in `crates/eps/src/import/ai/tests.rs`).
|
||||
In a `.ai` opened from its editing data, Convert to Shape on a whole path or type object opens as a live Rectangle, Rounded Rectangle or Ellipse effect with its Absolute or Relative size, its corner radius, its place among the object's effects and whether it is hidden. A relative size in the file is added to each side. A relative Ellipse, or a setting VectorCraft doesn't read, keeps the drawn art (`crates/eps/src/import/ai/style/tests.rs`, `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/tests_native.rs`).
|
||||
In a `.ai` opened from its editing data, Bas Relief in an art style takes its Detail, Smoothness and Light direction from the style's settings block, and an object other than type with it opens as itself with the live effect. A settings block that VectorCraft can't read (malformed, another effect's, a value out of range or a key it doesn't know) keeps the object's drawn look (part of #637; [raster effects reference](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-filter-effects/raster-effects-reference.html), [Photoshop File Formats Specification](https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/), [scripting the filter gallery](https://community.adobe.com/questions-712/scripting-support-for-the-filter-gallery-1064646); `crates/eps/src/import/ai/style/tests.rs`, `crates/eps/src/import/ai/tests.rs`).
|
||||
PDF export and `.ai` saves write a page with a side longer than 14,400 pt with a `UserUnit` (PDF 1.6), its longer side divided by 14,400 and rounded up to the next thousandth, so that no side is longer than 14,400 units (ISO 32000-1, Annex C.2); a PDF 1.5 file with such a page is written as PDF 1.6 with PDF 1.5's encryption, PDF/X files and PDF 1.3 and 1.4 files write it in points (in PDF 1.3 and 1.4, a page past 32,767 pt that needs a real number past 32,767 is refused with an error naming it), a page whose short side is 3 pt or longer but would be under 3 units at that `UserUnit` gets a smaller one that keeps the short side at 3 units, and the export's warnings give each such page's size and how it is written (#6382). The Save PDF dialog's "Write pages longer than 200 in at full size in points" (`longPagesInPoints`, on by default; `.ai` saves leave it off) writes such pages in points without a `UserUnit` at every PDF version, in files without a PDF/X or PDF/A standard, so readers that ignore `UserUnit` show them at full size.
|
||||
|
||||
+28
-3
@@ -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).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user