From 2c7211090b57d1263e30cb2c9abff35887ac5e2a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 16:54:42 -0800 Subject: [PATCH 01/13] 3D: Extrude & Bevel takes custom bevel shapes drawn as open paths Custom bevels come from the bevels file, Bevels.vectorcraft next to the preferences. Each symbol whose art is one open path is one bevel, listed by name after the five built-in shapes in the Bevel Shape menus of Extrude & Bevel and Extrude & Bevel (Classic). Edit Bevels... under Bevel Shape in the 3D and Materials panel opens the file, creating it with an example bevel when it is missing, and saving it reloads the menus. A custom bevel takes the Width, Height, Repeat, Space, Bevel Inside and Bevel both sides settings, and the effect keeps a copy of its points so the document draws it without the file. - threeD.bevels.list, threeD.bevels.edit and threeD.bevels.reload - bevel {custom: name} in effect.apply and effect.setParams, stored as bevel custom with bevelName and bevelProfile (2 to 64 points) - Docs: docs/mcp.md, docs/three-d.md, docs/effects-parity.md --- apps/vectorcraft-cli/src/main.rs | 1 + apps/vectorcraft/src/main.rs | 2 + apps/vectorcraft/src/prefs_dir.rs | 8 + crates/effects/src/catalog.rs | 4 +- crates/effects/src/lib.rs | 11 +- crates/effects/src/solids.rs | 75 +++- crates/effects/src/solids/classic.rs | 21 +- crates/effects/src/solids/tests.rs | 52 +++ crates/engine/src/cmd.rs | 2 + crates/engine/src/cmd/arrowheads.rs | 7 +- crates/engine/src/cmd/bevels.rs | 334 ++++++++++++++++++ crates/engine/src/cmd/effectcmd.rs | 13 + crates/engine/src/cmd/fileio/save.rs | 4 +- crates/engine/src/lib.rs | 2 + crates/engine/src/session/documents.rs | 1 + crates/engine/src/tests.rs | 1 + crates/engine/src/tests/bevels.rs | 217 ++++++++++++ crates/three-d/src/lib.rs | 2 +- crates/three-d/src/solid.rs | 72 ++++ crates/three-d/src/solid/tests.rs | 34 ++ crates/ui-egui/src/dialogs/revolve.rs | 77 +++- crates/ui-egui/src/dialogs/three_d_classic.rs | 13 +- crates/ui-egui/src/i18n/bg.tsv | 4 + crates/ui-egui/src/i18n/bs.tsv | 4 + crates/ui-egui/src/i18n/ca.tsv | 4 + crates/ui-egui/src/i18n/cs.tsv | 4 + crates/ui-egui/src/i18n/da.tsv | 4 + crates/ui-egui/src/i18n/de.tsv | 4 + crates/ui-egui/src/i18n/el.tsv | 4 + crates/ui-egui/src/i18n/es.tsv | 4 + crates/ui-egui/src/i18n/fi.tsv | 4 + crates/ui-egui/src/i18n/fr.tsv | 4 + crates/ui-egui/src/i18n/hi.tsv | 4 + crates/ui-egui/src/i18n/hu.tsv | 4 + crates/ui-egui/src/i18n/id.tsv | 4 + crates/ui-egui/src/i18n/it.tsv | 4 + crates/ui-egui/src/i18n/ja.tsv | 4 + crates/ui-egui/src/i18n/ka.tsv | 4 + crates/ui-egui/src/i18n/ko.tsv | 4 + crates/ui-egui/src/i18n/nl.tsv | 4 + crates/ui-egui/src/i18n/pl.tsv | 4 + crates/ui-egui/src/i18n/pt-br.tsv | 4 + crates/ui-egui/src/i18n/ru.tsv | 4 + crates/ui-egui/src/i18n/sv.tsv | 4 + crates/ui-egui/src/i18n/tr.tsv | 4 + crates/ui-egui/src/i18n/uk.tsv | 4 + crates/ui-egui/src/i18n/vi.tsv | 4 + crates/ui-egui/src/i18n/zh-hans.tsv | 4 + crates/ui-egui/src/i18n/zh-hant.tsv | 4 + crates/ui-egui/src/panels/tests_three_d.rs | 35 ++ crates/ui-egui/src/panels/three_d.rs | 15 +- docs/effects-parity.md | 4 +- docs/mcp.md | 29 +- docs/three-d.md | 29 +- 54 files changed, 1119 insertions(+), 54 deletions(-) create mode 100644 crates/engine/src/cmd/bevels.rs create mode 100644 crates/engine/src/tests/bevels.rs diff --git a/apps/vectorcraft-cli/src/main.rs b/apps/vectorcraft-cli/src/main.rs index 0d4deca36f..c0726b3dc0 100644 --- a/apps/vectorcraft-cli/src/main.rs +++ b/apps/vectorcraft-cli/src/main.rs @@ -249,6 +249,7 @@ fn with_stores(mut h: Headless) -> Headless { prefs_dir::attach_pdf_preset_store(&mut h.session); prefs_dir::attach_custom_dictionary(&mut h.session); prefs_dir::attach_arrowheads(&mut h.session); + prefs_dir::attach_bevels(&mut h.session); h } diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index c2b40e37e6..bd5749ba25 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -490,6 +490,8 @@ fn main() -> std::process::ExitCode { prefs_dir::attach_custom_dictionary(&mut app.session); // The custom arrowheads, kept in their own file next to the preferences. prefs_dir::attach_arrowheads(&mut app.session); + // The custom bevels, kept in their own file next to the preferences. + prefs_dir::attach_bevels(&mut app.session); // Fit the window to its monitor, or put it back where it was (still hidden). let winit_window = cc.winit_window().cloned(); if let Some(w) = &winit_window { diff --git a/apps/vectorcraft/src/prefs_dir.rs b/apps/vectorcraft/src/prefs_dir.rs index 11afcfe121..c6b6bb4c7e 100644 --- a/apps/vectorcraft/src/prefs_dir.rs +++ b/apps/vectorcraft/src/prefs_dir.rs @@ -97,6 +97,14 @@ pub fn attach_arrowheads(session: &mut vectorcraft_engine::Session) { } } +/// Keep the custom bevels (`threeD.bevels.edit`) in the `Bevels.vectorcraft` file next to the +/// settings, and list the bevels it holds. +pub fn attach_bevels(session: &mut vectorcraft_engine::Session) { + if let Some(path) = store_dir(vectorcraft_engine::cmd::bevels::FILE_NAME) { + session.attach_bevels_file(path.to_string_lossy().to_string()); + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/effects/src/catalog.rs b/crates/effects/src/catalog.rs index 5b785bee14..fc0fe42c8c 100644 --- a/crates/effects/src/catalog.rs +++ b/crates/effects/src/catalog.rs @@ -189,7 +189,7 @@ pub fn effect_catalog() -> Vec { EXTRUDE, "Extrude & Bevel…", &["Effect", "3D and Materials"], - "{depth: pt (0..2000, 50), twist: degrees (0..360, 0; the back turned against the front), taper: % (1..100, 100; the back's size), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none), bevelWidth: pt (0..1000, 4), bevelHeight: pt (0..1000, 4), bevelRepeat: integer (1..32, 1), bevelSpace: % (0..90, 0; flat between repeats), bevelInside: bool (false: added around the shape; true: carved into it), bevelBothSides: bool (false), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; the first light casts a hard-edged shadow, black at 50% times the art's opacity), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across)}. The front face is the art, extruded backwards about the centre of its bounds; painted with the top fill (else the top stroke).", + "{depth: pt (0..2000, 50), twist: degrees (0..360, 0; the back turned against the front), taper: % (1..100, 100; the back's size), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none; or custom, a bevel of the user's own drawn by bevelProfile), bevelWidth: pt (0..1000, 4), bevelHeight: pt (0..1000, 4), bevelRepeat: integer (1..32, 1), bevelSpace: % (0..90, 0; flat between repeats), bevelInside: bool (false: added around the shape; true: carved into it), bevelBothSides: bool (false), bevelName: string (a custom bevel's name), bevelProfile: [[x, y], …] (a custom bevel's 2 to 64 points, shares 0..1 of the width and height from [0, 0] at the cap's edge to [1, 1] at the side wall, joined by straight lines; effect.apply and effect.setParams also take bevel {custom: name}, a bevel of the bevels file (threeD.bevels.list), and store it as bevel custom with its bevelName and bevelProfile), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; the first light casts a hard-edged shadow, black at 50% times the art's opacity), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across)}. The front face is the art, extruded backwards about the centre of its bounds; painted with the top fill (else the top stroke).", json!({"depth":50.0,"twist":0.0,"taper":100.0,"cap":true,"bevel":"none","bevelWidth":4.0,"bevelHeight":4.0,"bevelRepeat":1,"bevelSpace":0.0,"bevelInside":false,"bevelBothSides":false,"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"shade":true,"lightColor":"#ffffff","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":80.0,"lightSoftness":0.0,"ambient":25.0,"shadow":false,"shadowPosition":"behind","shadowDistance":0.0,"shadowBounds":100.0}), ), g( @@ -210,7 +210,7 @@ pub fn effect_catalog() -> Vec { CLASSIC_EXTRUDE, "Extrude & Bevel (Classic)…", &["Effect", "3D and Materials", "3D (Classic)"], - "{depth: pt (0..2000, 50), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none), bevelHeight: pt (1..100, 4; the bevel is as wide as it is tall), bevelInside: bool (false: added around the shape; true: carved into it), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face, hidden ones included, and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), drawHiddenFaces: bool (false; also draws the faces turned away, behind the others)}. The front face is the art, extruded backwards about the center of its bounds; a solid is built for the top fill and for each stroke, each in its own paint. The defaults are VectorCraft's own.", + "{depth: pt (0..2000, 50), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none; or custom, a bevel of the user's own drawn by bevelProfile), bevelHeight: pt (1..100, 4; the bevel is as wide as it is tall), bevelInside: bool (false: added around the shape; true: carved into it), bevelName: string and bevelProfile: [[x, y], …] (a custom bevel's name and points, as for threeD.extrude; bevel {custom: name} takes a bevel of the bevels file), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face, hidden ones included, and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), drawHiddenFaces: bool (false; also draws the faces turned away, behind the others)}. The front face is the art, extruded backwards about the center of its bounds; a solid is built for the top fill and for each stroke, each in its own paint. The defaults are VectorCraft's own.", json!({"depth":50.0,"cap":true,"bevel":"none","bevelHeight":4.0,"bevelInside":false,"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"surface":"plastic","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":100.0,"ambient":50.0,"highlightIntensity":60.0,"highlightSize":90.0,"blendSteps":25,"shadingColor":"black","shadingCustom":"#000000","drawHiddenFaces":false}), ), g( diff --git a/crates/effects/src/lib.rs b/crates/effects/src/lib.rs index d5f0af894a..3ea44d683f 100644 --- a/crates/effects/src/lib.rs +++ b/crates/effects/src/lib.rs @@ -87,15 +87,16 @@ pub use revolve::{ CLASSIC_REVOLVE, REVOLVE, has_revolve, is_revolve, revolve_art, revolve_art_in, revolve_options, validate_revolve, validate_revolve_in, }; pub use solids::{ - CLASSIC_EXTRUDE, CLASSIC_ROTATE, EXTRUDE, INFLATE, ROTATE, ROTATE_SURFACES, ROTATION_PRESETS, SHADING_COLORS, SOLIDS, SolidMesh, THREE_D_TYPES, - classic_extrude_options, classic_shading, extrude_options, has_solid, inflate_options, is_classic_three_d, is_three_d, solid_art, solid_art_in, - three_d_meshes, three_d_meshes_in, three_d_meshes_of, three_d_meshes_of_in, three_d_params_as, three_d_wireframe_in, validate_solid, - validate_solid_in, validate_three_d, validate_three_d_at, validate_three_d_at_in, validate_three_d_in, validate_three_d_params, view_options, + BEVEL_NAME, BEVEL_PROFILE, CLASSIC_EXTRUDE, CLASSIC_ROTATE, EXTRUDE, INFLATE, ROTATE, ROTATE_SURFACES, ROTATION_PRESETS, SHADING_COLORS, SOLIDS, + SolidMesh, THREE_D_TYPES, classic_extrude_options, classic_shading, extrude_options, has_solid, inflate_options, is_classic_three_d, is_three_d, + solid_art, solid_art_in, three_d_meshes, three_d_meshes_in, three_d_meshes_of, three_d_meshes_of_in, three_d_params_as, three_d_wireframe_in, + validate_solid, validate_solid_in, validate_three_d, validate_three_d_at, validate_three_d_at_in, validate_three_d_in, validate_three_d_params, + view_options, }; pub use stylize::{ScribbleSetting, scribble_setting_id, scribble_settings}; pub use svg_filter::SVG_FILTER; pub use trap::TRAP; -pub use vectorcraft_three_d::Mesh; +pub use vectorcraft_three_d::{BevelProfile, Mesh}; pub use warp::{WARP_NET, WarpNet, WarpStyle, map_version, warp_point, warp_version}; mod catalog; diff --git a/crates/effects/src/solids.rs b/crates/effects/src/solids.rs index 4ddd453587..b538cf5c04 100644 --- a/crates/effects/src/solids.rs +++ b/crates/effects/src/solids.rs @@ -6,7 +6,7 @@ use serde_json::Value; use vectorcraft_doc::color::{BlendMode, Paint}; use vectorcraft_doc::{Appearance, AppearanceItem, Document, Effect, Node, NodeId, NodeKind, OpacityMask, StrokeLayer}; use vectorcraft_geom::{FillRule, PathData, Rect}; -use vectorcraft_three_d::{Bevel, BevelShape, Extrude, Facet, Inflate, Mesh, View}; +use vectorcraft_three_d::{Bevel, BevelProfile, BevelShape, Extrude, Facet, Inflate, Mesh, View}; #[cfg(test)] use vectorcraft_doc::color::Color; @@ -54,7 +54,9 @@ pub const THREE_D_TYPES: [(&str, &str); 4] = [("plane", ROTATE), ("extrude", EXT /// The parameters of 3D effect `to` for an effect `from` with `params`, as switching the object /// type keeps them: every setting `to` takes keeps its value from `params` (the defaults of `from` /// under them), each rotation angle wrapped into -180° to 180° when `to` is not Revolve, and the -/// settings only `to` takes start at their defaults. Settings `to` does not take are dropped. +/// settings only `to` takes start at their defaults. Settings `to` does not take are dropped; a +/// custom bevel's name and points ([`BEVEL_NAME`], [`BEVEL_PROFILE`]) go with `bevel` when `to` +/// takes one. pub fn three_d_params_as(from: &str, params: &Value, to: &str) -> Value { let current = crate::merged_params(from, params); let mut out = crate::default_params(to).and_then(|v| v.as_object().cloned()).unwrap_or_default(); @@ -63,6 +65,13 @@ pub fn three_d_params_as(from: &str, params: &Value, to: &str) -> Value { value.clone_from(v); } } + if out.contains_key("bevel") { + for key in [BEVEL_NAME, BEVEL_PROFILE] { + if let Some(v) = current.get(key).filter(|v| !v.is_null()) { + out.insert(key.into(), v.clone()); + } + } + } if to != crate::REVOLVE { for key in ["rotationX", "rotationY", "rotationZ"] { if let Some(a) = out.get(key).and_then(Value::as_f64).filter(|a| !(-180.0..=180.0).contains(a)) { @@ -125,14 +134,66 @@ pub fn view_options(p: &Value) -> View { } } -/// Extrude & Bevel's parameters. `bevel` is `"none"` or a [`BevelShape`] id. +/// The custom bevel's name parameter: the name the bevels file gave it, kept for the menus. +pub const BEVEL_NAME: &str = "bevelName"; +/// The custom bevel's points parameter: `[[across, down], …]`, shares of the bevel's width and +/// height from the cap's edge `[0, 0]` to the side wall `[1, 1]` (a copy of the bevel's path, so +/// the document draws it without the bevels file). +pub const BEVEL_PROFILE: &str = "bevelProfile"; + +/// The points of `v`, a [`BEVEL_PROFILE`] value; `None` unless it is an array of `[x, y]` number +/// pairs that make a [`BevelProfile`]. +fn bevel_profile(v: &Value) -> Option { + let list = v.as_array().filter(|a| a.len() <= BevelProfile::MAX_POINTS)?; + let pts: Option> = list + .iter() + .map(|pt| match pt.as_array().map(Vec::as_slice) { + Some([x, y]) => Some((x.as_f64()?, y.as_f64()?)), + _ => None, + }) + .collect(); + BevelProfile::new(&pts?) +} + +/// The bevel shape of parameters `p`: `bevel` `"none"` (none), a built-in [`BevelShape`] id, or +/// `"custom"` with its points in [`BEVEL_PROFILE`] (none when they do not make a profile). +pub(crate) fn bevel_shape(p: &Value) -> Option { + match text(p, "bevel", "none") { + "custom" => p.get(BEVEL_PROFILE).and_then(bevel_profile).map(BevelShape::Custom), + id => BevelShape::parse(id), + } +} + +/// Check the custom bevel parameters of `p`: `bevel` `"custom"` needs [`BEVEL_PROFILE`], whose +/// points, when given, must make a profile, and [`BEVEL_NAME`] is a string. +fn validate_bevel(p: &Value) -> Result<(), String> { + let most = BevelProfile::MAX_POINTS; + if let Some(v) = p.get(BEVEL_PROFILE) + && !v.is_null() + && bevel_profile(v).is_none() + { + return Err(format!( + "{BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall)" + )); + } + if text(p, "bevel", "none") == "custom" && p.get(BEVEL_PROFILE).is_none_or(Value::is_null) { + return Err(format!("bevel custom needs {BEVEL_PROFILE}, the bevel's points")); + } + if p.get(BEVEL_NAME).is_some_and(|v| !v.is_string() && !v.is_null()) { + return Err(format!("{BEVEL_NAME} must be a string")); + } + Ok(()) +} + +/// Extrude & Bevel's parameters. `bevel` is `"none"`, a [`BevelShape`] id, or `"custom"` with +/// its points in [`BEVEL_PROFILE`]. pub fn extrude_options(p: &Value) -> Extrude { Extrude { depth: num(p, "depth", 50.0), twist: num(p, "twist", 0.0), taper: num(p, "taper", 100.0) / 100.0, cap: flag(p, "cap", true), - bevel: BevelShape::parse(text(p, "bevel", "none")).map(|shape| Bevel { + bevel: bevel_shape(p).map(|shape| Bevel { shape, width: num(p, "bevelWidth", 4.0), height: num(p, "bevelHeight", 4.0), @@ -213,12 +274,12 @@ fn validate_solid_params(id: &str, p: &Value) -> Result<(), String> { crate::lighting::validate(p)?; shadow::validate(p)?; if let Some(v) = p.get("bevel") - && !v.as_str().is_some_and(|s| s == "none" || BevelShape::parse(s).is_some()) + && !v.as_str().is_some_and(|s| s == "none" || s == "custom" || BevelShape::parse(s).is_some()) { let names: Vec<_> = BevelShape::ALL.iter().map(|b| b.id()).collect(); - return Err(format!("bevel must be none or one of {}", names.join(", "))); + return Err(format!("bevel must be none or one of {}, or custom with {BEVEL_PROFILE}", names.join(", "))); } - Ok(()) + validate_bevel(p) } /// The name an error gives 3D effect `id`. diff --git a/crates/effects/src/solids/classic.rs b/crates/effects/src/solids/classic.rs index 919de831ce..e0928f9452 100644 --- a/crates/effects/src/solids/classic.rs +++ b/crates/effects/src/solids/classic.rs @@ -7,7 +7,7 @@ use serde_json::Value; use vectorcraft_doc::color::{BlendMode, Color, Paint}; use vectorcraft_doc::{Appearance, AppearanceItem, FillLayer, Node, StrokeLayer}; use vectorcraft_geom::Rect; -use vectorcraft_three_d::{Bevel, BevelShape, ClassicShading, ClassicSurface, Extrude, Facet, Light}; +use vectorcraft_three_d::{Bevel, ClassicShading, ClassicSurface, Extrude, Facet, Light}; use crate::util::{flag, num, text}; @@ -43,13 +43,7 @@ pub fn classic_extrude_options(p: &Value) -> Extrude { Extrude { depth: num(p, "depth", 50.0), cap: flag(p, "cap", true), - bevel: BevelShape::parse(text(p, "bevel", "none")).map(|shape| Bevel { - shape, - width: height, - height, - inside: flag(p, "bevelInside", false), - ..Bevel::default() - }), + bevel: super::bevel_shape(p).map(|shape| Bevel { shape, width: height, height, inside: flag(p, "bevelInside", false), ..Bevel::default() }), hidden: flag(p, "drawHiddenFaces", false) || classic_shading(p).surface == ClassicSurface::Wireframe, ..Extrude::default() } @@ -106,9 +100,16 @@ const FLAGS: [&str; 4] = ["cap", "bevelInside", "lightBehind", "drawHiddenFaces" /// Check Extrude & Bevel (Classic)'s parameters `p` (its defaults filled in): every key is one of /// its parameters, numbers are in range, flags are true or false, and `surface`, `shadingColor` and -/// `shadingCustom` name a surface, a shading color and a #rrggbb color. +/// `shadingCustom` name a surface, a shading color and a #rrggbb color. A custom bevel's name and +/// points ([`super::BEVEL_NAME`], [`super::BEVEL_PROFILE`]) are parameters too, checked with +/// Extrude & Bevel's. pub fn validate(p: &Value) -> Result<(), String> { - validate_classic(CLASSIC_EXTRUDE, p, &RANGES, &FLAGS) + let mut rest = p.clone(); + if let Some(m) = rest.as_object_mut() { + m.remove(super::BEVEL_NAME); + m.remove(super::BEVEL_PROFILE); + } + validate_classic(CLASSIC_EXTRUDE, &rest, &RANGES, &FLAGS) } /// Rotate (Classic)'s numeric parameters: (key, lowest, highest, whole numbers only). diff --git a/crates/effects/src/solids/tests.rs b/crates/effects/src/solids/tests.rs index 1efe826c75..2ff2e51b05 100644 --- a/crates/effects/src/solids/tests.rs +++ b/crates/effects/src/solids/tests.rs @@ -619,6 +619,58 @@ fn parameters_are_validated_and_lengths_scale_with_the_object() { assert!(extrude_options(&json!({})).bevel.is_none()); } +/// `bevel` custom draws the points of `bevelProfile` in both Extrude & Bevels, with the other bevel +/// settings; bad points, a custom bevel without points and a name that is not a string are refused. +#[test] +fn custom_bevels_draw_their_points_and_bad_points_are_refused() { + let n = square_node(); + let notch = json!([[0, 0], [0.2, 0.6], [0.7, 0.4], [1, 1]]); + let custom = json!({"bevel": "custom", "bevelName": "Notch", "bevelProfile": notch, "bevelWidth": 10, "bevelRepeat": 2, "bevelBothSides": true}); + let b = extrude_options(&custom).bevel.unwrap(); + assert!(matches!(b.shape, BevelShape::Custom(_))); + assert_eq!((b.width, b.repeat, b.both_sides), (10.0, 2, true)); + let points: Vec<(f64, f64)> = match b.shape { + BevelShape::Custom(p) => p.points().collect(), + _ => vec![], + }; + assert_eq!(points.len(), 4); + assert!((points[2].0 - 0.7).abs() < 1e-4 && (points[2].1 - 0.4).abs() < 1e-4, "{points:?}"); + assert!(matches!(classic_extrude_options(&custom).bevel.map(|b| b.shape), Some(BevelShape::Custom(_)))); + for id in [EXTRUDE, CLASSIC_EXTRUDE] { + let classic_params = json!({"bevel": "classic", "bevelHeight": 10}); + let custom_params = json!({"bevel": "custom", "bevelProfile": notch, "bevelHeight": 10, "bevelName": "Notch"}); + assert!(validate_solid(&n, id, &custom_params).is_ok(), "{id}"); + let art = |p: &Value| { + let mut n = square_node(); + n.appearance.effects.push(fx(id, p.clone())); + solid_art(&n).unwrap() + }; + assert_ne!(art(&classic_params), art(&custom_params), "{id}"); + for (bad, err) in [ + (json!({"bevel": "custom"}), "bevel custom needs bevelProfile"), + (json!({"bevel": "custom", "bevelProfile": [[0, 0]]}), "bevelProfile must be 2 to 64"), + (json!({"bevel": "custom", "bevelProfile": [[0.1, 0], [1, 1]]}), "bevelProfile must be 2 to 64"), + (json!({"bevel": "custom", "bevelProfile": [[0, 0], [2, 0.5], [1, 1]]}), "bevelProfile must be 2 to 64"), + (json!({"bevel": "custom", "bevelProfile": [[0, 0], ["a", 0.5], [1, 1]]}), "bevelProfile must be 2 to 64"), + (json!({"bevel": "custom", "bevelProfile": "0,0 1,1"}), "bevelProfile must be 2 to 64"), + (json!({"bevel": "custom", "bevelProfile": notch, "bevelName": 3}), "bevelName must be a string"), + ] { + let e = validate_solid(&n, id, &bad).unwrap_err(); + assert!(e.contains(err), "{id} {bad}: {e}"); + } + } + // A loaded file whose points do not make a profile draws no bevel. + assert!(extrude_options(&json!({"bevel": "custom", "bevelProfile": [[0, 0]]})).bevel.is_none()); + // Changing the type keeps the custom bevel where the new effect takes a bevel, and drops it + // where it does not. + let classic = three_d_params_as(EXTRUDE, &custom, CLASSIC_EXTRUDE); + assert_eq!((&classic["bevel"], &classic[BEVEL_NAME], &classic[BEVEL_PROFILE]), (&json!("custom"), &json!("Notch"), ¬ch)); + assert!(validate_solid(&n, CLASSIC_EXTRUDE, &classic).is_ok()); + assert_eq!(three_d_params_as(CLASSIC_EXTRUDE, &classic, EXTRUDE)[BEVEL_PROFILE], notch); + let inflate = three_d_params_as(EXTRUDE, &custom, INFLATE); + assert!(inflate.get(BEVEL_PROFILE).is_none() && inflate.get(BEVEL_NAME).is_none()); +} + #[test] fn inflate_reads_twist_taper_and_cap() { let o = inflate_options(&json!({"twist": 90, "taper": 40, "cap": false})); diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 66eb2104d1..171d1bf09a 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -8,6 +8,7 @@ pub mod arrowheads; mod artboardalign; mod assets; mod attributes; +pub mod bevels; pub mod brushlib; mod brushsym; mod buildcmds; @@ -312,6 +313,7 @@ pub fn command_specs() -> &'static [CommandSpec] { v.extend(draw2::specs()); v.extend(xform::specs()); v.extend(effectcmd::specs()); + v.extend(bevels::specs()); v.extend(wireframe::specs()); v.extend(pathops::specs()); v.extend(compoundshape::specs()); diff --git a/crates/engine/src/cmd/arrowheads.rs b/crates/engine/src/cmd/arrowheads.rs index 0aeda59731..eba26ad80e 100644 --- a/crates/engine/src/cmd/arrowheads.rs +++ b/crates/engine/src/cmd/arrowheads.rs @@ -378,13 +378,14 @@ impl Session { } } -fn same_file(a: &str, b: &str) -> bool { +pub(super) fn same_file(a: &str, b: &str) -> bool { let canon = |p: &str| std::fs::canonicalize(p).unwrap_or_else(|_| std::path::PathBuf::from(p)); std::path::Path::new(a) == std::path::Path::new(b) || canon(a) == canon(b) } -/// The document in the arrowheads file at `path`; `None` when there is no file. -fn read(path: &str) -> std::result::Result, String> { +/// The document in the arrowheads file at `path` (or another such file of the user's, as the +/// bevels file); `None` when there is no file. +pub(super) fn read(path: &str) -> std::result::Result, String> { let size = match std::fs::metadata(path) { Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(None), Err(e) => return Err(format!("{path}: {e}")), diff --git a/crates/engine/src/cmd/bevels.rs b/crates/engine/src/cmd/bevels.rs new file mode 100644 index 0000000000..f36082862e --- /dev/null +++ b/crates/engine/src/cmd/bevels.rs @@ -0,0 +1,334 @@ +//! Custom bevels for Extrude & Bevel and Extrude & Bevel (Classic). The bevels file is a native +//! document kept next to the preferences ([`Session::attach_bevels_file`]). Each of its symbols +//! whose art is one open path is one bevel, listed by the symbol's name after the built-in shapes +//! in the Bevel Shape menus. The path runs from its first anchor, at the cap's edge, to its last, +//! at the side wall: across the page is across the bevel's width and down the page is along its +//! height, whichever way the path is drawn, and points past its ends are held to them. Curves are +//! cut into straight lines, at most [`BevelProfile::MAX_POINTS`] points in all. Saving the file +//! reloads the bevels. An effect that uses a custom bevel carries a copy of its points +//! (`bevelProfile`), so its document draws it anywhere. + +use std::sync::Arc; + +use serde_json::{Value, json}; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_doc::{Appearance, Document, Node, NodeId, NodeKind, Symbol}; +use vectorcraft_geom::{Affine, PathData, PathEl, Point, SubPath}; +use vectorcraft_render::effects::{BEVEL_NAME, BEVEL_PROFILE, BevelProfile}; + +use super::arrowheads::{read, same_file}; +use super::{CommandSpec, Result, Session, always, bad, cmd}; + +/// The bevels file's name, in the folder of the preferences. +pub const FILE_NAME: &str = "Bevels.vectorcraft"; +/// The most bevels read from the file; symbols past it are skipped. +pub const MAX_BEVELS: usize = 256; +/// The most anchors a bevel's path may have; a symbol past it is skipped. +pub const MAX_ANCHORS: usize = 4096; +/// The most points a bevel's path is cut into before it is simplified; a symbol past it is skipped. +pub const MAX_LINE_POINTS: usize = 8192; + +pub fn specs() -> Vec { + vec![ + cmd!( + query "threeD.bevels.list", + "Bevels", + [], + None, + "{} → {bevels: [{name (effect.apply and effect.setParams take Extrude & Bevel's and Extrude & Bevel (Classic)'s `bevel` as {custom: name}), points: [[x, y]…] (shares of the bevel's width and height from the cap's edge [0, 0] to the side wall [1, 1])}], file: the bevels file's path or null (no file here, as on the web), skipped: [{name, reason}] symbols of the file that are not bevels, error: why the file could not be read, or null} the custom bevels, listed after the built-in shapes in the Bevel Shape menus", + always, + list + ), + cmd!( + "threeD.bevels.edit", + "Edit Bevels", + [], + None, + "{} open the bevels file (a native document next to the preferences; created first with one example bevel when it is missing). Each symbol in it whose art is one open path is one custom bevel named after the symbol: the path runs from its first anchor at the cap's edge to its last at the side wall, across the page across the bevel's width and down the page along its height. Saving the file reloads the bevels → {path, created: whether the file was made now}", + has_file, + edit + ), + cmd!( + "threeD.bevels.reload", + "Reload Bevels", + [], + None, + "{} read the bevels file again (a save of it from VectorCraft does this already) → {count, skipped: [{name, reason}]}", + has_file, + reload + ), + ] +} + +/// A custom bevel: its name and its points, (share of the width, share of the height). +#[derive(Clone, Debug, PartialEq)] +pub struct CustomBevel { + pub name: String, + pub points: Vec<(f64, f64)>, +} + +impl CustomBevel { + /// The points as `bevelProfile` holds them. + pub fn profile_json(&self) -> Value { + json!(self.points.iter().map(|&(x, y)| [x, y]).collect::>()) + } +} + +/// The custom bevels read from the bevels file. +#[derive(Default)] +pub struct Bevels { + path: Option, + bevels: Vec>, + skipped: Vec<(String, String)>, + error: Option, +} + +impl Bevels { + /// The bevels file's path; `None` without one (the web, runs without preferences). + pub fn path(&self) -> Option<&str> { + self.path.as_deref() + } + /// The bevels, in the order of the file's symbols. + pub fn bevels(&self) -> &[Arc] { + &self.bevels + } + /// Bevel `name`. + pub fn get(&self, name: &str) -> Option> { + self.bevels.iter().find(|b| b.name == name).cloned() + } + fn set(&mut self, read: Read) { + (self.bevels, self.skipped) = (read.bevels.into_iter().map(Arc::new).collect(), read.skipped); + self.error = None; + } +} + +/// The bevels a document holds, and the symbols that are not bevels with the reason. +#[derive(Debug, Default)] +pub struct Read { + pub bevels: Vec, + pub skipped: Vec<(String, String)>, +} + +/// The bevels of document `doc`: one per symbol, up to [`MAX_BEVELS`] (see the module docs). +pub fn bevels_of(doc: &Document) -> Read { + let mut out = Read::default(); + for (i, sym) in doc.symbols.iter().enumerate() { + if i >= MAX_BEVELS { + out.skipped.push((sym.name.clone(), format!("only the first {MAX_BEVELS} symbols are read"))); + continue; + } + if out.bevels.iter().any(|b| b.name == sym.name) { + out.skipped.push((sym.name.clone(), "another symbol has this name".into())); + continue; + } + match points_of(&sym.art) { + Ok(points) => out.bevels.push(CustomBevel { name: sym.name.clone(), points }), + Err(why) => out.skipped.push((sym.name.clone(), why.into())), + } + } + out +} + +/// The one open path of art `n`: `n` itself, or the one member of groups that hold one member each. +fn open_path(n: &Node) -> Option<&PathData> { + match &n.kind { + NodeKind::Path { path, guide: false, .. } if path.subpaths.len() == 1 && !path.subpaths[0].closed => Some(path), + NodeKind::Group { children, clip: false } if children.len() == 1 => open_path(&children[0]), + _ => None, + } +} + +/// The profile points of a bevel symbol's art `n` (see the module docs). +fn points_of(n: &Node) -> std::result::Result, &'static str> { + let path = open_path(n).ok_or("its art is not one open path")?; + if path.anchor_count() > MAX_ANCHORS { + return Err("its path has too many anchors for a bevel"); + } + let mut line: Vec = vec![]; + let mut too_many = false; + let tolerance = path.bounds().map_or(1.0, |b| b.width().hypot(b.height()) / 2000.0).max(1e-9); + vectorcraft_geom::flatten(path.to_bezpath().elements().iter().copied(), tolerance, |el| match el { + PathEl::MoveTo(p) | PathEl::LineTo(p) if line.len() < MAX_LINE_POINTS => line.push(p), + PathEl::MoveTo(_) | PathEl::LineTo(_) => too_many = true, + _ => {} + }); + if too_many { + return Err("its path is too detailed for a bevel"); + } + let (Some(&first), Some(&last)) = (line.first(), line.last()) else { return Err("its path has no length") }; + let (dx, dy) = (last.x - first.x, last.y - first.y); + let size = path.bounds().map_or(0.0, |b| b.width().hypot(b.height())); + if !(dx.abs() > size * 1e-6 && dy.abs() > size * 1e-6 && size.is_finite()) { + return Err("its ends are not apart both across and down"); + } + let mut pts: Vec<(f64, f64)> = line.iter().map(|p| (((p.x - first.x) / dx).clamp(0.0, 1.0), ((p.y - first.y) / dy).clamp(0.0, 1.0))).collect(); + pts.dedup_by(|a, b| (a.0 - b.0).abs() < 1e-9 && (a.1 - b.1).abs() < 1e-9); + if pts.len() < 2 { + return Err("its ends are not apart both across and down"); + } + // The ends map to the corners exactly. + let last = pts.len() - 1; + (pts[0], pts[last]) = ((0.0, 0.0), (1.0, 1.0)); + let pts = simplified(&pts); + BevelProfile::new(&pts).ok_or("its path is too detailed for a bevel")?; + Ok(pts) +} + +/// `pts` with the fewest points the Ramer-Douglas-Peucker rule keeps at a tolerance (from a +/// thousandth of the bevel, doubled until they fit) that leaves at most +/// [`BevelProfile::MAX_POINTS`]. The first and last points are always kept. +fn simplified(pts: &[(f64, f64)]) -> Vec<(f64, f64)> { + let mut eps = 1e-3; + loop { + let out = rdp(pts, eps); + if out.len() <= BevelProfile::MAX_POINTS || eps > 2.0 { + return out; + } + eps *= 2.0; + } +} + +/// The points of `pts` Ramer-Douglas-Peucker keeps at tolerance `eps`. +fn rdp(pts: &[(f64, f64)], eps: f64) -> Vec<(f64, f64)> { + if pts.len() < 3 { + return pts.to_vec(); + } + let mut keep = vec![false; pts.len()]; + keep[0] = true; + keep[pts.len() - 1] = true; + let mut stack = vec![(0, pts.len() - 1)]; + while let Some((a, b)) = stack.pop() { + let (p, q) = (pts[a], pts[b]); + let (vx, vy) = (q.0 - p.0, q.1 - p.1); + let len = vx.hypot(vy); + let far = (a + 1..b) + .map(|i| { + let (wx, wy) = (pts[i].0 - p.0, pts[i].1 - p.1); + let d = if len > 0.0 { (vx * wy - vy * wx).abs() / len } else { wx.hypot(wy) }; + (i, d) + }) + .fold(None, |best: Option<(usize, f64)>, (i, d)| if best.is_none_or(|(_, bd)| d > bd) { Some((i, d)) } else { best }); + if let Some((i, d)) = far + && d > eps + { + keep[i] = true; + stack.push((a, i)); + stack.push((i, b)); + } + } + pts.iter().zip(keep).filter_map(|(p, k)| k.then_some(*p)).collect() +} + +/// The document a missing bevels file starts as: one example bevel, a chamfer with a notch. +pub fn starter() -> Document { + let mut doc = Document::new(612.0, 792.0); + doc.title = "Bevels".into(); + let name = "Example Bevel"; + let pts = [Point::new(0.0, 0.0), Point::new(10.0, 40.0), Point::new(55.0, 30.0), Point::new(100.0, 100.0)]; + let art = + Node::path(NodeId(0), PathData::single(SubPath::polyline(&pts, false)), Appearance::basic(Paint::None, Paint::solid(Color::BLACK), 1.0)); + let art = doc.reid(&art); + doc.symbols.push(Symbol { name: name.into(), art: Arc::new(art), dynamic: false }); + let id = doc.alloc_id(); + let instance = Node::new(id, NodeKind::SymbolInstance { symbol: name.into(), xf: Affine::translate((256.0, 346.0)) }); + let layer = doc.layers.first().map(|l| l.id); + let _ = doc.insert(layer, 0, instance); + doc +} + +impl Session { + /// Keep the custom bevels in the file at `path` and read the bevels it holds (none while it is + /// missing; an unreadable file is reported by `threeD.bevels.list`). + pub fn attach_bevels_file(&mut self, path: String) { + self.bevels.path = Some(path); + self.reload_bevels(); + } + + /// Read the bevels file again. + fn reload_bevels(&mut self) { + let Some(path) = self.bevels.path.clone() else { return }; + match read(&path) { + Ok(Some(doc)) => self.bevels.set(bevels_of(&doc)), + Ok(None) => self.bevels.set(Read::default()), + Err(e) => { + self.bevels.set(Read::default()); + self.bevels.error = Some(e); + } + } + } + + /// A document was saved to `path`: when that is the bevels file, its bevels are read back from + /// what was written. + pub(crate) fn bevels_saved(&mut self, path: &str) { + if self.bevels.path.as_deref().is_some_and(|b| same_file(b, path)) { + self.reload_bevels(); + } + } +} + +/// `params` of an effect with `bevel` given as `{custom: name}`: the bevel of the bevels file named +/// so, stored as `bevel` `"custom"` with its `bevelName` and `bevelProfile`. Other values are left +/// for the effect to check. +pub(crate) fn resolve_custom(s: &Session, params: &mut Value, cmd: &str) -> Result<()> { + let Some(Value::Object(o)) = params.get("bevel") else { return Ok(()) }; + let name = match (o.len(), o.get("custom")) { + (1, Some(Value::String(name))) => name.clone(), + _ => return Err(bad(cmd, "bevel: give a shape id, or {custom: name} for a bevel of the bevels file (threeD.bevels.list)")), + }; + let bevel = s.bevels.get(&name).ok_or_else(|| bad(cmd, format!("no custom bevel {name} (see threeD.bevels.list)")))?; + params["bevel"] = json!("custom"); + params[BEVEL_NAME] = json!(bevel.name); + params[BEVEL_PROFILE] = bevel.profile_json(); + Ok(()) +} + +fn has_file(s: &Session) -> std::result::Result<(), String> { + if s.bevels.path.is_some() { Ok(()) } else { Err("no bevels file here".into()) } +} + +fn skipped(s: &Session) -> Vec { + s.bevels.skipped.iter().map(|(name, reason)| json!({"name": name, "reason": reason})).collect() +} + +fn list(s: &mut Session, _: &Value) -> Result { + let bevels: Vec = s.bevels.bevels.iter().map(|b| json!({"name": b.name, "points": b.profile_json()})).collect(); + Ok(json!({"bevels": bevels, "file": s.bevels.path, "skipped": skipped(s), "error": s.bevels.error})) +} + +fn reload(s: &mut Session, _: &Value) -> Result { + const C: &str = "threeD.bevels.reload"; + s.reload_bevels(); + if let Some(e) = &s.bevels.error { + return Err(bad(C, e.clone())); + } + Ok(json!({"count": s.bevels.bevels.len(), "skipped": skipped(s)})) +} + +fn edit(s: &mut Session, _: &Value) -> Result { + const C: &str = "threeD.bevels.edit"; + let path = s.bevels.path.clone().ok_or_else(|| bad(C, "no bevels file here"))?; + if let Some(dir) = std::path::Path::new(&path).parent() { + std::fs::create_dir_all(dir).map_err(|e| bad(C, format!("{}: {e}", dir.display())))?; + } + // Made only when no file is there, also when another run makes one at the same moment. + let bytes = vectorcraft_format::save_file(&starter()); + let created = match crate::file_access::unconfined(|| super::fileio::write_new_file(&path, &bytes)) { + Ok(()) => true, + Err(_) if std::path::Path::new(&path).exists() => false, + Err(e) => return Err(bad(C, e.to_string())), + }; + if created { + s.reload_bevels(); + } + // Already open: that document comes to the front. + let open = s.documents().iter().position(|st| st.path.as_deref().is_some_and(|p| same_file(p, &path))); + match open { + Some(i) => { + s.set_active(i); + } + None => { + crate::file_access::unconfined(|| s.execute("document.open", &json!({ "path": path })))?; + } + } + Ok(json!({"path": path, "created": created})) +} diff --git a/crates/engine/src/cmd/effectcmd.rs b/crates/engine/src/cmd/effectcmd.rs index b570ce332a..be410f6d25 100644 --- a/crates/engine/src/cmd/effectcmd.rs +++ b/crates/engine/src/cmd/effectcmd.rs @@ -427,6 +427,10 @@ pub(crate) fn apply(s: &mut Session, p: &Value) -> Result { if texture_load_effect(id) { load_texture(&mut params, C)?; } + // A custom bevel by name takes a copy of its points from the bevels file. + if bevel_effect(id) { + super::bevels::resolve_custom(s, &mut params, C)?; + } // An SVG filter needs its element, and is named by its id. if id == effects::SVG_FILTER { let xml = params.get("xml").and_then(Value::as_str).ok_or_else(|| bad(C, "give `xml`, one SVG element"))?; @@ -718,6 +722,9 @@ fn set_params(s: &mut Session, p: &Value) -> Result { if edited.iter().any(|e| texture_load_effect(e)) { load_texture(&mut params, C)?; } + if edited.iter().any(|e| bevel_effect(e)) || kind == Some(effects::EXTRUDE) { + super::bevels::resolve_custom(s, &mut params, C)?; + } let targets = effect_targets(s, p, item, index, C)?; // The type each 3D effect already has, with nothing else to change, is no edit (and is not // checked again). @@ -798,6 +805,12 @@ fn set_params(s: &mut Session, p: &Value) -> Result { Ok(json!({ "ids": ids_json(&ids) })) } +/// Does effect `id` take a `bevel` (Extrude & Bevel, Extrude & Bevel (Classic)), which may be a +/// custom bevel given by name? +fn bevel_effect(id: &str) -> bool { + id == effects::EXTRUDE || id == effects::CLASSIC_EXTRUDE +} + // ---------- Load Texture ---------- /// Effect › Distort › Glass. diff --git a/crates/engine/src/cmd/fileio/save.rs b/crates/engine/src/cmd/fileio/save.rs index e1cbf68bf2..4e67063c9c 100644 --- a/crates/engine/src/cmd/fileio/save.rs +++ b/crates/engine/src/cmd/fileio/save.rs @@ -1032,7 +1032,8 @@ impl SaveJob { } // The other open documents that place this one show the new version. let written = self.plan.path.clone().filter(|_| matches!(self.plan.format.id, "vectorcraft" | "template")); - // A save of the arrowheads file lists its heads in the arrowhead menus. + // A save of the arrowheads file lists its heads in the arrowhead menus, and one of the + // bevels file its bevels in the Bevel Shape menus. let native = self.plan.format.id == "vectorcraft"; if let Some(st) = s.document_mut(uid) { self.finish(st); @@ -1043,6 +1044,7 @@ impl SaveJob { if let Some(path) = written { if native { s.arrowheads_saved(&path); + s.bevels_saved(&path); } crate::cmd::links::refresh_placed(s, uid, &path); } diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index a891fb9599..214d3279f8 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -153,6 +153,8 @@ pub struct Session { pub brush_libraries: cmd::brushlib::Libraries, /// The custom arrowheads of the arrowheads file (`stroke.arrowheads.*`); none without one. pub arrowheads: cmd::arrowheads::Arrowheads, + /// The custom bevels of the bevels file (`threeD.bevels.*`); none without one. + pub bevels: cmd::bevels::Bevels, /// The id each loaded library outside a request's read roots has been shown under, by its own id /// ([`cmd::swatchlib::concealed_library_ids`]), kept for the session. shown_library_ids: std::sync::Mutex>, diff --git a/crates/engine/src/session/documents.rs b/crates/engine/src/session/documents.rs index 3e9ae56423..7b200af6bb 100644 --- a/crates/engine/src/session/documents.rs +++ b/crates/engine/src/session/documents.rs @@ -81,6 +81,7 @@ impl Session { symbol_libraries: Default::default(), brush_libraries: Default::default(), arrowheads: Default::default(), + bevels: Default::default(), shown_library_ids: Default::default(), libraries: Default::default(), pdf_preset_dir: None, diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 18eadcdf80..d3d6046f89 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -14,6 +14,7 @@ mod assets; mod assets_3d; mod attributes; mod bboxrotate; +mod bevels; mod blendfidelity; mod blendopts; mod blendspine; diff --git a/crates/engine/src/tests/bevels.rs b/crates/engine/src/tests/bevels.rs new file mode 100644 index 0000000000..4540ae9654 --- /dev/null +++ b/crates/engine/src/tests/bevels.rs @@ -0,0 +1,217 @@ +//! Custom bevels (`cmd/bevels.rs`): bevels read from the bevels file's symbols, listed, set on +//! Extrude & Bevel and Extrude & Bevel (Classic) by name, reloaded when the file is saved, and kept +//! with the documents that use them. + +use std::sync::Arc; + +use serde_json::{Value, json}; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_doc::{Appearance, Document, Node, Symbol}; +use vectorcraft_geom::{Anchor, PathData, Point, SubPath}; +use vectorcraft_render::effects; + +use crate::cmd::bevels::{self, bevels_of}; +use crate::*; + +fn line(pts: &[(f64, f64)], closed: bool) -> Node { + let pts: Vec = pts.iter().map(|&(x, y)| Point::new(x, y)).collect(); + Node::path(NodeId(0), PathData::single(SubPath::polyline(&pts, closed)), Appearance::basic(Paint::None, Paint::solid(Color::BLACK), 1.0)) +} + +fn add_symbol(d: &mut Document, name: &str, art: Node) { + let art = d.reid(&art); + d.symbols.push(Symbol { name: name.into(), art: Arc::new(art), dynamic: false }); +} + +/// A folder of its own for test `name`, emptied. +fn folder(name: &str) -> std::path::PathBuf { + let dir = std::env::temp_dir().join(format!("vectorcraft-bevels-{name}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + dir +} + +fn close(a: (f64, f64), b: (f64, f64)) -> bool { + (a.0 - b.0).abs() < 1e-9 && (a.1 - b.1).abs() < 1e-9 +} + +#[test] +fn each_open_path_symbol_is_a_bevel_from_its_first_anchor_to_its_last() { + let mut d = Document::new(100.0, 100.0); + add_symbol(&mut d, "Notch", line(&[(0.0, 0.0), (20.0, 60.0), (70.0, 40.0), (100.0, 100.0)], false)); + // The same path mirrored across the page and drawn from the other side gives the same points. + add_symbol(&mut d, "Mirrored", line(&[(300.0, 50.0), (280.0, 110.0), (230.0, 90.0), (200.0, 150.0)], false)); + // In a group of one, at another size. + let small = line(&[(0.0, 0.0), (2.0, 6.0), (7.0, 4.0), (10.0, 10.0)], false); + add_symbol(&mut d, "Grouped", Node::group(NodeId(0), vec![Arc::new(small)])); + // Points past the ends are held to them. + add_symbol(&mut d, "Overshoot", line(&[(0.0, 0.0), (-20.0, 50.0), (100.0, 120.0), (100.0, 100.0)], false)); + add_symbol(&mut d, "Closed", line(&[(0.0, 0.0), (10.0, 0.0), (10.0, 10.0)], true)); + let two = Node::group(NodeId(0), vec![Arc::new(line(&[(0.0, 0.0), (1.0, 1.0)], false)), Arc::new(line(&[(0.0, 0.0), (1.0, 1.0)], false))]); + add_symbol(&mut d, "Two paths", two); + add_symbol(&mut d, "Upright", line(&[(0.0, 0.0), (5.0, 50.0), (0.0, 100.0)], false)); + let dense: Vec<(f64, f64)> = (0..=bevels::MAX_ANCHORS).map(|i| (i as f64, i as f64)).collect(); + add_symbol(&mut d, "Dense", line(&dense, false)); + add_symbol(&mut d, "Notch", line(&[(0.0, 0.0), (1.0, 1.0)], false)); + let read = bevels_of(&d); + let names: Vec<&str> = read.bevels.iter().map(|b| b.name.as_str()).collect(); + assert_eq!(names, ["Notch", "Mirrored", "Grouped", "Overshoot"]); + let notch = [(0.0, 0.0), (0.2, 0.6), (0.7, 0.4), (1.0, 1.0)]; + for b in &read.bevels[..3] { + assert_eq!(b.points.len(), 4, "{}", b.name); + assert!(b.points.iter().zip(notch).all(|(&a, b)| close(a, b)), "{}: {:?}", b.name, b.points); + } + assert!(close(read.bevels[3].points[1], (0.0, 0.5)) && close(read.bevels[3].points[2], (1.0, 1.0)), "{:?}", read.bevels[3].points); + let skipped: Vec<(&str, &str)> = read.skipped.iter().map(|(n, r)| (n.as_str(), r.as_str())).collect(); + assert_eq!( + skipped, + [ + ("Closed", "its art is not one open path"), + ("Two paths", "its art is not one open path"), + ("Upright", "its ends are not apart both across and down"), + ("Dense", "its path has too many anchors for a bevel"), + ("Notch", "another symbol has this name"), + ] + ); +} + +/// A curve is cut into straight lines, and a path of many points keeps the ones that matter, at +/// most 64 in all, ends included. +#[test] +fn curves_and_long_paths_fit_in_the_points_a_bevel_holds() { + let mut d = Document::new(100.0, 100.0); + // A quarter circle from (0, 0) to (100, 100), bulging up and right. + let k = 0.5523 * 100.0; + let mut a = Anchor::corner(Point::new(0.0, 0.0)); + a.h_out = Point::new(k, 0.0); + let mut b = Anchor::corner(Point::new(100.0, 100.0)); + b.h_in = Point::new(100.0, 100.0 - k); + let arc = Node::path(NodeId(0), PathData::single(SubPath::new(vec![a, b], false)), Appearance::default()); + add_symbol(&mut d, "Arc", arc); + let wavy: Vec<(f64, f64)> = (0..=3000).map(|i| (i as f64 / 30.0, i as f64 / 30.0 + 5.0 * (i as f64 / 50.0).sin())).collect(); + add_symbol(&mut d, "Wavy", line(&wavy, false)); + let read = bevels_of(&d); + assert!(read.skipped.is_empty(), "{:?}", read.skipped); + for b in &read.bevels { + assert!((3..=effects::BevelProfile::MAX_POINTS).contains(&b.points.len()), "{}: {}", b.name, b.points.len()); + assert!(close(b.points[0], (0.0, 0.0)) && close(*b.points.last().unwrap(), (1.0, 1.0)), "{}", b.name); + assert!(effects::BevelProfile::new(&b.points).is_some(), "{}", b.name); + } + // The arc's points lie on the circle: across first, then down. + let arc = &read.bevels[0]; + assert!(arc.points.iter().all(|&(x, y)| (((x - 0.0).powi(2) + (y - 1.0).powi(2)).sqrt() - 1.0).abs() < 0.01), "{:?}", arc.points); +} + +fn rect(s: &mut Session, x: u32) -> NodeId { + NodeId(s.execute("shape.rectangle", &json!({"x": x, "y": 100, "width": 60, "height": 60})).unwrap()["id"].as_u64().unwrap()) +} + +fn params(s: &Session, id: NodeId) -> Value { + s.doc().unwrap().doc.node(id).unwrap().appearance.effects[0].params.clone() +} + +#[test] +fn the_bevels_file_is_made_opened_and_reloaded_when_saved() { + let dir = folder("edit"); + let file = dir.join(bevels::FILE_NAME).to_string_lossy().to_string(); + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap(); + let id = rect(&mut s, 20); + s.attach_bevels_file(file.clone()); + let list = s.execute("threeD.bevels.list", &json!({})).unwrap(); + assert_eq!((list["bevels"].as_array().unwrap().len(), list["file"].as_str()), (0, Some(file.as_str()))); + let apply = json!({"effect": effects::EXTRUDE, "ids": [id.0], "item": null, "params": {"bevel": {"custom": "Example Bevel"}}}); + assert!(s.execute("effect.apply", &apply).unwrap_err().to_string().contains("no custom bevel Example Bevel")); + let r = s.execute("threeD.bevels.edit", &json!({})).unwrap(); + assert_eq!(r["created"], true); + assert_eq!(s.doc().unwrap().path.as_deref(), Some(file.as_str()), "the file is the active document"); + let list = s.execute("threeD.bevels.list", &json!({})).unwrap(); + assert_eq!(list["bevels"][0]["name"], "Example Bevel"); + assert_eq!(list["bevels"][0]["points"].as_array().unwrap().len(), 4); + // A second bevel drawn in the file is listed once the file is saved. + let st = s.doc_mut().unwrap(); + add_symbol(Arc::make_mut(&mut st.doc), "Steps", line(&[(0.0, 0.0), (0.0, 50.0), (50.0, 50.0), (50.0, 100.0), (100.0, 100.0)], false)); + assert_eq!(s.execute("threeD.bevels.list", &json!({})).unwrap()["bevels"].as_array().unwrap().len(), 1); + s.execute("document.save", &json!({})).unwrap(); + let list = s.execute("threeD.bevels.list", &json!({})).unwrap(); + let names: Vec<&str> = list["bevels"].as_array().unwrap().iter().filter_map(|b| b["name"].as_str()).collect(); + assert_eq!(names, ["Example Bevel", "Steps"]); + assert_eq!(s.execute("threeD.bevels.reload", &json!({})).unwrap()["count"], 2); + // Editing again brings the open file to the front, without making it anew. + s.execute("document.activate", &json!({"index": 0})).unwrap(); + assert_eq!(s.execute("threeD.bevels.edit", &json!({})).unwrap()["created"], false); + assert_eq!(s.documents().len(), 2); + // The rectangle takes the bevel with a copy of its points, in both Extrude & Bevels. + s.execute("document.activate", &json!({"index": 0})).unwrap(); + s.execute("effect.apply", &json!({"effect": effects::EXTRUDE, "ids": [id.0], "item": null, "params": {"bevel": {"custom": "Steps"}}})).unwrap(); + let p = params(&s, id); + assert_eq!((p["bevel"].as_str(), p[effects::BEVEL_NAME].as_str()), (Some("custom"), Some("Steps"))); + assert_eq!(p[effects::BEVEL_PROFILE], json!([[0.0, 0.0], [0.0, 0.5], [0.5, 0.5], [0.5, 1.0], [1.0, 1.0]])); + let set = |bevel: Value| json!({"ids": [id.0], "index": 0, "item": null, "params": {"bevel": bevel}}); + s.execute("effect.setParams", &set(json!({"custom": "Example Bevel"}))).unwrap(); + assert_eq!(params(&s, id)[effects::BEVEL_NAME], "Example Bevel"); + for bad in [json!({"custom": 3}), json!({"custom": "Nope"}), json!({"name": "Steps"})] { + let undo = s.doc().unwrap().history.undo.len(); + assert!(s.execute("effect.setParams", &set(bad.clone())).is_err(), "{bad}"); + assert_eq!(s.doc().unwrap().history.undo.len(), undo, "{bad}: no undo step"); + } + let classic = rect(&mut s, 200); + s.execute( + "effect.apply", + &json!({"effect": effects::CLASSIC_EXTRUDE, "ids": [classic.0], "item": null, "params": {"bevel": {"custom": "Steps"}}}), + ) + .unwrap(); + assert_eq!(params(&s, classic)[effects::BEVEL_NAME], "Steps"); + // A built-in shape again draws that shape. + s.execute("effect.setParams", &set(json!("rounded"))).unwrap(); + assert!(matches!(effects::extrude_options(¶ms(&s, id)).bevel.map(|b| b.shape.id()), Some("rounded"))); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn a_document_keeps_its_custom_bevels_without_the_bevels_file() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 300, "height": 300})).unwrap(); + let id = rect(&mut s, 100); + let notch = json!([[0, 0], [0.2, 0.6], [0.7, 0.4], [1, 1]]); + let custom = json!({"bevel": "custom", "bevelName": "Notch", "bevelProfile": notch, "bevelWidth": 12, "bevelHeight": 12}); + s.execute("effect.apply", &json!({"effect": effects::EXTRUDE, "ids": [id.0], "item": null, "params": custom})).unwrap(); + let ink = |s: &Session| { + vectorcraft_render::Renderer::new().render(&s.doc().unwrap().doc, 300, 300, vectorcraft_geom::Affine::IDENTITY, &Default::default()) + }; + let with_bevel = ink(&s); + // Saved and opened in a session that has no bevels file: the bevel is drawn the same. + let saved = s.execute("document.export", &json!({"format": "vectorcraft"})).unwrap()["dataBase64"].clone(); + let mut o = Session::new(); + o.execute("document.open", &json!({"name": "a.vectorcraft", "dataBase64": saved})).unwrap(); + assert_eq!(params(&o, id)[effects::BEVEL_PROFILE], params(&s, id)[effects::BEVEL_PROFILE]); + assert_eq!(ink(&o).pixels, with_bevel.pixels); + // The classic chamfer draws differently. + let set = json!({"ids": [id.0], "index": 0, "item": null, "params": {"bevel": "classic"}}); + o.execute("effect.setParams", &set).unwrap(); + assert_ne!(ink(&o).pixels, with_bevel.pixels); + o.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(ink(&o).pixels, with_bevel.pixels); + // Points that do not make a bevel are refused before the document changes. + let bad = json!({"ids": [id.0], "index": 0, "item": null, "params": {"bevelProfile": [[0, 0], [0.5, 2], [1, 1]]}}); + assert!(o.execute("effect.setParams", &bad).unwrap_err().to_string().contains("bevelProfile must be")); +} + +#[test] +fn without_a_bevels_file_editing_is_refused_and_none_are_listed() { + let mut s = Session::new(); + s.execute("file.new", &json!({})).unwrap(); + let list = s.execute("threeD.bevels.list", &json!({})).unwrap(); + assert_eq!((list["bevels"].as_array().unwrap().len(), &list["file"]), (0, &Value::Null)); + assert!(s.execute("threeD.bevels.edit", &json!({})).is_err()); + assert!(s.execute("threeD.bevels.reload", &json!({})).is_err()); + // A file that is not a document lists no bevels and says why. + let dir = folder("unreadable"); + let file = dir.join(bevels::FILE_NAME); + std::fs::write(&file, b"not a document").unwrap(); + s.attach_bevels_file(file.to_string_lossy().to_string()); + let list = s.execute("threeD.bevels.list", &json!({})).unwrap(); + assert!(list["error"].is_string(), "{list}"); + assert!(s.execute("threeD.bevels.reload", &json!({})).is_err()); + let _ = std::fs::remove_dir_all(&dir); +} diff --git a/crates/three-d/src/lib.rs b/crates/three-d/src/lib.rs index 2d945c1439..10fd08ca00 100644 --- a/crates/three-d/src/lib.rs +++ b/crates/three-d/src/lib.rs @@ -8,7 +8,7 @@ mod solid; mod visibility; -pub use solid::{Bevel, BevelShape, Extrude, Facet, Inflate, View, extrude, inflate, inflate_together, plane}; +pub use solid::{Bevel, BevelProfile, BevelShape, Extrude, Facet, Inflate, View, extrude, inflate, inflate_together, plane}; pub use visibility::{VisibleFace, visible_faces}; mod shading; pub use shading::{ClassicShading, ClassicSurface, LightGradient, RgbGradient, ShadeGradient}; diff --git a/crates/three-d/src/solid.rs b/crates/three-d/src/solid.rs index 18c9959b19..30a65781d4 100644 --- a/crates/three-d/src/solid.rs +++ b/crates/three-d/src/solid.rs @@ -105,6 +105,8 @@ impl View { } /// The shape of a bevel's cross-section, from the cap's edge (0) to the side wall (1). +// A custom profile takes 258 bytes; an extrusion copies its bevel a few times. +#[allow(clippy::large_enum_variant)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum BevelShape { /// A straight 45° chamfer when width and height are equal. @@ -118,11 +120,73 @@ pub enum BevelShape { Step, /// A convex then concave S curve. Ogee, + /// A cross-section of the user's own, drawn as an open path ([`BevelProfile`]). + Custom(BevelProfile), +} + +/// A custom bevel's cross-section: points from the cap's edge, (0, 0), to the side wall, (1, 1), +/// each a (share of the width, share of the height) pair in 0..1, joined by straight lines. The +/// shares are kept to 1/32,768 in a fixed array, so the profile is `Copy` like the built-in shapes. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct BevelProfile { + points: [(u16, u16); BevelProfile::MAX_POINTS], + len: u8, +} + +impl BevelProfile { + /// The most points a profile holds. + pub const MAX_POINTS: usize = 64; + + /// A profile of `points`, or `None` unless there are 2 to [`Self::MAX_POINTS`] of them, every + /// share is a number in 0..1, and they start at (0, 0) and end at (1, 1). + pub fn new(points: &[(f64, f64)]) -> Option { + const END: f64 = 1e-6; + if !(2..=Self::MAX_POINTS).contains(&points.len()) || points.iter().any(|&(x, y)| !(0.0..=1.0).contains(&x) || !(0.0..=1.0).contains(&y)) { + return None; + } + let (first, last) = (points[0], points[points.len() - 1]); + if first.0 > END || first.1 > END || last.0 < 1.0 - END || last.1 < 1.0 - END { + return None; + } + let mut out = Self { points: [(0, 0); Self::MAX_POINTS], len: points.len() as u8 }; + let share = |v: f64| (v * f64::from(Self::ONE)).round() as u16; + for (slot, &(x, y)) in out.points.iter_mut().zip(points) { + *slot = (share(x), share(y)); + } + out.points[0] = (0, 0); + out.points[points.len() - 1] = (Self::ONE, Self::ONE); + Some(out) + } + + /// A whole share in the stored points: shares are kept to 1/32,768, so halves and quarters + /// stay exact. + const ONE: u16 = 1 << 15; + + /// The points, as (share of the width, share of the height). + pub fn points(&self) -> impl Iterator + '_ { + let share = |v: u16| f64::from(v) / f64::from(Self::ONE); + self.points[..usize::from(self.len)].iter().map(move |&(x, y)| (share(x), share(y))) + } + + /// The point at `s` (0..1), the points spread evenly along `s` and joined by straight lines. + fn at(&self, s: f64) -> (f64, f64) { + // A profile holds at least two points (`new`). + let len = usize::from(self.len).max(2); + let share = |v: u16| f64::from(v) / f64::from(Self::ONE); + let k = s * (len - 1) as f64; + let i = (k.floor() as usize).min(len - 2); + let f = k - i as f64; + let (a, b) = (self.points[i], self.points[i + 1]); + let (ax, ay, bx, by) = (share(a.0), share(a.1), share(b.0), share(b.1)); + (ax + (bx - ax) * f, ay + (by - ay) * f) + } } impl BevelShape { + /// The built-in shapes. pub const ALL: [BevelShape; 5] = [Self::Classic, Self::Rounded, Self::Cove, Self::Step, Self::Ogee]; + /// The shape's parameter value; `custom` for a [`BevelShape::Custom`] one. pub fn id(self) -> &'static str { match self { Self::Classic => "classic", @@ -130,9 +194,11 @@ impl BevelShape { Self::Cove => "cove", Self::Step => "step", Self::Ogee => "ogee", + Self::Custom(_) => "custom", } } + /// The built-in shape named `s`. pub fn parse(s: &str) -> Option { Self::ALL.into_iter().find(|b| b.id() == s) } @@ -142,6 +208,7 @@ impl BevelShape { let s = s.clamp(0.0, 1.0); let q = s * std::f64::consts::FRAC_PI_2; match self { + Self::Custom(profile) => profile.at(s), Self::Classic => (s, s), Self::Rounded => (1.0 - q.cos(), q.sin()), Self::Cove => (q.sin(), 1.0 - q.cos()), @@ -169,6 +236,11 @@ impl BevelShape { match self { Self::Classic => vec![0.0, 1.0], Self::Step => vec![0.0, 0.25, 0.5, 0.75, 1.0], + // Each of its points, where the straight lines between them turn. + Self::Custom(profile) => { + let last = (usize::from(profile.len) - 1) as f64; + (0..usize::from(profile.len)).map(|i| i as f64 / last).collect() + } _ => (0..=8).map(|i| f64::from(i) / 8.0).collect(), } } diff --git a/crates/three-d/src/solid/tests.rs b/crates/three-d/src/solid/tests.rs index be887180b2..fc6c2dd25e 100644 --- a/crates/three-d/src/solid/tests.rs +++ b/crates/three-d/src/solid/tests.rs @@ -198,6 +198,40 @@ fn bevel_shapes_repeats_and_both_sides_change_the_surface() { } } +/// A custom bevel's points are its cross-section, joined by straight lines: two points make the +/// classic chamfer, and the step shape's points make the step shape's solid. Other points change +/// the surface. A profile must run from (0, 0) to (1, 1) with every share in 0..1. +#[test] +fn custom_bevel_profiles_shape_the_bevel() { + let (p, b) = shape(&square(0.0, 0.0, 100.0)); + let v = View { rotation_x: -20.0, rotation_y: 30.0, ..front() }; + let solid = |shape: BevelShape| { + let bevel = Bevel { shape, width: 12.0, height: 12.0, repeat: 2, space: 0.2, both_sides: true, ..Bevel::default() }; + extrude(&p, FillRule::EvenOdd, b, Extrude { bevel: Some(bevel), ..Extrude::default() }, v).unwrap() + }; + let custom = |pts: &[(f64, f64)]| BevelShape::Custom(BevelProfile::new(pts).unwrap()); + assert_eq!(solid(custom(&[(0.0, 0.0), (1.0, 1.0)])), solid(BevelShape::Classic)); + let step = [(0.0, 0.0), (0.0, 0.5), (0.5, 0.5), (0.5, 1.0), (1.0, 1.0)]; + assert_eq!(solid(custom(&step)), solid(BevelShape::Step)); + let notch = custom(&[(0.0, 0.0), (0.2, 0.6), (0.7, 0.4), (1.0, 1.0)]); + assert_ne!(solid(notch), solid(BevelShape::Classic)); + assert_eq!(notch.id(), "custom"); + assert_eq!(BevelShape::parse("custom"), None); + assert_eq!(notch.at(0.0), (0.0, 0.0)); + assert_eq!(notch.at(1.0), (1.0, 1.0)); + // The point a third of the way along is the second point, kept to 1/32,768. + let (x, y) = notch.at(1.0 / 3.0); + assert!(close(x, 0.2, 1e-4) && close(y, 0.6, 1e-4), "{x}, {y}"); + // Inside, the bevel carves the shape with the same points. + let inside = Bevel { shape: notch, width: 12.0, height: 12.0, inside: true, ..Bevel::default() }; + assert!(extrude(&p, FillRule::EvenOdd, b, Extrude { bevel: Some(inside), ..Extrude::default() }, v).is_ok()); + let too_many = vec![(0.5, 0.5); BevelProfile::MAX_POINTS + 1]; + for bad in [&[(0.0, 0.0)][..], &[(0.1, 0.0), (1.0, 1.0)], &[(0.0, 0.0), (1.0, 0.9)], &[(0.0, 0.0), (1.2, 0.5), (1.0, 1.0)], &too_many] { + assert_eq!(BevelProfile::new(bad), None, "{bad:?}"); + } + assert!(BevelProfile::new(&[(0.0, 0.0), (f64::NAN, 0.5), (1.0, 1.0)]).is_none()); +} + #[test] fn holes_stay_holes_in_the_caps_and_get_walls_of_their_own() { let mut b = square(0.0, 0.0, 100.0); diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs index c7a306887e..8ecda502bd 100644 --- a/crates/ui-egui/src/dialogs/revolve.rs +++ b/crates/ui-egui/src/dialogs/revolve.rs @@ -6,7 +6,7 @@ use egui::{Align2, FontId, Id, Pos2, Sense, Stroke, vec2}; use serde_json::{Value, json}; use vectorcraft_doc::Unit; -use vectorcraft_effects::{CLASSIC_EXTRUDE, CLASSIC_REVOLVE, EXTRUDE, INFLATE, REVOLVE, ROTATION_PRESETS}; +use vectorcraft_effects::{BEVEL_NAME, BEVEL_PROFILE, CLASSIC_EXTRUDE, CLASSIC_REVOLVE, EXTRUDE, INFLATE, REVOLVE, ROTATION_PRESETS}; use crate::state::Dialog; use crate::theme::Tokens; @@ -178,11 +178,11 @@ fn solid_controls(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, id: & } else if object && d.str("__tab") != "rotation" { let unit = app.session.general_unit(); if id == CLASSIC_EXTRUDE { - super::three_d_classic::object_controls(ui, d, unit); + super::three_d_classic::object_controls(app, ui, d, unit); } else if id == CLASSIC_REVOLVE { super::three_d_classic::revolve_controls(ui, d, unit); } else if id == EXTRUDE { - extrude_controls(ui, d, unit); + extrude_controls(app, ui, d, unit); } else { heading(ui, tl!("Object")); number(ui, d, "depth", tl!("Depth"), (0.0, 2000.0), "", 1, Some(unit)); @@ -197,8 +197,73 @@ fn solid_controls(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, id: & } } +/// The Bevel Shape menu of Extrude & Bevel and Extrude & Bevel (Classic) (`effect`): None and the +/// built-in shapes, then the custom bevels of the bevels file, and the effect's own custom bevel +/// when the file does not list it (a document from elsewhere carries its points). Picking a +/// custom bevel stores its name and a copy of its points. In the 3D and Materials panel, Edit +/// Bevels… opens the bevels file (`__editBevels`, which the panel runs). +pub(super) fn bevel_choice(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, effect: &str) { + const KEY: &str = "bevel"; + // (shown label, value, the custom bevel's name and points). The built-in labels are + // translated; custom bevels show their names as they are. + type Choice = (String, Value, Option<(String, Value)>); + let mut options: Vec = super::effect::own_choices(effect, KEY, false) + .unwrap_or_default() + .into_iter() + .map(|(label, value)| (tl!(label).to_string(), json!(value), None)) + .collect(); + let builtin = options.len(); + for b in app.session.bevels.bevels() { + options.push((b.name.clone(), json!("custom"), Some((b.name.clone(), b.profile_json())))); + } + let name = d.fields.get(BEVEL_NAME).and_then(Value::as_str).unwrap_or_default().to_string(); + let points = d.fields.get(BEVEL_PROFILE).filter(|v| !v.is_null()).cloned(); + let custom = d.fields.get(KEY).and_then(Value::as_str) == Some("custom"); + let is = |c: &Option<(String, Value)>| c.as_ref().is_some_and(|(n, p)| *n == name && Some(p) == points.as_ref()); + // The effect's own custom bevel, unless the file lists it by name with the same points. + let own = custom && !options[builtin..].iter().any(|(_, _, c)| is(c)); + if own && let Some(p) = &points { + let shown = if name.is_empty() { tl!("Custom").to_string() } else { name.clone() }; + options.push((shown, json!("custom"), Some((name.clone(), p.clone())))); + } + let default = vectorcraft_effects::default_params(effect).and_then(|p| p.get(KEY).cloned()).unwrap_or(Value::Null); + let mixed = d.fields.get(KEY).is_some_and(Value::is_null); + let value = d.fields.get(KEY).filter(|v| !v.is_null()).cloned().unwrap_or_else(|| default.clone()); + let current = if custom { + options[builtin..].iter().position(|(_, _, c)| is(c)).map(|i| i + builtin) + } else { + options[..builtin].iter().position(|(_, v, _)| *v == value) + }; + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 6.0; + label(ui, tl!("Bevel Shape")); + let labels: Vec<&str> = options.iter().map(|(l, _, _)| l.as_str()).collect(); + let shown = current.and_then(|i| labels.get(i)).copied().unwrap_or(""); + let width = VALUE_W + rail_width(ui) + 6.0; + if let Some(k) = widgets::dropdown_names(ui, ("three-d-choice", KEY), shown, &labels, width) + && let Some((_, v, c)) = options.get(k) + { + d.fields.insert(KEY.into(), v.clone()); + if let Some((n, p)) = c { + d.fields.insert(BEVEL_NAME.into(), json!(n)); + d.fields.insert(BEVEL_PROFILE.into(), p.clone()); + } + } + let default_label = options.iter().find(|(_, v, _)| *v == default).map_or("", |(l, _, _)| l.as_str()); + if reset_dot(ui, KEY, mixed || value != default, default_label) { + d.fields.insert(KEY.into(), default.clone()); + } + }); + if d.bool("__panel") { + let enabled = app.session.bevels.path().is_some(); + if ui.add_enabled(enabled, egui::Button::new(tl!("Edit Bevels…"))).clicked() { + d.fields.insert("__editBevels".into(), json!(true)); + } + } +} + /// Extrude & Bevel's depth, twist, taper, cap and bevel. -fn extrude_controls(ui: &mut egui::Ui, d: &mut Dialog, unit: Unit) { +fn extrude_controls(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, unit: Unit) { heading(ui, tl!("Object")); number(ui, d, "depth", tl!("Depth"), (0.0, 2000.0), "", 1, Some(unit)); number(ui, d, "twist", tl!("Twist"), (0.0, 360.0), "°", 1, None); @@ -206,9 +271,7 @@ fn extrude_controls(ui: &mut egui::Ui, d: &mut Dialog, unit: Unit) { choice(ui, d, "cap", c3("Cap"), &[(json!(true), c3("Solid")), (json!(false), c3("Hollow"))]); ui.add_space(10.0); heading(ui, c3("Bevel")); - let shapes: Vec<(Value, &str)> = - super::effect::own_choices(EXTRUDE, "bevel", false).unwrap_or_default().into_iter().map(|(label, value)| (json!(value), label)).collect(); - choice(ui, d, "bevel", tl!("Bevel Shape"), &shapes); + bevel_choice(app, ui, d, EXTRUDE); ui.add_enabled_ui(d.str("bevel") != "none", |ui| { number(ui, d, "bevelWidth", tl!("Width"), (0.0, 1000.0), "", 1, Some(unit)); number(ui, d, "bevelHeight", tl!("Height"), (0.0, 1000.0), "", 1, Some(unit)); diff --git a/crates/ui-egui/src/dialogs/three_d_classic.rs b/crates/ui-egui/src/dialogs/three_d_classic.rs index a3857c914a..5d9070e17c 100644 --- a/crates/ui-egui/src/dialogs/three_d_classic.rs +++ b/crates/ui-egui/src/dialogs/three_d_classic.rs @@ -11,15 +11,15 @@ 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; -/// Depth and cap, then the bevel: its shape, its height and whether it is added around the shape -/// or carved into it. -pub(super) fn object_controls(ui: &mut egui::Ui, d: &mut Dialog, unit: Unit) { +/// Depth and cap, then the bevel: its shape (a custom one included), its height and whether it is +/// added around the shape or carved into it. +pub(super) fn object_controls(app: &crate::VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, unit: Unit) { heading(ui, tl!("Object")); number(ui, d, "depth", tl!("Depth"), (0.0, 2000.0), "", 1, Some(unit)); choice(ui, d, "cap", c3("Cap"), &[(json!(true), c3("Solid")), (json!(false), c3("Hollow"))]); ui.add_space(10.0); heading(ui, c3("Bevel")); - choice(ui, d, "bevel", tl!("Bevel Shape"), &options("bevel")); + super::revolve::bevel_choice(app, ui, d, CLASSIC_EXTRUDE); ui.add_enabled_ui(d.str("bevel") != "none", |ui| { number(ui, d, "bevelHeight", tl!("Height"), (1.0, 100.0), "", 1, Some(unit)); toggle(ui, d, "bevelInside", tl!("Bevel Inside"), false); @@ -78,11 +78,6 @@ pub(super) fn surface_controls(ui: &mut egui::Ui, d: &mut Dialog) { } } -/// The values of Extrude & Bevel (Classic)'s `key` as the dropdowns list them, (value, label). -fn options(key: &str) -> Vec<(Value, &'static str)> { - options_of(CLASSIC_EXTRUDE, key) -} - /// The values of classic 3D effect `effect`'s `key` as the dropdowns list them, (value, label). fn options_of(effect: &str, key: &str) -> Vec<(Value, &'static str)> { super::effect::own_choices(effect, key, false).unwrap_or_default().into_iter().map(|(label, value)| (json!(value), label)).collect() diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 582a927f09..09041c162f 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -2811,6 +2811,10 @@ digits Malayalam Малаялам Edit Arrowheads Редактиране на върхове на стрелки Edit Arrowheads… Редактиране на върхове на стрелки… Reload Arrowheads Презареждане на върхове на стрелки + Bevels Фаски + Edit Bevels Редактиране на фаски + Edit Bevels… Редактиране на фаски… + Reload Bevels Презареждане на фаски Reset Rotate View Нулиране на изгледа на завъртане Rotate View to Selection Завъртане на изгледа спрямо селекцията Reset the rows to the artwork's colors Нулиране на редовете към цветовете на илюстрацията diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index d92da7ae40..27bcdb5898 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -3900,6 +3900,10 @@ theme Appearance Izgled Edit Arrowheads Uredi vrhove strelica Edit Arrowheads… Uredi vrhove strelica… Reload Arrowheads Ponovo učitaj vrhove strelica + Bevels Zakošenja + Edit Bevels Uredi zakošenja + Edit Bevels… Uredi zakošenja… + Reload Bevels Ponovo učitaj zakošenja Stroke Options Opcije poteza Width Profiles Profili širine Apply Graphic Style Primijeni grafički stil diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 283dae1800..21ac37e77c 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -3593,6 +3593,10 @@ digits Malayalam Malaiàlam Edit Arrowheads Edita les puntes de fletxa Edit Arrowheads… Edita les puntes de fletxa… Reload Arrowheads Torna a carregar les puntes de fletxa + Bevels Bisells + Edit Bevels Edita els bisells + Edit Bevels… Edita els bisells… + Reload Bevels Torna a carregar els bisells Reset Rotate View Restableix la rotació de la vista Reset Ruler Origin Restableix l’origen de les regles Reset the rows to the artwork's colors Restableix les files als colors de l’obra diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 519963c4eb..f368ced92f 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3956,6 +3956,10 @@ theme Appearance Motiv Edit Arrowheads Upravit šipky Edit Arrowheads… Upravit šipky… Reload Arrowheads Znovu načíst šipky + Bevels Zkosení + Edit Bevels Upravit zkosení + Edit Bevels… Upravit zkosení… + Reload Bevels Znovu načíst zkosení Stroke Options Možnosti tahu Width Profiles Profily šířky Apply Graphic Style Použít grafický styl diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 3269755003..5df91a764d 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3675,6 +3675,10 @@ theme Appearance Udseende Edit Arrowheads Redigér pilespidser Edit Arrowheads… Redigér pilespidser… Reload Arrowheads Genindlæs pilespidser + Bevels Facetter + Edit Bevels Redigér facetter + Edit Bevels… Redigér facetter… + Reload Bevels Genindlæs facetter Stroke Options Konturindstillinger Width Profiles Breddeprofiler Apply Graphic Style Anvend grafikstil diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index f3858abc1f..4b4656cd6e 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2856,6 +2856,10 @@ digits Malayalam Malayalam Edit Arrowheads Pfeilspitzen bearbeiten Edit Arrowheads… Pfeilspitzen bearbeiten… Reload Arrowheads Pfeilspitzen neu laden + Bevels Abgeflachte Kanten + Edit Bevels Abgeflachte Kanten bearbeiten + Edit Bevels… Abgeflachte Kanten bearbeiten… + Reload Bevels Abgeflachte Kanten neu laden Rotate View Ansicht drehen Reset Rotate View Ansichtsdrehung zurücksetzen Rotate View to Selection Ansicht nach Auswahl drehen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 52a12276f7..6742463f69 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3496,6 +3496,10 @@ digits Malayalam Μαλαγιάλαμ Edit Arrowheads Επεξεργασία αιχμών βελών Edit Arrowheads… Επεξεργασία αιχμών βελών… Reload Arrowheads Επαναφόρτωση αιχμών βελών + Bevels Λοξοτμήσεις + Edit Bevels Επεξεργασία λοξοτμήσεων + Edit Bevels… Επεξεργασία λοξοτμήσεων… + Reload Bevels Επαναφόρτωση λοξοτμήσεων Reset Rotate View Επαναφορά περιστροφής προβολής Rotate View to Selection Περιστροφή προβολής ως προς την επιλογή Reset the rows to the artwork's colors Επαναφορά γραμμών στα χρώματα του σχεδίου diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index e6f77cd908..dcc89cf724 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2890,6 +2890,10 @@ digits Malayalam Malayálam Edit Arrowheads Editar puntas de flecha Edit Arrowheads… Editar puntas de flecha… Reload Arrowheads Volver a cargar puntas de flecha + Bevels Biseles + Edit Bevels Editar biseles + Edit Bevels… Editar biseles… + Reload Bevels Volver a cargar biseles Reset Rotate View Restablecer rotación de vista Rotate View to Selection Rotar vista según la selección Reset the rows to the artwork's colors Restablecer las filas a los colores de la ilustración diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index dc0e432264..fb3975047f 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -3880,6 +3880,10 @@ theme Appearance Ulkoasu Edit Arrowheads Muokkaa nuolenkärkiä Edit Arrowheads… Muokkaa nuolenkärkiä… Reload Arrowheads Lataa nuolenkärjet uudelleen + Bevels Viisteet + Edit Bevels Muokkaa viisteitä + Edit Bevels… Muokkaa viisteitä… + Reload Bevels Lataa viisteet uudelleen Stroke Options Viivan asetukset Width Profiles Leveysprofiilit Apply Graphic Style Käytä grafiikkatyyliä diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 3c74586ef0..d9894d76c6 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2882,6 +2882,10 @@ digits Malayalam Malayalam Edit Arrowheads Modifier les pointes de flèche Edit Arrowheads… Modifier les pointes de flèche… Reload Arrowheads Recharger les pointes de flèche + Bevels Biseaux + Edit Bevels Modifier les biseaux + Edit Bevels… Modifier les biseaux… + Reload Bevels Recharger les biseaux Reset Rotate View Réinitialiser la rotation de l’affichage Rotate View to Selection Faire pivoter l’affichage selon la sélection Reset the rows to the artwork's colors Réinitialiser les lignes avec les couleurs de l’illustration diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 8e1ce7cc2a..6be73ec4a4 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -3921,6 +3921,10 @@ antiAlias Sharp शार्प Edit Arrowheads एरोहेड्स संपादित करें Edit Arrowheads… एरोहेड्स संपादित करें… Reload Arrowheads एरोहेड्स फिर से लोड करें + Bevels बेवल्स + Edit Bevels बेवल्स संपादित करें + Edit Bevels… बेवल्स संपादित करें… + Reload Bevels बेवल्स फिर से लोड करें Reset Rotate View व्यू घुमाएँ रीसेट करें Reset Ruler Origin शासकीय उत्पत्ति रीसेट करें Reset Symbol Instance सिंबल इंस्टेंस रीसेट करें diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 15ce573c11..ee8ee893a5 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3440,6 +3440,10 @@ mark-style Japanese Japán Edit Arrowheads Nyílhegyek szerkesztése Edit Arrowheads… Nyílhegyek szerkesztése… Reload Arrowheads Nyílhegyek újratöltése + Bevels Élletörések + Edit Bevels Élletörések szerkesztése + Edit Bevels… Élletörések szerkesztése… + Reload Bevels Élletörések újratöltése Reset Rotate View Nézetforgatás visszaállítása Rotate View to Selection Nézet elforgatása a kijelöléshez Reset the rows to the artwork's colors Sorok visszaállítása a grafika színeire diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index f68fad0c1c..d1870c3c6e 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3675,6 +3675,10 @@ theme Appearance Tampilan Edit Arrowheads Edit mata panah Edit Arrowheads… Edit mata panah… Reload Arrowheads Muat ulang mata panah + Bevels Bentuk bevel + Edit Bevels Edit bentuk bevel + Edit Bevels… Edit bentuk bevel… + Reload Bevels Muat ulang bentuk bevel Stroke Options Opsi goresan Width Profiles Profil lebar Apply Graphic Style Terapkan gaya grafis diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 480115859b..8548883c63 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2932,6 +2932,10 @@ digits Malayalam Malayalam Edit Arrowheads Modifica punte di freccia Edit Arrowheads… Modifica punte di freccia… Reload Arrowheads Ricarica punte di freccia + Bevels Smussi + Edit Bevels Modifica smussi + Edit Bevels… Modifica smussi… + Reload Bevels Ricarica smussi Rotate View Ruota vista Reset Rotate View Reimposta rotazione vista Rotate View to Selection Ruota vista in base alla selezione diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index ba3105aec0..49cf283eee 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -2940,6 +2940,10 @@ mark-style Japanese 日本式 Edit Arrowheads 矢印を編集 Edit Arrowheads… 矢印を編集… Reload Arrowheads 矢印を再読み込み + Bevels ベベル一覧 + Edit Bevels ベベルを編集 + Edit Bevels… ベベルを編集… + Reload Bevels ベベルを再読み込み Reset the rows to the artwork's colors 行をアートワークのカラーにリセット Reset to Default 初期設定に戻す Reset to White, Black 白、黒にリセット diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 83fadf726a..7142235bc7 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -3518,6 +3518,10 @@ theme Appearance იერსახე Edit Arrowheads ისრის წვერების რედაქტირება Edit Arrowheads… ისრის წვერების რედაქტირება… Reload Arrowheads ისრის წვერების ხელახლა ჩატვირთვა + Bevels წაკვეთები + Edit Bevels წაკვეთების რედაქტირება + Edit Bevels… წაკვეთების რედაქტირება… + Reload Bevels წაკვეთების ხელახლა ჩატვირთვა Stroke Options კონტურის პარამეტრები Width Profiles სიგანის პროფილები Apply Graphic Style გრაფიკული სტილის გამოყენება diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index e6f7478bf3..342fa1bed7 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -2929,6 +2929,10 @@ mark-style Japanese 일본식 Edit Arrowheads 화살촉 편집 Edit Arrowheads… 화살촉 편집… Reload Arrowheads 화살촉 다시 불러오기 + Bevels 베벨 목록 + Edit Bevels 베벨 편집 + Edit Bevels… 베벨 편집… + Reload Bevels 베벨 다시 불러오기 Reset the rows to the artwork's colors 행을 아트웍 색상으로 재설정 Reset to Default 기본값으로 재설정 Reset to White, Black 흰색, 검정으로 재설정 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 26baaa8dc5..f36af51d6b 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3689,6 +3689,10 @@ theme Appearance Vormgeving Edit Arrowheads Pijlpunten bewerken Edit Arrowheads… Pijlpunten bewerken… Reload Arrowheads Pijlpunten opnieuw laden + Bevels Afschuiningen + Edit Bevels Afschuiningen bewerken + Edit Bevels… Afschuiningen bewerken… + Reload Bevels Afschuiningen opnieuw laden Stroke Options Lijnopties Width Profiles Breedteprofielen Apply Graphic Style Grafische stijl toepassen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 3637bb6f94..1358fc20f5 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3819,6 +3819,10 @@ theme Appearance Wygląd Edit Arrowheads Edytuj groty strzałek Edit Arrowheads… Edytuj groty strzałek… Reload Arrowheads Wczytaj ponownie groty strzałek + Bevels Fazy + Edit Bevels Edytuj fazy + Edit Bevels… Edytuj fazy… + Reload Bevels Wczytaj ponownie fazy Stroke Options Opcje obrysu Width Profiles Profile szerokości Apply Graphic Style Zastosuj styl graficzny diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 15aa70e244..7ddbecebbb 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2427,6 +2427,10 @@ digits Malayalam Malaiala Edit Arrowheads Editar Pontas de Seta Edit Arrowheads… Editar Pontas de Seta… Reload Arrowheads Recarregar Pontas de Seta + Bevels Chanfros + Edit Bevels Editar Chanfros + Edit Bevels… Editar Chanfros… + Reload Bevels Recarregar Chanfros Rotate View Girar Visualização Reset Rotate View Redefinir Visualização Girada Rotate View to Selection Girar Visualização para a Seleção diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 21f270a0fb..3d36e9ea08 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2919,6 +2919,10 @@ digits Malayalam Малаялам Edit Arrowheads Редактировать стрелки Edit Arrowheads… Редактировать стрелки… Reload Arrowheads Перезагрузить стрелки + Bevels Фаски + Edit Bevels Редактировать фаски + Edit Bevels… Редактировать фаски… + Reload Bevels Перезагрузить фаски Rotate View Повернуть вид Reset Rotate View Сбросить поворот вида Rotate View to Selection Повернуть вид по выделению diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 7969960880..3efcee9a0e 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -2826,6 +2826,10 @@ digits Malayalam Malayalam Edit Arrowheads Redigera pilspetsar Edit Arrowheads… Redigera pilspetsar… Reload Arrowheads Läs in pilspetsar igen + Bevels Fasningar + Edit Bevels Redigera fasningar + Edit Bevels… Redigera fasningar… + Reload Bevels Läs in fasningar igen Reset Rotate View Återställ Rotera vy Rotate View to Selection Rotera vyn efter markeringen Reset the rows to the artwork's colors Återställ raderna till teckningens färger diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 639bf692a8..43b18b58fa 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2695,6 +2695,10 @@ digits Malayalam Malayalam Edit Arrowheads Ok Uçlarını Düzenle Edit Arrowheads… Ok Uçlarını Düzenle… Reload Arrowheads Ok Uçlarını Yeniden Yükle + Bevels Eğimler + Edit Bevels Eğimleri Düzenle + Edit Bevels… Eğimleri Düzenle… + Reload Bevels Eğimleri Yeniden Yükle Reset Rotate View Döndürme Görünümünü Sıfırla Rotate View to Selection Görünümü Seçime Döndür Reset the rows to the artwork's colors Satırları resmin renklerine göre sıfırlayın diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 2889757941..26f6c4815c 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2924,6 +2924,10 @@ digits Malayalam Малаялам Edit Arrowheads Редагувати стрілки Edit Arrowheads… Редагувати стрілки… Reload Arrowheads Перезавантажити стрілки + Bevels Фаски + Edit Bevels Редагувати фаски + Edit Bevels… Редагувати фаски… + Reload Bevels Перезавантажити фаски Rotate View Повернути вид Reset Rotate View Скинути поворот виду Rotate View to Selection Повернути вид за виділенням diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index ca39a2cd16..a7f09d2b6c 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3211,6 +3211,10 @@ mark-style Japanese Kiểu Nhật Edit Arrowheads Chỉnh sửa đầu mũi tên Edit Arrowheads… Chỉnh sửa đầu mũi tên… Reload Arrowheads Tải lại đầu mũi tên + Bevels Các kiểu vát + Edit Bevels Chỉnh sửa kiểu vát + Edit Bevels… Chỉnh sửa kiểu vát… + Reload Bevels Tải lại kiểu vát Rotate View Xoay chế độ xem Reset Rotate View Đặt lại xoay chế độ xem Rotate View to Selection Xoay chế độ xem theo vùng chọn diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index d4fe4ce4f3..31f699343e 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2790,6 +2790,10 @@ digits Malayalam 马拉雅拉姆数字 Edit Arrowheads 编辑箭头 Edit Arrowheads… 编辑箭头… Reload Arrowheads 重新载入箭头 + Bevels 斜角列表 + Edit Bevels 编辑斜角 + Edit Bevels… 编辑斜角… + Reload Bevels 重新载入斜角 Reset Rotate View 重置旋转视图 Rotate View to Selection 按所选对象旋转视图 Reset the rows to the artwork's colors 将各行重置为图稿的颜色 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 1a81d6d01c..30fa5ebb21 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -3901,6 +3901,10 @@ digits Malayalam 馬來亞拉姆數字 Edit Arrowheads 編輯箭頭 Edit Arrowheads… 編輯箭頭… Reload Arrowheads 重新載入箭頭 + Bevels 斜角清單 + Edit Bevels 編輯斜角 + Edit Bevels… 編輯斜角… + Reload Bevels 重新載入斜角 Rotate View 旋轉檢視 Reset Rotate View 重設旋轉檢視 Rotate View to Selection 依選取範圍旋轉檢視 diff --git a/crates/ui-egui/src/panels/tests_three_d.rs b/crates/ui-egui/src/panels/tests_three_d.rs index 29751dd5d7..def76a0197 100644 --- a/crates/ui-egui/src/panels/tests_three_d.rs +++ b/crates/ui-egui/src/panels/tests_three_d.rs @@ -211,6 +211,41 @@ fn a_change_reaches_each_selected_3d_effect_and_no_other_effect() { assert_eq!(fx(c)[0].params, c_shadow); } +/// A custom bevel picked in the panel sends its name and points with `bevel`, to the effects that +/// take a bevel only, and another custom bevel replaces them. +#[test] +fn a_custom_bevel_sends_its_name_and_points() { + let mut app = app(); + let a = app.session.active().unwrap().selection.objects[0].0; + set_type(&mut app, "extrude").unwrap(); + let b = app.run("shape.rectangle", json!({"x": 250, "y": 100, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap(); + app.run("effect.apply", json!({"effect": "threeD.inflate", "item": null})).unwrap(); + app.run("select.set", json!({"ids": [a, b]})).unwrap(); + let ctx = egui::Context::default(); + let pick = |name: &str, points: Value| { + Map::from_iter([ + ("bevel".to_string(), json!("custom")), + (vectorcraft_effects::BEVEL_NAME.to_string(), json!(name)), + (vectorcraft_effects::BEVEL_PROFILE.to_string(), points), + ]) + }; + let notch = json!([[0.0, 0.0], [0.2, 0.6], [0.7, 0.4], [1.0, 1.0]]); + send(&mut app, &ctx, pick("Notch", notch.clone()), false); + let fx = |app: &VectorcraftApp, id: u64| { + app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().appearance.effects[0].params.clone() + }; + let p = fx(&app, a); + assert_eq!( + (&p["bevel"], &p[vectorcraft_effects::BEVEL_NAME], &p[vectorcraft_effects::BEVEL_PROFILE]), + (&json!("custom"), &json!("Notch"), ¬ch) + ); + assert!(fx(&app, b).get(vectorcraft_effects::BEVEL_PROFILE).is_none()); + let steps = json!([[0.0, 0.0], [0.0, 0.5], [0.5, 0.5], [0.5, 1.0], [1.0, 1.0]]); + send(&mut app, &ctx, pick("Steps", steps.clone()), false); + let p = fx(&app, a); + assert_eq!((&p[vectorcraft_effects::BEVEL_NAME], &p[vectorcraft_effects::BEVEL_PROFILE]), (&json!("Steps"), &steps)); +} + #[test] fn the_panel_finds_a_3d_effect_on_a_fill() { let mut app = app(); diff --git a/crates/ui-egui/src/panels/three_d.rs b/crates/ui-egui/src/panels/three_d.rs index c9f2f2205e..92d0912e78 100644 --- a/crates/ui-egui/src/panels/three_d.rs +++ b/crates/ui-egui/src/panels/three_d.rs @@ -7,7 +7,7 @@ use egui::Ui; use serde_json::{Map, Value, json}; use vectorcraft_doc::{Effect, Node}; -use vectorcraft_effects::{CLASSIC_EXTRUDE, CLASSIC_REVOLVE, EXTRUDE, INFLATE, THREE_D_TYPES, is_three_d}; +use vectorcraft_effects::{BEVEL_NAME, BEVEL_PROFILE, CLASSIC_EXTRUDE, CLASSIC_REVOLVE, EXTRUDE, INFLATE, THREE_D_TYPES, is_three_d}; use super::{live_run, pstate, set_pstate}; use crate::VectorcraftApp; @@ -150,9 +150,11 @@ pub(crate) fn send(app: &mut VectorcraftApp, ctx: &egui::Context, changed: Map = pending .iter() - .filter(|(k, _)| takes.get(k.as_str()).is_some() && (k.as_str() != "lights" || *same_lights)) + .filter(|(k, _)| (takes.get(k.as_str()).is_some() || custom_bevel(k)) && (k.as_str() != "lights" || *same_lights)) .map(|(k, v)| (k.clone(), v.clone())) .collect(); (!params.is_empty()) @@ -232,6 +234,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let mut d = Dialog { kind: ID.into(), fields }; let before = crate::dialogs::form::params(&d); crate::dialogs::revolve::controls(app, ui, &mut d); + let edit_bevels = d.fields.remove("__editBevels").is_some(); let state: Map = d .fields .iter() @@ -243,6 +246,14 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let changed = changed_settings(&before, &after); let dragging = ctx.input(|i| i.pointer.any_down()); send(app, &ctx, changed, dragging); + // Bevel Shape's Edit Bevels…: the bevels file opens as a document of its own. + if edit_bevels { + finish(app, &ctx); + if let Err(e) = app.run("threeD.bevels.edit", json!({})) { + app.ui.status = e; + } + return; + } if quick_actions_shown(&d) { ui.add_space(10.0); let t = Tokens::get(ui.ctx()); diff --git a/docs/effects-parity.md b/docs/effects-parity.md index e219ce5e1b..406907e1b4 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -179,9 +179,9 @@ VectorCraft choices; an original approximation, never compared with another appl | Item | Ours | |---|---| | Revolve | initial: live, editable profile, rotation and light gizmos, default-on Cap with continuous curved rims, smooth vector shading and round seam joins, SVG/PDF output, Expand Appearance ([revolve.md](revolve.md), #846) | -| Extrude & Bevel, Inflate, Rotate | initial: live, 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)) | +| Extrude & Bevel, Inflate, Rotate | initial: live, depth, twist, taper, solid or hollow caps, five original bevel shapes and custom bevels drawn as open paths in the bevels file ([add custom bevel paths](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/add-custom-bevel-paths.html), [three-d.md](three-d.md#custom-bevels)), 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, 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)); no materials, soft shadows or ray tracing | -| 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, 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, 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, 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)); Map Art: none | +| 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, Extrude Depth, Cap, five original bevel shapes and the custom bevels 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, 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, 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)); Map Art: none | | Turntable (30.0 beta) | none | | Export 3D objects (OBJ, USDA, glTF) | initial: Asset Export's Export 3D Object collects an object with Extrude & Bevel, Revolve, Inflate or Rotate as a 3D asset, and Export writes its solids as a USDA (the default), USDZ, glTF or OBJ mesh with a material in each solid's paint color (`assets.add3D`, `assets.set3DFormat`, `assets.export3D`); no textures, map art or shading ([3D export help](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/export-3d-vector-artwork.html)) | diff --git a/docs/mcp.md b/docs/mcp.md index 0a6d0cf4b9..d1100f8e34 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3466,7 +3466,7 @@ it, masks that member's solids ([three-d.md](three-d.md#groups)). `threeD.extrude`: `depth` (points, 0..2000, default 50), `twist` (degrees, 0..360, 0), `taper` (1..100%, 100), `cap` (true solid, false hollow), `bevel` (`none`, `classic`, `rounded`, `cove`, `step`, `ogee`), `bevelWidth` and `bevelHeight` (points, default 4), `bevelRepeat` (1..32), `bevelSpace` (0..90%), `bevelInside`, -`bevelBothSides`. `threeD.inflate`: `depth` (points, default 0), `twist` (degrees, 0..360, 0), `taper` (1..100%, 100), `cap` (true +`bevelBothSides`; `bevel` `custom` with `bevelName` and `bevelProfile` is a custom bevel (below). `threeD.inflate`: `depth` (points, default 0), `twist` (degrees, 0..360, 0), `taper` (1..100%, 100), `cap` (true solid, false open behind), `volume` (0..100%, default 50), `bothSides`. All three take `rotationX/Y/Z` (degrees, -180..180, default the Off-Axis Front position -21.88/-23.4/9.06), `perspectiveAngle` and the lighting parameters as Revolve. See [three-d.md](three-d.md) for the Position presets, @@ -3478,12 +3478,37 @@ points returns "The shape is too complex for a 3D effect", and one whose faces d has so many points across so many of its grid's cells that filling the grid would pass its work limit. `threeD.rotate` takes up to 65,536 points. +Custom bevels come from the bevels file, `Bevels.vectorcraft` next to the preferences (none on the web or in runs +with `VECTORCRAFT_NO_PREFS`). `threeD.bevels.edit` (3D and Materials panel › Bevel Shape › Edit Bevels…) opens it, +and first creates it with one example bevel when it is missing. Each symbol whose art is one open path is one bevel, +named after the symbol and listed after the built-in shapes. These rules are VectorCraft's own: the path runs from its +first anchor at the cap's edge to its last at the side wall, across the page across the bevel's width and down the +page along its height, and curves are cut into straight lines of at most 64 points. The file is read when the app +starts and again each time VectorCraft saves it; `threeD.bevels.reload` reads it again. A file larger than 64 MB is +not read, at most 256 symbols are read, and a symbol that is not one open path, has more than 4,096 anchors, is cut +into more than 8,192 straight lines, has ends that are not apart both across and down, or repeats an earlier name is +listed in `skipped`. `threeD.bevels.list` +returns each bevel's `name` and `points`, the `file` path, the `skipped` symbols and any read `error`. + +`threeD.extrude` and `threeD.classicExtrude` take `bevel: {"custom": name}` in `effect.apply` and `effect.setParams`, +and store it as `bevel: "custom"` with `bevelName` and `bevelProfile`, a copy of the points (`[[x, y], …]`, 2 to 64 +shares 0..1 of the width and height from `[0, 0]` to `[1, 1]`), so the document draws the bevel without the file. An +unknown name, `custom` without `bevelProfile`, points that do not run from `[0, 0]` to `[1, 1]` within 0..1, or a +`bevelName` that is not a string is refused and the document is not changed. The help page +[Add custom bevel paths](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/add-custom-bevel-paths.html) +describes custom bevels drawn as open paths and kept as symbols in a bevels document. + +```json +{"name":"run_command","arguments":{"command":"threeD.bevels.list","params":{}}} +{"name":"run_command","arguments":{"command":"effect.apply","params":{"effect":"threeD.extrude","item":null,"params":{"bevel":{"custom":"Example Bevel"},"bevelWidth":8,"bevelHeight":8}}}} +``` + ## Extrude & Bevel (Classic) `effect.apply {effect: "threeD.classicExtrude", params: {...}, ids?, item?}` is Effect › 3D and Materials › 3D (Classic) › Extrude & Bevel (Classic)…. It builds the same solid as `threeD.extrude` and draws its faces with the classic surfaces. Parameters: `depth` (points, 0..2000, default 50), `cap` (true solid, false hollow), `bevel` (`none`, -`classic`, `rounded`, `cove`, `step`, `ogee`), `bevelHeight` (points, 1..100, default 4; the bevel is as wide as it +`classic`, `rounded`, `cove`, `step`, `ogee`, or a custom bevel as for `threeD.extrude`), `bevelHeight` (points, 1..100, default 4; the bevel is as wide as it is tall), `bevelInside` (false adds the bevel around the shape, true carves it into the shape), `rotationX/Y/Z` and `perspectiveAngle` as above, and the surface: diff --git a/docs/three-d.md b/docs/three-d.md index 820bc1e805..7f04b1787c 100644 --- a/docs/three-d.md +++ b/docs/three-d.md @@ -79,7 +79,7 @@ object is where the art was. | Twist | 0° to 360°: the back face turned against the front, the walls following in slices. | | Taper | 1–100 %: the back face's size against the front's. | | Cap | **Solid** closes the front and back; **Hollow** leaves them open, showing the insides of the walls. | -| Bevel Shape | **None**, **Classic** (a straight chamfer), **Rounded** (convex quarter round), **Cove** (concave), **Step** (two steps) or **Ogee** (an S curve). Our own cross-sections. | +| Bevel Shape | **None**, **Classic** (a straight chamfer), **Rounded** (convex quarter round), **Cove** (concave), **Step** (two steps) or **Ogee** (an S curve). Our own cross-sections. After them come the custom bevels ([Custom bevels](#custom-bevels)). | | Width, Height | How far the bevel reaches across the face and along the depth (0–1,000 pt each). The height is limited to the depth (half of it on each side with Bevel both sides). | | Repeat, Space | The cross-section repeated 1–32 times across the width, with a share (0–90 %) of the width flat between repeats. | | Bevel Inside | The bevel carved into the shape (the front face shrinks) instead of added around it (the walls stand outside the art). | @@ -88,6 +88,28 @@ object is where the art was. Holes stay holes, with walls of their own. Bevels move each corner along its bisector (mitres are limited to four times the width), so a bevel wider than a narrow part of the shape folds over itself. +### Custom bevels + +The public [Add custom bevel paths](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/add-custom-bevel-paths.html) +page describes a custom bevel as one open path saved as a symbol in a bevels document, then listed in the Bevel menu. +VectorCraft keeps its custom bevels in `Bevels.vectorcraft`, a native document next to the preferences (none on the +web or in runs with `VECTORCRAFT_NO_PREFS`). The layout below is VectorCraft's own. + +- **Edit Bevels…** under Bevel Shape in the 3D and Materials panel (`threeD.bevels.edit`) opens the file, and first + creates it with one example bevel when it is missing. +- Each symbol whose art is one open path (alone or in groups of one member) is one bevel, named after the symbol and + listed after the built-in shapes in the Bevel Shape menus of Extrude & Bevel and Extrude & Bevel (Classic). +- The path runs from its first anchor, at the cap's edge, to its last, at the side wall. Across the page is across + the bevel's width and down the page is along its height, whichever way the path is drawn. Points past its ends are + held to them, curves are cut into straight lines, and a path is simplified to at most 64 points. +- A custom bevel takes Width, Height, Repeat, Space, Bevel Inside and Bevel both sides like the built-in shapes. +- The file is read when the app starts and again each time VectorCraft saves it; `threeD.bevels.reload` reads it + again. A file larger than 64 MB is not read, at most 256 symbols are read, and a symbol that is not one open path, + has more than 4,096 anchors, is cut into more than 8,192 straight lines, has ends that are not apart both across and down, or repeats an earlier name is listed + in `skipped` by `threeD.bevels.list`. +- An effect that uses a custom bevel keeps its name and a copy of its points, so the document draws it the same way + without the bevels file. + ## Inflate The shape puffed out like a cushion: its outline stays where the art is and the surface rises towards the @@ -297,7 +319,7 @@ Our reading: ## Parameters (`effect.apply`, `effect.setParams`) `threeD.extrude`: `depth`, `twist`, `taper` (%), `cap`, `bevel` (`none`, `classic`, `rounded`, `cove`, `step`, -`ogee`), `bevelWidth`, `bevelHeight`, `bevelRepeat`, `bevelSpace` (%), `bevelInside`, `bevelBothSides`. +`ogee`, or `custom` with `bevelName` and `bevelProfile`; `{custom: name}` takes a bevel of the bevels file), `bevelWidth`, `bevelHeight`, `bevelRepeat`, `bevelSpace` (%), `bevelInside`, `bevelBothSides`. `threeD.inflate`: `depth`, `volume` (%), `bothSides`. All three take the view and lighting parameters Revolve uses: `rotationX`, `rotationY`, `rotationZ`, `perspectiveAngle` (degrees), `shade`, `lightColor` (`#rrggbb`, default `#ffffff`), `lightIntensity` (%), `lightRotation`, `lightHeight` (degrees), `lightSoftness` (%), `ambient` (%, to 200), `lightBehind`. Lengths are points and scale with the object (Scale Strokes & Effects). @@ -314,7 +336,8 @@ out, perspective). No Adobe software, assets, presets or bevel shapes were used. and **ray-traced rendering** are not built: shading uses directional lights, in the paint of the fill or stroke the solid is built for ([Fills and strokes](#fills-and-strokes)), and the shadow is hard-edged ([Shadows](#shadows)). -- The bevel shapes and their names are our own; custom bevel paths are not supported. +- The bevel shapes and their names are our own. Custom bevels come from VectorCraft's own bevels file + ([Custom bevels](#custom-bevels)) and are cut into straight lines. - Visibility is a painter's algorithm: faces of a closed solid turned away are left out, and the rest are drawn back to front, with a flat cap or flat back turned toward the viewer drawn after all of them. Concave solids seen at steep angles can overlap wrongly; open (hollow) solids show both sides. Twisted walls and bevels are From 0e74240620e4c178852b0ef0197306450440c153 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 17:37:57 -0800 Subject: [PATCH 02/13] 3D: plug-ins may not open the bevels file threeD.bevels.edit joins stroke.arrowheads.edit in the commands a plug-in may not call, and the merge with main is formatted. --- crates/effects/src/lib.rs | 6 +++--- crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/three-d/src/lib.rs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/effects/src/lib.rs b/crates/effects/src/lib.rs index 3c6c1d03d7..0c980a0c43 100644 --- a/crates/effects/src/lib.rs +++ b/crates/effects/src/lib.rs @@ -87,9 +87,9 @@ pub use revolve::{ CLASSIC_REVOLVE, REVOLVE, has_revolve, is_revolve, revolve_art, revolve_art_in, revolve_options, validate_revolve, validate_revolve_in, }; pub use solids::{ - BEVEL_NAME, BEVEL_PROFILE, CLASSIC_EXTRUDE, CLASSIC_ROTATE, EXTRUDE, GRAPHICS, GraphicFrame, INFLATE, MAX_GRAPHICS, MappedGraphic, ROTATE, ROTATE_SURFACES, - ROTATION_PRESETS, SHADING_COLORS, SOLIDS, SolidMesh, THREE_D_TYPES, classic_extrude_options, classic_shading, extrude_options, graphic_bounds, - graphic_frame, graphic_symbols, has_solid, inflate_options, is_classic_three_d, is_three_d, mapped_graphics, missing_symbol, + BEVEL_NAME, BEVEL_PROFILE, CLASSIC_EXTRUDE, CLASSIC_ROTATE, EXTRUDE, GRAPHICS, GraphicFrame, INFLATE, MAX_GRAPHICS, MappedGraphic, ROTATE, + ROTATE_SURFACES, ROTATION_PRESETS, SHADING_COLORS, SOLIDS, SolidMesh, THREE_D_TYPES, classic_extrude_options, classic_shading, extrude_options, + graphic_bounds, graphic_frame, graphic_symbols, has_solid, inflate_options, is_classic_three_d, is_three_d, mapped_graphics, missing_symbol, names_graphic_symbol, rename_graphic_symbol, rename_graphic_symbol_in, solid_art, solid_art_in, takes_graphics, three_d_meshes, three_d_meshes_in, three_d_meshes_of, three_d_meshes_of_in, three_d_params_as, three_d_wireframe_in, validate_solid, validate_solid_in, validate_three_d, validate_three_d_at, validate_three_d_at_in, validate_three_d_in, validate_three_d_params, view_options, with_graphic, diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index 0f5ada29fe..9a26b463f0 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -695,5 +695,6 @@ pub(super) const DENIED: &[&str] = &[ "object.liquify", "object.pathfinder.options", "stroke.arrowheads.edit", + "threeD.bevels.edit", "type.compositeFonts.set", ]; diff --git a/crates/three-d/src/lib.rs b/crates/three-d/src/lib.rs index 2ae07ba022..b2aaac253d 100644 --- a/crates/three-d/src/lib.rs +++ b/crates/three-d/src/lib.rs @@ -9,8 +9,8 @@ mod solid; mod visibility; pub use solid::{ - Bevel, BevelProfile, BevelShape, Extrude, FaceMap, Facet, Inflate, PlanarFace, View, extrude, extrude_face_map, inflate, inflate_together, - plane, plane_face_map, + Bevel, BevelProfile, BevelShape, Extrude, FaceMap, Facet, Inflate, PlanarFace, View, extrude, extrude_face_map, inflate, inflate_together, plane, + plane_face_map, }; pub use visibility::{VisibleFace, visible_faces}; mod shading; From dc956060f8ca68009166c7fca0546090a9fe236d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 17:52:23 -0800 Subject: [PATCH 03/13] 3D: the bevels file stops cutting a path once it passes the point limit A bevel's path is cut into straight lines one segment at a time, and the reader stops at the segment that passes 8,192 points, so a detailed symbol is skipped without cutting the rest of its path. --- crates/engine/src/cmd/bevels.rs | 25 ++++++++++++++++++------- crates/engine/src/tests/bevels.rs | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/cmd/bevels.rs b/crates/engine/src/cmd/bevels.rs index f36082862e..efe662b332 100644 --- a/crates/engine/src/cmd/bevels.rs +++ b/crates/engine/src/cmd/bevels.rs @@ -145,14 +145,25 @@ fn points_of(n: &Node) -> std::result::Result, &'static str> { return Err("its path has too many anchors for a bevel"); } let mut line: Vec = vec![]; - let mut too_many = false; let tolerance = path.bounds().map_or(1.0, |b| b.width().hypot(b.height()) / 2000.0).max(1e-9); - vectorcraft_geom::flatten(path.to_bezpath().elements().iter().copied(), tolerance, |el| match el { - PathEl::MoveTo(p) | PathEl::LineTo(p) if line.len() < MAX_LINE_POINTS => line.push(p), - PathEl::MoveTo(_) | PathEl::LineTo(_) => too_many = true, - _ => {} - }); - if too_many { + // One segment at a time, so a path past the limit stops being cut at the segment that passes it. + let mut at: Option = None; + for &el in path.to_bezpath().elements() { + if line.len() > MAX_LINE_POINTS { + return Err("its path is too detailed for a bevel"); + } + match (el, at) { + (PathEl::MoveTo(p), _) => line.push(p), + (_, Some(start)) => vectorcraft_geom::flatten([PathEl::MoveTo(start), el], tolerance, |e| { + if let PathEl::LineTo(p) = e { + line.push(p); + } + }), + (_, None) => {} + } + at = el.end_point().or(at); + } + if line.len() > MAX_LINE_POINTS { return Err("its path is too detailed for a bevel"); } let (Some(&first), Some(&last)) = (line.first(), line.last()) else { return Err("its path has no length") }; diff --git a/crates/engine/src/tests/bevels.rs b/crates/engine/src/tests/bevels.rs index 4540ae9654..5314ce5b00 100644 --- a/crates/engine/src/tests/bevels.rs +++ b/crates/engine/src/tests/bevels.rs @@ -102,6 +102,28 @@ fn curves_and_long_paths_fit_in_the_points_a_bevel_holds() { assert!(arc.points.iter().all(|&(x, y)| (((x - 0.0).powi(2) + (y - 1.0).powi(2)).sqrt() - 1.0).abs() < 0.01), "{:?}", arc.points); } +/// A path of many tall curves, cut into more straight lines than a bevel's path may take, is +/// skipped as too detailed. +#[test] +fn a_path_cut_into_too_many_lines_is_skipped() { + let mut d = Document::new(100.0, 100.0); + let anchors: Vec = (0..4000) + .map(|i| { + let p = Point::new(f64::from(i), f64::from(i) / 4.0); + let swing = if i % 2 == 0 { 1000.0 } else { -1000.0 }; + let mut a = Anchor::corner(p); + a.h_in = Point::new(p.x - 0.5, p.y - swing); + a.h_out = Point::new(p.x + 0.5, p.y + swing); + a + }) + .collect(); + let wild = Node::path(NodeId(0), PathData::single(SubPath::new(anchors, false)), Appearance::default()); + add_symbol(&mut d, "Wild", wild); + let read = bevels_of(&d); + assert!(read.bevels.is_empty()); + assert_eq!(read.skipped, [("Wild".to_string(), "its path is too detailed for a bevel".to_string())]); +} + fn rect(s: &mut Session, x: u32) -> NodeId { NodeId(s.execute("shape.rectangle", &json!({"x": x, "y": 100, "width": 60, "height": 60})).unwrap()["id"].as_u64().unwrap()) } From 4a212fdbd6ac1b042dae8b49916f3047dc3d78fc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 19:25:30 -0800 Subject: [PATCH 04/13] 3D: a replay draws the custom bevel it recorded, and a mixed selection takes the whole bevel effect.apply and effect.setParams given bevel {custom: name} record the bevel's points in their journal entry as savedBevel, and savedBevel given with the name is used in place of the bevels file's points, so a replay draws the same bevel after the file changes or drops the name. The 3D and Materials panel sends a custom bevel's name and points with bevel whenever any of the three changes, so an Extrude & Bevel in a mixed selection that had no custom bevel takes the whole bevel. --- crates/engine/src/cmd/bevels.rs | 22 ++++++++---- crates/engine/src/cmd/effectcmd.rs | 8 ++--- crates/engine/src/tests/bevels.rs | 41 ++++++++++++++++++++++ crates/ui-egui/src/panels/tests_three_d.rs | 27 ++++++++++++++ crates/ui-egui/src/panels/three_d.rs | 14 +++++++- docs/mcp.md | 4 ++- 6 files changed, 104 insertions(+), 12 deletions(-) diff --git a/crates/engine/src/cmd/bevels.rs b/crates/engine/src/cmd/bevels.rs index efe662b332..cbc4dbb8f3 100644 --- a/crates/engine/src/cmd/bevels.rs +++ b/crates/engine/src/cmd/bevels.rs @@ -277,19 +277,29 @@ impl Session { } } +/// The command parameter that holds the points a custom bevel given by name had when the command +/// ran. The journal records it, so a replay draws the same bevel after the bevels file changes or +/// loses that name. +pub const SAVED_BEVEL: &str = "savedBevel"; + /// `params` of an effect with `bevel` given as `{custom: name}`: the bevel of the bevels file named -/// so, stored as `bevel` `"custom"` with its `bevelName` and `bevelProfile`. Other values are left -/// for the effect to check. -pub(crate) fn resolve_custom(s: &Session, params: &mut Value, cmd: &str) -> Result<()> { +/// so, stored as `bevel` `"custom"` with its `bevelName` and `bevelProfile`. The command's +/// [`SAVED_BEVEL`] points (`p`), when given, are used in place of the file's, and the points used +/// join the journal entry as [`SAVED_BEVEL`]. Other values are left for the effect to check. +pub(crate) fn resolve_custom(s: &mut Session, p: &Value, params: &mut Value, cmd: &str) -> Result<()> { let Some(Value::Object(o)) = params.get("bevel") else { return Ok(()) }; let name = match (o.len(), o.get("custom")) { (1, Some(Value::String(name))) => name.clone(), _ => return Err(bad(cmd, "bevel: give a shape id, or {custom: name} for a bevel of the bevels file (threeD.bevels.list)")), }; - let bevel = s.bevels.get(&name).ok_or_else(|| bad(cmd, format!("no custom bevel {name} (see threeD.bevels.list)")))?; + let points = match p.get(SAVED_BEVEL).filter(|v| !v.is_null()) { + Some(saved) => saved.clone(), + None => s.bevels.get(&name).ok_or_else(|| bad(cmd, format!("no custom bevel {name} (see threeD.bevels.list)")))?.profile_json(), + }; + s.note_journal(SAVED_BEVEL, points.clone()); params["bevel"] = json!("custom"); - params[BEVEL_NAME] = json!(bevel.name); - params[BEVEL_PROFILE] = bevel.profile_json(); + params[BEVEL_NAME] = json!(name); + params[BEVEL_PROFILE] = points; Ok(()) } diff --git a/crates/engine/src/cmd/effectcmd.rs b/crates/engine/src/cmd/effectcmd.rs index e391ef006d..73f447a6f0 100644 --- a/crates/engine/src/cmd/effectcmd.rs +++ b/crates/engine/src/cmd/effectcmd.rs @@ -49,7 +49,7 @@ fn effect_specs() -> Vec { "Apply Effect", [], None, - "{effect: id (see effect.list, e.g. \"stylize.dropShadow\", \"distort.roughen\", \"warp.arc\", or \"plugin.\" for an installed effect plug-in), params?: {…} (missing keys take the dialog defaults), item?: appearance item index|null (apply to that fill/stroke only; omitted: the Appearance panel's active item, else the whole object), ids?|id?: [..] (layers too), target?: \"object\"|\"contents\" (contents: the objects inside groups and layers)} append a live effect to each selected object's appearance (a group's or layer's apply to its members as one piece: one combined shadow; a Pathfinder effect, which combines a group's contents, groups several loose selected objects first, in the same undo step) → {ids, index, item, grouped?}", + "{effect: id (see effect.list, e.g. \"stylize.dropShadow\", \"distort.roughen\", \"warp.arc\", or \"plugin.\" for an installed effect plug-in), params?: {…} (missing keys take the dialog defaults), item?: appearance item index|null (apply to that fill/stroke only; omitted: the Appearance panel's active item, else the whole object), ids?|id?: [..] (layers too), target?: \"object\"|\"contents\" (contents: the objects inside groups and layers), savedBevel?: [[x, y]…] (with params bevel {custom: name}: the custom bevel's points, used in place of the bevels file's; the journal records them so a replay draws the same bevel after the file changes)} append a live effect to each selected object's appearance (a group's or layer's apply to its members as one piece: one combined shadow; a Pathfinder effect, which combines a group's contents, groups several loose selected objects first, in the same undo step) → {ids, index, item, grouped?}", has_doc, apply ), @@ -76,7 +76,7 @@ fn effect_specs() -> Vec { "Effect Options", [], None, - "{index: int, params?: {…} (merged into the current parameters), warpStyle?: string (an existing Warp style suffix, e.g. arc or flag; changes only an applied Warp in place), threeDType?: plane|extrude|revolve|inflate (the 3D and Materials panel's object type: changes only an applied 3D effect in place into Rotate, Extrude & Bevel, Revolve or Inflate; the settings the new effect also takes keep their values, rotation angles wrapped into -180..180 outside Revolve, and the others start at its defaults; params then merge into the new effect's; the type the effect already has, with nothing else given, changes nothing and records no undo step), visible?: bool, item?: appearance item index|null (as effect.remove), ids?|id?: [..], target?: \"object\"|\"contents\", aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection)} → {ids}", + "{index: int, params?: {…} (merged into the current parameters), warpStyle?: string (an existing Warp style suffix, e.g. arc or flag; changes only an applied Warp in place), threeDType?: plane|extrude|revolve|inflate (the 3D and Materials panel's object type: changes only an applied 3D effect in place into Rotate, Extrude & Bevel, Revolve or Inflate; the settings the new effect also takes keep their values, rotation angles wrapped into -180..180 outside Revolve, and the others start at its defaults; params then merge into the new effect's; the type the effect already has, with nothing else given, changes nothing and records no undo step), visible?: bool, item?: appearance item index|null (as effect.remove), ids?|id?: [..], target?: \"object\"|\"contents\", aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection), savedBevel?: [[x, y]…] (as effect.apply)} → {ids}", has_doc, set_params ), @@ -436,7 +436,7 @@ pub(crate) fn apply(s: &mut Session, p: &Value) -> Result { } // A custom bevel by name takes a copy of its points from the bevels file. if bevel_effect(id) { - super::bevels::resolve_custom(s, &mut params, C)?; + super::bevels::resolve_custom(s, p, &mut params, C)?; } // An SVG filter needs its element, and is named by its id. if id == effects::SVG_FILTER { @@ -733,7 +733,7 @@ fn set_params(s: &mut Session, p: &Value) -> Result { load_texture(&mut params, C)?; } if edited.iter().any(|e| bevel_effect(e)) || kind == Some(effects::EXTRUDE) { - super::bevels::resolve_custom(s, &mut params, C)?; + super::bevels::resolve_custom(s, p, &mut params, C)?; } let targets = effect_targets(s, p, item, index, C)?; // The type each 3D effect already has, with nothing else to change, is no edit (and is not diff --git a/crates/engine/src/tests/bevels.rs b/crates/engine/src/tests/bevels.rs index 5314ce5b00..1a77959394 100644 --- a/crates/engine/src/tests/bevels.rs +++ b/crates/engine/src/tests/bevels.rs @@ -190,6 +190,47 @@ fn the_bevels_file_is_made_opened_and_reloaded_when_saved() { let _ = std::fs::remove_dir_all(&dir); } +/// `effect.apply` and `effect.setParams` given a custom bevel by name record its points as +/// `savedBevel`, so a replay draws that bevel after the bevels file no longer has it. +#[test] +fn a_replay_draws_the_custom_bevel_the_command_recorded() { + let dir = folder("replay"); + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap(); + let id = rect(&mut s, 20); + s.attach_bevels_file(dir.join(bevels::FILE_NAME).to_string_lossy().to_string()); + s.execute("threeD.bevels.edit", &json!({})).unwrap(); + s.execute("document.activate", &json!({"index": 0})).unwrap(); + let apply = json!({"effect": effects::EXTRUDE, "ids": [id.0], "item": null, "params": {"bevel": {"custom": "Example Bevel"}}}); + s.execute("effect.apply", &apply).unwrap(); + let applied = params(&s, id); + let (cmd, recorded) = s.journal.last().unwrap().clone(); + assert_eq!(cmd, "effect.apply"); + assert_eq!(recorded[bevels::SAVED_BEVEL], applied[effects::BEVEL_PROFILE]); + let set = json!({"ids": [id.0], "index": 0, "item": null, "params": {"bevel": {"custom": "Example Bevel"}, "bevelWidth": 9}}); + s.execute("effect.setParams", &set).unwrap(); + let edited = params(&s, id); + let (_, set_recorded) = s.journal.last().unwrap().clone(); + assert_eq!(set_recorded[bevels::SAVED_BEVEL], applied[effects::BEVEL_PROFILE]); + // The bevels file no longer has the bevel: by name it is refused, and the replays draw it. + s.attach_bevels_file(dir.join("Other.vectorcraft").to_string_lossy().to_string()); + assert!(s.execute("effect.apply", &apply).is_err()); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(s.doc().unwrap().doc.node(id).unwrap().appearance.effects.is_empty()); + s.replay("effect.apply", &recorded).unwrap(); + assert_eq!(params(&s, id), applied); + s.replay("effect.setParams", &set_recorded).unwrap(); + assert_eq!(params(&s, id), edited); + // Points given with the name are used in place of the file's. + let notch = json!([[0.0, 0.0], [0.2, 0.6], [0.7, 0.4], [1.0, 1.0]]); + let mut given = set.clone(); + given["savedBevel"] = notch.clone(); + s.execute("effect.setParams", &given).unwrap(); + assert_eq!((¶ms(&s, id)[effects::BEVEL_PROFILE], ¶ms(&s, id)[effects::BEVEL_NAME]), (¬ch, &json!("Example Bevel"))); + let _ = std::fs::remove_dir_all(&dir); +} + #[test] fn a_document_keeps_its_custom_bevels_without_the_bevels_file() { let mut s = Session::new(); diff --git a/crates/ui-egui/src/panels/tests_three_d.rs b/crates/ui-egui/src/panels/tests_three_d.rs index a97574f6ba..d272901fce 100644 --- a/crates/ui-egui/src/panels/tests_three_d.rs +++ b/crates/ui-egui/src/panels/tests_three_d.rs @@ -246,6 +246,33 @@ fn a_custom_bevel_sends_its_name_and_points() { assert_eq!((&p[vectorcraft_effects::BEVEL_NAME], &p[vectorcraft_effects::BEVEL_PROFILE]), (&json!("Steps"), &steps)); } +/// With one Extrude & Bevel on a custom bevel and one without, picking that custom bevel sends its +/// name and points too, though the form already held them, so both effects take it. +#[test] +fn a_custom_bevel_picked_for_a_mixed_selection_reaches_every_effect() { + let mut app = app(); + let notch = json!([[0.0, 0.0], [0.2, 0.6], [0.7, 0.4], [1.0, 1.0]]); + let custom = json!({"bevel": "custom", "bevelName": "Notch", "bevelProfile": notch}); + app.run("effect.apply", json!({"effect": "threeD.extrude", "item": null, "params": custom})).unwrap(); + let a = app.session.active().unwrap().selection.objects[0].0; + let b = app.run("shape.rectangle", json!({"x": 250, "y": 100, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap(); + app.run("effect.apply", json!({"effect": "threeD.extrude", "item": null})).unwrap(); + app.run("select.set", json!({"ids": [a, b]})).unwrap(); + let mut fields = target(&app).map(|t| vectorcraft_effects::merged_params(&t.effect, &t.params)).unwrap().as_object().cloned().unwrap(); + super::mark_mixed(&app, &mut fields); + assert_eq!((&fields["bevel"], &fields[vectorcraft_effects::BEVEL_NAME]), (&Value::Null, &json!("Notch"))); + let before = Value::Object(fields.clone()); + fields.insert("bevel".into(), json!("custom")); + let changed = changed_settings(&before, &Value::Object(fields)); + assert_eq!(Value::Object(changed.clone()), json!({"bevel": "custom", "bevelName": "Notch", "bevelProfile": notch})); + send(&mut app, &egui::Context::default(), changed, false); + let st = app.session.active().unwrap(); + for id in [a, b] { + let p = &st.doc.node(vectorcraft_doc::NodeId(id)).unwrap().appearance.effects[0].params; + assert_eq!((&p["bevel"], &p[vectorcraft_effects::BEVEL_PROFILE]), (&json!("custom"), ¬ch), "{id}"); + } +} + #[test] fn the_panel_finds_a_3d_effect_on_a_fill() { let mut app = app(); diff --git a/crates/ui-egui/src/panels/three_d.rs b/crates/ui-egui/src/panels/three_d.rs index 54fb767bb5..c16963bb8b 100644 --- a/crates/ui-egui/src/panels/three_d.rs +++ b/crates/ui-egui/src/panels/three_d.rs @@ -491,9 +491,21 @@ pub(crate) fn mark_mixed(app: &VectorcraftApp, fields: &mut Map) } /// The settings whose values differ between `before` and `after`, with their values in `after`. +/// A change to a custom bevel (`bevel` `"custom"`, its name or its points) sends all three, so an +/// effect of a mixed selection that had none takes the whole bevel. pub(crate) fn changed_settings(before: &Value, after: &Value) -> Map { let Some(after) = after.as_object() else { return Map::new() }; - after.iter().filter(|(k, v)| before.get(k.as_str()) != Some(*v)).map(|(k, v)| (k.clone(), v.clone())).collect() + let mut changed: Map = + after.iter().filter(|(k, v)| before.get(k.as_str()) != Some(*v)).map(|(k, v)| (k.clone(), v.clone())).collect(); + let custom = ["bevel", BEVEL_NAME, BEVEL_PROFILE]; + if after.get("bevel").and_then(Value::as_str) == Some("custom") && custom.iter().any(|k| changed.contains_key(*k)) { + for k in custom { + if let Some(v) = after.get(k) { + changed.insert(k.into(), v.clone()); + } + } + } + changed } #[cfg(test)] diff --git a/docs/mcp.md b/docs/mcp.md index 70ebac3783..88f264be96 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3529,7 +3529,9 @@ returns each bevel's `name` and `points`, the `file` path, the `skipped` symbols and store it as `bevel: "custom"` with `bevelName` and `bevelProfile`, a copy of the points (`[[x, y], …]`, 2 to 64 shares 0..1 of the width and height from `[0, 0]` to `[1, 1]`), so the document draws the bevel without the file. An unknown name, `custom` without `bevelProfile`, points that do not run from `[0, 0]` to `[1, 1]` within 0..1, or a -`bevelName` that is not a string is refused and the document is not changed. The help page +`bevelName` that is not a string is refused and the document is not changed. The command's journal entry records the +points as `savedBevel`, and `savedBevel` given with `{"custom": name}` is used in place of the file's points, so a +replay draws the same bevel after the file changes or drops the name. The help page [Add custom bevel paths](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/add-custom-bevel-paths.html) describes custom bevels drawn as open paths and kept as symbols in a bevels document. From e32a8d9822d727d157cf69d7e4e6a71f3d7904be Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 19:39:10 -0800 Subject: [PATCH 05/13] 3D: Bevel Shape lists the first object's custom bevel for a mixed selection When the selected Extrude & Bevels have custom bevels with different points, the panel unsets the shown points. Bevel Shape still lists the first selected effect's own custom bevel when the bevels file does not have it, so it can be picked for the whole selection. --- crates/ui-egui/src/dialogs/revolve.rs | 55 +++++++++++++++------- crates/ui-egui/src/panels/tests_three_d.rs | 38 +++++++++++++++ crates/ui-egui/src/panels/three_d.rs | 14 ++++++ 3 files changed, 90 insertions(+), 17 deletions(-) diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs index 7d7b6fe3d1..1349146f59 100644 --- a/crates/ui-egui/src/dialogs/revolve.rs +++ b/crates/ui-egui/src/dialogs/revolve.rs @@ -238,17 +238,15 @@ fn solid_controls(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, id: & } } -/// The Bevel Shape menu of Extrude & Bevel and Extrude & Bevel (Classic) (`effect`): None and the -/// built-in shapes, then the custom bevels of the bevels file, and the effect's own custom bevel -/// when the file does not list it (a document from elsewhere carries its points). Picking a -/// custom bevel stores its name and a copy of its points. In the 3D and Materials panel, Edit -/// Bevels… opens the bevels file (`__editBevels`, which the panel runs). -pub(super) fn bevel_choice(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, effect: &str) { - const KEY: &str = "bevel"; - // (shown label, value, the custom bevel's name and points). The built-in labels are - // translated; custom bevels show their names as they are. - type Choice = (String, Value, Option<(String, Value)>); - let mut options: Vec = super::effect::own_choices(effect, KEY, false) +/// A Bevel Shape menu entry: (shown label, value, the custom bevel's name and points). +pub(crate) type BevelChoice = (String, Value, Option<(String, Value)>); + +/// The entries of [`bevel_choice`]'s menu for form `fields`, and how many are built in. The +/// built-in labels are translated; custom bevels show their names as they are. The effect's own +/// custom bevel, the panel's [`OWN_BEVEL`] else the form's, is listed unless the file lists it by +/// name with the same points. +pub(crate) fn bevel_options(app: &VectorcraftApp, fields: &serde_json::Map, effect: &str) -> (Vec, usize) { + let mut options: Vec = super::effect::own_choices(effect, "bevel", false) .unwrap_or_default() .into_iter() .map(|(label, value)| (tl!(label).to_string(), json!(value), None)) @@ -257,16 +255,39 @@ pub(super) fn bevel_choice(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dial for b in app.session.bevels.bevels() { options.push((b.name.clone(), json!("custom"), Some((b.name.clone(), b.profile_json())))); } + let custom = fields.get("bevel").and_then(Value::as_str) == Some("custom"); + let own = match fields.get(OWN_BEVEL).and_then(Value::as_array).map(Vec::as_slice) { + Some([n, p]) => Some((n.as_str().unwrap_or_default().to_string(), p.clone())), + _ => fields + .get(BEVEL_PROFILE) + .filter(|p| custom && !p.is_null()) + .map(|p| (fields.get(BEVEL_NAME).and_then(Value::as_str).unwrap_or_default().to_string(), p.clone())), + }; + if let Some((n, p)) = own + && !options[builtin..].iter().any(|(_, _, c)| c.as_ref().is_some_and(|(cn, cp)| *cn == n && *cp == p)) + { + let shown = if n.is_empty() { tl!("Custom").to_string() } else { n.clone() }; + options.push((shown, json!("custom"), Some((n, p)))); + } + (options, builtin) +} + +/// The form field where the 3D and Materials panel puts the first selected effect's custom bevel, +/// `[name, points]`, so Bevel Shape lists it while a mixed selection unsets the shown bevel. +pub(crate) const OWN_BEVEL: &str = "__ownBevel"; + +/// The Bevel Shape menu of Extrude & Bevel and Extrude & Bevel (Classic) (`effect`): None and the +/// built-in shapes, then the custom bevels of the bevels file, and the effect's own custom bevel +/// when the file does not list it (a document from elsewhere carries its points). Picking a +/// custom bevel stores its name and a copy of its points. In the 3D and Materials panel, Edit +/// Bevels… opens the bevels file (`__editBevels`, which the panel runs). +pub(super) fn bevel_choice(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, effect: &str) { + const KEY: &str = "bevel"; + let (options, builtin) = bevel_options(app, &d.fields, effect); let name = d.fields.get(BEVEL_NAME).and_then(Value::as_str).unwrap_or_default().to_string(); let points = d.fields.get(BEVEL_PROFILE).filter(|v| !v.is_null()).cloned(); let custom = d.fields.get(KEY).and_then(Value::as_str) == Some("custom"); let is = |c: &Option<(String, Value)>| c.as_ref().is_some_and(|(n, p)| *n == name && Some(p) == points.as_ref()); - // The effect's own custom bevel, unless the file lists it by name with the same points. - let own = custom && !options[builtin..].iter().any(|(_, _, c)| is(c)); - if own && let Some(p) = &points { - let shown = if name.is_empty() { tl!("Custom").to_string() } else { name.clone() }; - options.push((shown, json!("custom"), Some((name.clone(), p.clone())))); - } let default = vectorcraft_effects::default_params(effect).and_then(|p| p.get(KEY).cloned()).unwrap_or(Value::Null); let mixed = d.fields.get(KEY).is_some_and(Value::is_null); let value = d.fields.get(KEY).filter(|v| !v.is_null()).cloned().unwrap_or_else(|| default.clone()); diff --git a/crates/ui-egui/src/panels/tests_three_d.rs b/crates/ui-egui/src/panels/tests_three_d.rs index d272901fce..d2bca6e290 100644 --- a/crates/ui-egui/src/panels/tests_three_d.rs +++ b/crates/ui-egui/src/panels/tests_three_d.rs @@ -273,6 +273,44 @@ fn a_custom_bevel_picked_for_a_mixed_selection_reaches_every_effect() { } } +/// Two custom bevels the bevels file does not list: the mixed selection unsets the shown points, +/// and Bevel Shape still lists the first effect's own bevel, which then reaches both effects. +#[test] +fn a_mixed_selection_still_lists_the_first_effects_own_custom_bevel() { + use crate::dialogs::revolve::{OWN_BEVEL, bevel_options}; + let mut app = app(); + let notch = json!([[0.0, 0.0], [0.2, 0.6], [0.7, 0.4], [1.0, 1.0]]); + let steps = json!([[0.0, 0.0], [0.0, 0.5], [0.5, 0.5], [0.5, 1.0], [1.0, 1.0]]); + let custom = |name: &str, points: &Value| json!({"bevel": "custom", "bevelName": name, "bevelProfile": points}); + app.run("effect.apply", json!({"effect": "threeD.extrude", "item": null, "params": custom("Notch", ¬ch)})).unwrap(); + let a = app.session.active().unwrap().selection.objects[0].0; + let b = app.run("shape.rectangle", json!({"x": 250, "y": 100, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap(); + app.run("effect.apply", json!({"effect": "threeD.extrude", "item": null, "params": custom("Steps", &steps)})).unwrap(); + app.run("select.set", json!({"ids": [a, b]})).unwrap(); + let mut fields = target(&app).map(|t| vectorcraft_effects::merged_params(&t.effect, &t.params)).unwrap().as_object().cloned().unwrap(); + let own = super::own_bevel(&fields).unwrap(); + super::mark_mixed(&app, &mut fields); + assert_eq!(fields[vectorcraft_effects::BEVEL_PROFILE], Value::Null); + fields.insert(OWN_BEVEL.into(), own); + let (options, builtin) = bevel_options(&app, &fields, "threeD.extrude"); + assert_eq!(options.len(), builtin + 1); + let (label, value, picked) = options[builtin].clone(); + assert_eq!((label.as_str(), value), ("Notch", json!("custom"))); + let (name, points) = picked.unwrap(); + assert_eq!(points, notch); + // Picking it sends the whole bevel to both effects. + fields.remove(OWN_BEVEL); + let before = Value::Object(fields.clone()); + fields.insert(vectorcraft_effects::BEVEL_NAME.into(), json!(name)); + fields.insert(vectorcraft_effects::BEVEL_PROFILE.into(), points); + send(&mut app, &egui::Context::default(), changed_settings(&before, &Value::Object(fields)), false); + let st = app.session.active().unwrap(); + for id in [a, b] { + let p = &st.doc.node(vectorcraft_doc::NodeId(id)).unwrap().appearance.effects[0].params; + assert_eq!((&p[vectorcraft_effects::BEVEL_NAME], &p[vectorcraft_effects::BEVEL_PROFILE]), (&json!("Notch"), ¬ch), "{id}"); + } +} + #[test] fn the_panel_finds_a_3d_effect_on_a_fill() { let mut app = app(); diff --git a/crates/ui-egui/src/panels/three_d.rs b/crates/ui-egui/src/panels/three_d.rs index c16963bb8b..ddab3a0fb8 100644 --- a/crates/ui-egui/src/panels/three_d.rs +++ b/crates/ui-egui/src/panels/three_d.rs @@ -13,6 +13,7 @@ use vectorcraft_effects::{BEVEL_NAME, BEVEL_PROFILE, CLASSIC_EXTRUDE, CLASSIC_RE use super::{live_run, pstate, set_pstate}; use crate::VectorcraftApp; +use crate::dialogs::revolve::OWN_BEVEL; use crate::dialogs::three_d_materials as materials; use crate::state::Dialog; use crate::theme::Tokens; @@ -235,13 +236,18 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { }; // The applied effect's settings in the dialog's form, with the controls' own state. let mut fields = vectorcraft_effects::merged_params(&t.effect, &t.params).as_object().cloned().unwrap_or_default(); + let own_bevel = own_bevel(&fields); mark_mixed(app, &mut fields); fields.extend(pstate::>(&ctx, UI_STATE)); fields.insert("__effect".into(), json!(t.effect)); fields.insert("__panel".into(), json!(true)); + if let Some(own) = own_bevel { + fields.insert(OWN_BEVEL.into(), own); + } let mut d = Dialog { kind: ID.into(), fields }; let before = crate::dialogs::form::params(&d); crate::dialogs::revolve::controls(app, ui, &mut d); + d.fields.remove(OWN_BEVEL); let edit_bevels = d.fields.remove("__editBevels").is_some(); let action = d.fields.remove(materials::ACTION).and_then(|v| materials::Action::from_value(&v)); let state: Map = d @@ -490,6 +496,14 @@ pub(crate) fn mark_mixed(app: &VectorcraftApp, fields: &mut Map) } } +/// The custom bevel of an effect's settings `fields`, `[name, points]`, when its `bevel` is +/// `"custom"` with points (the Bevel Shape menu lists it while a mixed selection unsets them). +pub(crate) fn own_bevel(fields: &Map) -> Option { + let points = fields.get(BEVEL_PROFILE).filter(|v| !v.is_null())?; + let name = fields.get(BEVEL_NAME).and_then(Value::as_str).unwrap_or_default(); + (fields.get("bevel").and_then(Value::as_str) == Some("custom")).then(|| json!([name, points])) +} + /// The settings whose values differ between `before` and `after`, with their values in `after`. /// A change to a custom bevel (`bevel` `"custom"`, its name or its points) sends all three, so an /// effect of a mixed selection that had none takes the whole bevel. From 17f1361ab55a2e5afdaeb7c5c572a3c91ade8683 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 19:58:15 -0800 Subject: [PATCH 06/13] 3D: simplifying the bevels file's paths has a work limit Simplifying the paths of one bevels file measures at most 40,000,000 point-to-line distances. A symbol whose path needs more than are left is listed in skipped as too detailed, so a file of long jagged paths no longer stalls reading the bevels at startup or on reload. --- crates/engine/src/cmd/bevels.rs | 36 ++++++++++++++++++++----------- crates/engine/src/tests/bevels.rs | 15 +++++++++++++ docs/mcp.md | 3 ++- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/crates/engine/src/cmd/bevels.rs b/crates/engine/src/cmd/bevels.rs index cbc4dbb8f3..cd68bd7f1b 100644 --- a/crates/engine/src/cmd/bevels.rs +++ b/crates/engine/src/cmd/bevels.rs @@ -27,6 +27,9 @@ pub const MAX_BEVELS: usize = 256; pub const MAX_ANCHORS: usize = 4096; /// The most points a bevel's path is cut into before it is simplified; a symbol past it is skipped. pub const MAX_LINE_POINTS: usize = 8192; +/// The most point-to-line distances simplifying the bevels of one file may measure; a symbol that +/// needs more than is left is skipped as too detailed. +pub const MAX_SIMPLIFY_WORK: u64 = 40_000_000; pub fn specs() -> Vec { vec![ @@ -111,6 +114,11 @@ pub struct Read { /// The bevels of document `doc`: one per symbol, up to [`MAX_BEVELS`] (see the module docs). pub fn bevels_of(doc: &Document) -> Read { + bevels_within(doc, MAX_SIMPLIFY_WORK) +} + +/// [`bevels_of`] with `work` point-to-line distances to simplify the paths with. +pub fn bevels_within(doc: &Document, mut work: u64) -> Read { let mut out = Read::default(); for (i, sym) in doc.symbols.iter().enumerate() { if i >= MAX_BEVELS { @@ -121,7 +129,7 @@ pub fn bevels_of(doc: &Document) -> Read { out.skipped.push((sym.name.clone(), "another symbol has this name".into())); continue; } - match points_of(&sym.art) { + match points_of(&sym.art, &mut work) { Ok(points) => out.bevels.push(CustomBevel { name: sym.name.clone(), points }), Err(why) => out.skipped.push((sym.name.clone(), why.into())), } @@ -138,8 +146,9 @@ fn open_path(n: &Node) -> Option<&PathData> { } } -/// The profile points of a bevel symbol's art `n` (see the module docs). -fn points_of(n: &Node) -> std::result::Result, &'static str> { +/// The profile points of a bevel symbol's art `n` (see the module docs), simplified within `work` +/// point-to-line distances, which it uses up. +fn points_of(n: &Node, work: &mut u64) -> std::result::Result, &'static str> { let path = open_path(n).ok_or("its art is not one open path")?; if path.anchor_count() > MAX_ANCHORS { return Err("its path has too many anchors for a bevel"); @@ -180,35 +189,38 @@ fn points_of(n: &Node) -> std::result::Result, &'static str> { // The ends map to the corners exactly. let last = pts.len() - 1; (pts[0], pts[last]) = ((0.0, 0.0), (1.0, 1.0)); - let pts = simplified(&pts); + let pts = simplified(&pts, work).ok_or("its path is too detailed for a bevel")?; BevelProfile::new(&pts).ok_or("its path is too detailed for a bevel")?; Ok(pts) } /// `pts` with the fewest points the Ramer-Douglas-Peucker rule keeps at a tolerance (from a /// thousandth of the bevel, doubled until they fit) that leaves at most -/// [`BevelProfile::MAX_POINTS`]. The first and last points are always kept. -fn simplified(pts: &[(f64, f64)]) -> Vec<(f64, f64)> { +/// [`BevelProfile::MAX_POINTS`]. The first and last points are always kept. `None` when that +/// measures more point-to-line distances than `work` has left. +fn simplified(pts: &[(f64, f64)], work: &mut u64) -> Option> { let mut eps = 1e-3; loop { - let out = rdp(pts, eps); + let out = rdp(pts, eps, work)?; if out.len() <= BevelProfile::MAX_POINTS || eps > 2.0 { - return out; + return Some(out); } eps *= 2.0; } } -/// The points of `pts` Ramer-Douglas-Peucker keeps at tolerance `eps`. -fn rdp(pts: &[(f64, f64)], eps: f64) -> Vec<(f64, f64)> { +/// The points of `pts` Ramer-Douglas-Peucker keeps at tolerance `eps`; `None` when that measures +/// more point-to-line distances than `work` has left. +fn rdp(pts: &[(f64, f64)], eps: f64, work: &mut u64) -> Option> { if pts.len() < 3 { - return pts.to_vec(); + return Some(pts.to_vec()); } let mut keep = vec![false; pts.len()]; keep[0] = true; keep[pts.len() - 1] = true; let mut stack = vec![(0, pts.len() - 1)]; while let Some((a, b)) = stack.pop() { + *work = work.checked_sub((b - a).saturating_sub(1) as u64)?; let (p, q) = (pts[a], pts[b]); let (vx, vy) = (q.0 - p.0, q.1 - p.1); let len = vx.hypot(vy); @@ -227,7 +239,7 @@ fn rdp(pts: &[(f64, f64)], eps: f64) -> Vec<(f64, f64)> { stack.push((i, b)); } } - pts.iter().zip(keep).filter_map(|(p, k)| k.then_some(*p)).collect() + Some(pts.iter().zip(keep).filter_map(|(p, k)| k.then_some(*p)).collect()) } /// The document a missing bevels file starts as: one example bevel, a chamfer with a notch. diff --git a/crates/engine/src/tests/bevels.rs b/crates/engine/src/tests/bevels.rs index 1a77959394..762086bb5f 100644 --- a/crates/engine/src/tests/bevels.rs +++ b/crates/engine/src/tests/bevels.rs @@ -124,6 +124,21 @@ fn a_path_cut_into_too_many_lines_is_skipped() { assert_eq!(read.skipped, [("Wild".to_string(), "its path is too detailed for a bevel".to_string())]); } +/// Simplifying the paths of one file measures at most a fixed number of point-to-line distances: +/// a path that needs more than are left is skipped as too detailed, and a short one still reads. +#[test] +fn simplifying_the_bevels_of_a_file_has_a_work_limit() { + let mut d = Document::new(100.0, 100.0); + let wavy: Vec<(f64, f64)> = (0..=3000).map(|i| (i as f64 / 30.0, i as f64 / 30.0 + 5.0 * (i as f64 / 50.0).sin())).collect(); + add_symbol(&mut d, "Wavy", line(&wavy, false)); + add_symbol(&mut d, "Notch", line(&[(0.0, 0.0), (20.0, 60.0), (70.0, 40.0), (100.0, 100.0)], false)); + let read = bevels::bevels_within(&d, 5_000); + let names: Vec<&str> = read.bevels.iter().map(|b| b.name.as_str()).collect(); + assert_eq!(names, ["Notch"]); + assert_eq!(read.skipped, [("Wavy".to_string(), "its path is too detailed for a bevel".to_string())]); + assert_eq!(bevels_of(&d).bevels.len(), 2); +} + fn rect(s: &mut Session, x: u32) -> NodeId { NodeId(s.execute("shape.rectangle", &json!({"x": x, "y": 100, "width": 60, "height": 60})).unwrap()["id"].as_u64().unwrap()) } diff --git a/docs/mcp.md b/docs/mcp.md index 88f264be96..c5e3df4083 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3521,7 +3521,8 @@ first anchor at the cap's edge to its last at the side wall, across the page acr page along its height, and curves are cut into straight lines of at most 64 points. The file is read when the app starts and again each time VectorCraft saves it; `threeD.bevels.reload` reads it again. A file larger than 64 MB is not read, at most 256 symbols are read, and a symbol that is not one open path, has more than 4,096 anchors, is cut -into more than 8,192 straight lines, has ends that are not apart both across and down, or repeats an earlier name is +into more than 8,192 straight lines, needs more point-to-line distances to simplify than are left of the 40,000,000 +the file may take, has ends that are not apart both across and down, or repeats an earlier name is listed in `skipped`. `threeD.bevels.list` returns each bevel's `name` and `points`, the `file` path, the `skipped` symbols and any read `error`. From b30b317a8afe075c1d8604ab5c1d0e97d279bc25 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 00:08:14 -0800 Subject: [PATCH 07/13] 3D: Extrude & Bevel (Classic) takes bevelProfile as a parameter The Classic params text named bevelName and bevelProfile in one entry, so the parameter check read only bevelName and refused a bevelProfile given to effect.apply or effect.setParams as an unknown parameter. Each key now has its own entry. The parameter-type test lists bevelName and bevelProfile of both extrude effects among the keys with checks of their own: validate_bevel refuses points that do not make a bevel and a name that is not a string. A new test applies a custom bevel to both effects and checks that a name that is not a string is refused with the document unchanged. --- crates/effects/src/catalog.rs | 2 +- crates/engine/src/cmd/params.rs | 4 ++-- crates/engine/src/tests/bevels.rs | 17 +++++++++++++++++ crates/engine/src/tests/params.rs | 3 ++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/effects/src/catalog.rs b/crates/effects/src/catalog.rs index dff0bf6f8e..7171025676 100644 --- a/crates/effects/src/catalog.rs +++ b/crates/effects/src/catalog.rs @@ -210,7 +210,7 @@ pub fn effect_catalog() -> Vec { CLASSIC_EXTRUDE, "Extrude & Bevel (Classic)…", &["Effect", "3D and Materials", "3D (Classic)"], - "{depth: pt (0..2000, 50), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none; or custom, a bevel of the user's own drawn by bevelProfile), bevelHeight: pt (1..100, 4; the bevel is as wide as it is tall), bevelInside: bool (false: added around the shape; true: carved into it), bevelName: string and bevelProfile: [[x, y], …] (a custom bevel's name and points, as for threeD.extrude; bevel {custom: name} takes a bevel of the bevels file), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face, hidden ones included, and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), drawHiddenFaces: bool (false; also draws the faces turned away, behind the others)}. The front face is the art, extruded backwards about the center of its bounds; a solid is built for the top fill and for each stroke, each in its own paint. The defaults are VectorCraft's own.", + "{depth: pt (0..2000, 50), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none; or custom, a bevel of the user's own drawn by bevelProfile), bevelHeight: pt (1..100, 4; the bevel is as wide as it is tall), bevelInside: bool (false: added around the shape; true: carved into it), bevelName: string (a custom bevel's name), bevelProfile: [[x, y], …] (a custom bevel's points, as for threeD.extrude; bevel {custom: name} takes a bevel of the bevels file), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face, hidden ones included, and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), drawHiddenFaces: bool (false; also draws the faces turned away, behind the others)}. The front face is the art, extruded backwards about the center of its bounds; a solid is built for the top fill and for each stroke, each in its own paint. The defaults are VectorCraft's own.", json!({"depth":50.0,"cap":true,"bevel":"none","bevelHeight":4.0,"bevelInside":false,"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"surface":"plastic","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":100.0,"ambient":50.0,"highlightIntensity":60.0,"highlightSize":90.0,"blendSteps":25,"shadingColor":"black","shadingCustom":"#000000","drawHiddenFaces":false}), ), g( diff --git a/crates/engine/src/cmd/params.rs b/crates/engine/src/cmd/params.rs index c38854ae76..1f8a047405 100644 --- a/crates/engine/src/cmd/params.rs +++ b/crates/engine/src/cmd/params.rs @@ -360,8 +360,8 @@ fn check_effect_types(id: &str, effect: &str, params: &Value) -> Result<()> { /// without a dialog default: the earlier 3D Perspective and light (`perspective`, `lightAzimuth`, /// `lightElevation`) and Scribble `variation` are numbers, an Outline Stroke's `width` is a number /// and a Gaussian Blur's `linear` is true or false. A Glass or Texturizer `textureImage`, an SVG -/// filter's `name` and `xml`, a Warp's `version` and the `style` of Crop Marks have checks of their -/// own; they aren't listed. +/// filter's `name` and `xml`, a Warp's `version`, the `style` of Crop Marks and an Extrude & +/// Bevel's custom `bevelName` and `bevelProfile` have checks of their own; they aren't listed. pub(crate) fn undefaulted_type(effect: &str, key: &str) -> Option { use vectorcraft_render::effects; let number = || Some(Value::from(0.0)); diff --git a/crates/engine/src/tests/bevels.rs b/crates/engine/src/tests/bevels.rs index 762086bb5f..662a026023 100644 --- a/crates/engine/src/tests/bevels.rs +++ b/crates/engine/src/tests/bevels.rs @@ -275,6 +275,23 @@ fn a_document_keeps_its_custom_bevels_without_the_bevels_file() { assert!(o.execute("effect.setParams", &bad).unwrap_err().to_string().contains("bevelProfile must be")); } +#[test] +fn both_extrudes_take_a_custom_bevels_points_and_refuse_a_name_that_is_not_a_string() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 300, "height": 300})).unwrap(); + let notch = json!([[0, 0], [0.2, 0.6], [0.7, 0.4], [1, 1]]); + for effect in [effects::EXTRUDE, effects::CLASSIC_EXTRUDE] { + let id = rect(&mut s, 100); + let apply = |name: Value| json!({"effect": effect, "ids": [id.0], "item": null, "params": {"bevel": "custom", "bevelName": name, "bevelProfile": notch}}); + let before = s.doc().unwrap().doc.clone(); + let e = s.execute("effect.apply", &apply(json!(3))).unwrap_err().to_string(); + assert!(e.contains("bevelName must be a string"), "{effect}: {e}"); + assert_eq!(s.doc().unwrap().doc, before, "{effect}"); + s.execute("effect.apply", &apply(json!("Notch"))).unwrap(); + assert_eq!((¶ms(&s, id)[effects::BEVEL_PROFILE], ¶ms(&s, id)[effects::BEVEL_NAME]), (¬ch, &json!("Notch")), "{effect}"); + } +} + #[test] fn without_a_bevels_file_editing_is_refused_and_none_are_listed() { let mut s = Session::new(); diff --git a/crates/engine/src/tests/params.rs b/crates/engine/src/tests/params.rs index e72f607030..ffce7b6db9 100644 --- a/crates/engine/src/tests/params.rs +++ b/crates/engine/src/tests/params.rs @@ -610,11 +610,12 @@ fn an_effect_parameter_without_a_default_is_held_to_its_type() { use crate::cmd::params::undefaulted_type; use vectorcraft_render::effects::effect_catalog; // Read by checks of their own: a stored texture or a texture to load, an SVG filter, a Warp's - // map and the style of Crop Marks. + // map, the style of Crop Marks and a custom bevel's name and points. let own_check = |effect: &str, key: &str| match key { "textureImage" | "name" | "xml" => true, "version" => effect.starts_with("warp."), "style" => effect == "cropMarks", + "bevelName" | "bevelProfile" => matches!(effect, "threeD.extrude" | "threeD.classicExtrude"), _ => false, }; let mut unlisted = vec![]; From d1a3624ca517715315e0ce983f94436538d13089 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 04:29:23 -0800 Subject: [PATCH 08/13] i18n: the custom bevel refusals are translated in the complete-message catalogs Extrude & Bevel refuses a bevel that is not none, a built-in shape or custom, a custom bevel without bevelProfile, points that do not make a bevel, and a bevelName that is not a string. These four messages had no @msg row, so they showed in English in every interface language, and three_d_refusals_are_translated_in_every_complete_catalog failed. Each of the 22 complete-message catalogs gets the four rows. The row for the bevel message is replaced, since the message now ends with the custom value. NAMED_KEYS lists the two messages that name bevel, none and custom without backticks, and three_d_refusals_translate_with_their_values shows each refusal translated with its parameter names and values as written. --- crates/ui-egui/src/i18n/ca.tsv | 5 ++++- crates/ui-egui/src/i18n/cs.tsv | 5 ++++- crates/ui-egui/src/i18n/de.tsv | 5 ++++- crates/ui-egui/src/i18n/el.tsv | 5 ++++- crates/ui-egui/src/i18n/es.tsv | 5 ++++- crates/ui-egui/src/i18n/fi.tsv | 5 ++++- crates/ui-egui/src/i18n/fr.tsv | 5 ++++- crates/ui-egui/src/i18n/hi.tsv | 5 ++++- crates/ui-egui/src/i18n/hu.tsv | 5 ++++- crates/ui-egui/src/i18n/it.tsv | 5 ++++- crates/ui-egui/src/i18n/ja.tsv | 5 ++++- crates/ui-egui/src/i18n/ka.tsv | 5 ++++- crates/ui-egui/src/i18n/ko.tsv | 5 ++++- crates/ui-egui/src/i18n/pl.tsv | 5 ++++- crates/ui-egui/src/i18n/pt-br.tsv | 5 ++++- crates/ui-egui/src/i18n/ru.tsv | 5 ++++- crates/ui-egui/src/i18n/sv.tsv | 5 ++++- crates/ui-egui/src/i18n/tests.rs | 19 ++++++++++++++++++- crates/ui-egui/src/i18n/tr.tsv | 5 ++++- crates/ui-egui/src/i18n/uk.tsv | 5 ++++- crates/ui-egui/src/i18n/vi.tsv | 5 ++++- crates/ui-egui/src/i18n/zh-hans.tsv | 5 ++++- crates/ui-egui/src/i18n/zh-hant.tsv | 5 ++++- 23 files changed, 106 insertions(+), 23 deletions(-) diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 07c2afa971..504c15da91 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -6070,7 +6070,10 @@ digits Malayalam Malaiàlam @msg The 3D object is too complex to export L’objecte 3D és massa complex per exportar-lo @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) l’objecte no té cap efecte 3D (Extrudeix i bisella, Revoluciona, Infla o Gira) @msg its 3D effect builds no solid el seu efecte 3D no construeix cap sòlid -@msg bevel must be none or one of {_1} bevel ha de ser none o un de {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel ha de ser none, un de {_1}, o custom amb {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom necessita {BEVEL_PROFILE}, els punts del bisell +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} ha de ser una cadena +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} ha de tenir de 2 a {most} punts [x, y], cada proporció entre 0 i 1, des de [0, 0] (la vora de la tapa) fins a [1, 1] (la paret lateral) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} no pot construir sòlids a partir d’aquesta il·lustració: les seves instàncies de símbol, fusions i grups de retall contenen massa objectes @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} no pot construir un sòlid a partir de la instància del símbol «{symbol}»: la il·lustració del símbol no està disponible @msg {_1}: the clipping path is too complex to cut the art with {_1}: el traçat de retall és massa complex per retallar-hi la il·lustració diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 8396445906..4f6c67e2c0 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5913,7 +5913,10 @@ mark-style Japanese Japonské @msg The 3D object is too complex to export 3D objekt je pro export příliš složitý @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) objekt nemá žádný 3D efekt (Vysunutí a zkosení, Rotační těleso, Nafouknutí ani Otočit) @msg its 3D effect builds no solid jeho 3D efekt nevytváří žádné těleso -@msg bevel must be none or one of {_1} bevel musí být none nebo jedno z {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel musí být none, jedno z {_1} nebo custom s {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom vyžaduje {BEVEL_PROFILE}, body zkosení +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} musí být řetězec +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} musí mít 2 až {most} bodů [x, y], každý podíl mezi 0 a 1, od [0, 0] (hrana čelní plochy) do [1, 1] (boční stěna) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} nemůže z této kresby vytvořit tělesa: její instance symbolů, prolnutí a ořezové skupiny obsahují příliš mnoho objektů @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} nemůže vytvořit těleso z instance symbolu „{symbol}“: kresba symbolu není k dispozici @msg {_1}: the clipping path is too complex to cut the art with {_1}: ořezová cesta je příliš složitá na oříznutí kresby diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 5696072ba7..0ff0eafd4e 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5488,7 +5488,10 @@ lighting Light Licht @msg The 3D object is too complex to export Das 3D-Objekt ist zu komplex für den Export @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) das Objekt hat keinen 3D-Effekt (Extrudieren und abgeflachte Kante, Kreiseln, Aufblasen oder Drehen) @msg its 3D effect builds no solid sein 3D-Effekt erzeugt keinen Körper -@msg bevel must be none or one of {_1} bevel muss none oder einer der folgenden Werte sein: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel muss none, einer der Werte {_1} oder custom mit {BEVEL_PROFILE} sein +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom benötigt {BEVEL_PROFILE}, die Punkte der abgeflachten Kante +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} muss eine Zeichenfolge sein +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} muss 2 bis {most} Punkte [x, y] enthalten, jeder Anteil zwischen 0 und 1, von [0, 0] (Kante der Deckfläche) bis [1, 1] (Seitenwand) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} kann aus diesem Bildmaterial keine Körper erstellen: Seine Symbolinstanzen, Angleichungen und Schnittgruppen enthalten zu viele Objekte @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} kann keinen Körper aus der Instanz des Symbols „{symbol}“ erstellen: Das Bildmaterial des Symbols ist nicht verfügbar @msg {_1}: the clipping path is too complex to cut the art with {_1}: Der Schnittpfad ist zu komplex, um das Bildmaterial damit zu beschneiden diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index b7b1f81f59..fd3ee29069 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -5272,7 +5272,10 @@ digits Malayalam Μαλαγιάλαμ @msg The 3D object is too complex to export Το αντικείμενο 3D είναι πολύ σύνθετο για εξαγωγή @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) το αντικείμενο δεν έχει εφέ 3D (Εξώθηση και λοξότμηση, Περιστροφή γύρω από άξονα, Φούσκωμα ή Περιστροφή) @msg its 3D effect builds no solid το εφέ 3D του δεν δημιουργεί στερεό -@msg bevel must be none or one of {_1} το bevel πρέπει να είναι none ή ένα από τα {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} το bevel πρέπει να είναι none, ένα από τα {_1} ή custom με {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points το bevel custom χρειάζεται το {BEVEL_PROFILE}, τα σημεία της λοξότμησης +@msg {BEVEL_NAME} must be a string το {BEVEL_NAME} πρέπει να είναι συμβολοσειρά +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) το {BEVEL_PROFILE} πρέπει να έχει 2 έως {most} σημεία [x, y], κάθε αναλογία μεταξύ 0 και 1, από [0, 0] (η ακμή της ακραίας όψης) έως [1, 1] (το πλευρικό τοίχωμα) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1}: δεν μπορούν να δημιουργηθούν στερεά από αυτό το σχέδιο· οι παρουσίες συμβόλων, οι αναμείξεις και οι ομάδες αποκοπής του περιέχουν πάρα πολλά αντικείμενα @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}: δεν μπορεί να δημιουργηθεί στερεό από την παρουσία του συμβόλου «{symbol}»· το σχέδιο του συμβόλου δεν είναι διαθέσιμο @msg {_1}: the clipping path is too complex to cut the art with {_1}: η διαδρομή αποκοπής είναι πολύ σύνθετη για να κόψει το σχέδιο diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index b355e9bf76..1dd915ddcd 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5854,7 +5854,10 @@ mark-style Japanese Japonesas @msg The 3D object is too complex to export El objeto 3D es demasiado complejo para exportarlo @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) el objeto no tiene ningún efecto 3D (Extrusión y biselado, Revolución, Inflar o Rotar) @msg its 3D effect builds no solid su efecto 3D no construye ningún sólido -@msg bevel must be none or one of {_1} bevel debe ser none o uno de estos: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel debe ser none, uno de estos: {_1}, o custom con {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom necesita {BEVEL_PROFILE}, los puntos del bisel +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} debe ser una cadena +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} debe tener de 2 a {most} puntos [x, y], cada proporción entre 0 y 1, desde [0, 0] (el borde de la tapa) hasta [1, 1] (la pared lateral) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} no puede construir sólidos a partir de esta ilustración: sus instancias de símbolo, fusiones y grupos de recorte contienen demasiados objetos @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} no puede construir un sólido a partir de la instancia del símbolo «{symbol}»: la ilustración del símbolo no está disponible @msg {_1}: the clipping path is too complex to cut the art with {_1}: el trazado de recorte es demasiado complejo para recortar la ilustración diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 43d82f356a..5af4dca9df 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5795,7 +5795,10 @@ mark-style Japanese Japanilainen @msg The 3D object is too complex to export 3D-objekti on liian monimutkainen vietäväksi @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) objektilla ei ole 3D-tehostetta (Pursota ja viistä, Pyöräytä, Täytä ilmalla tai Kierrä) @msg its 3D effect builds no solid sen 3D-tehoste ei muodosta kappaletta -@msg bevel must be none or one of {_1} bevel-arvon on oltava none tai jokin seuraavista: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel-arvon on oltava none, jokin seuraavista: {_1}, tai custom yhdessä arvon {BEVEL_PROFILE} kanssa +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom tarvitsee arvon {BEVEL_PROFILE}, viisteen pisteet +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} on oltava merkkijono +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) arvossa {BEVEL_PROFILE} on oltava vähintään 2 ja enintään {most} pistettä [x, y], kukin osuus väliltä 0 ja 1, pisteestä [0, 0] (päätypinnan reuna) pisteeseen [1, 1] (sivuseinä) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} ei voi muodostaa kappaleita tästä kuvituksesta: sen symbolien esiintymät, sulautukset ja leikkausryhmät sisältävät liikaa objekteja @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} ei voi muodostaa kappaletta symbolin ”{symbol}” esiintymästä: symbolin kuvitus ei ole käytettävissä @msg {_1}: the clipping path is too complex to cut the art with {_1}: leikkauspolku on liian monimutkainen kuvituksen leikkaamiseen diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index ac34af8029..996a0e3a3b 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5483,7 +5483,10 @@ lighting Light Lumière @msg The 3D object is too complex to export L'objet 3D est trop complexe pour être exporté @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) l'objet n'a aucun effet 3D (Extrusion et biseautage, Révolution, Gonfler ou Rotation) @msg its 3D effect builds no solid son effet 3D ne construit aucun volume -@msg bevel must be none or one of {_1} bevel doit valoir none ou l’une de ces valeurs : {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel doit valoir none, l’une des valeurs {_1}, ou custom avec {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom nécessite {BEVEL_PROFILE}, les points du biseau +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} doit être une chaîne +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} doit contenir de 2 à {most} points [x, y], chaque proportion entre 0 et 1, de [0, 0] (le bord de la face) à [1, 1] (la paroi latérale) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} ne peut pas construire de volumes à partir de cette illustration : ses occurrences de symbole, dégradés de formes et groupes de découpe contiennent trop d'objets @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} ne peut pas construire de volume à partir de l'occurrence du symbole « {symbol} » : l'illustration du symbole n'est pas disponible @msg {_1}: the clipping path is too complex to cut the art with {_1} : le tracé de découpe est trop complexe pour découper l'illustration diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 47431f6610..c03c3a0c95 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -7896,7 +7896,10 @@ antiAlias Sharp शार्प @msg The 3D object is too complex to export 3D ऑब्जेक्ट एक्सपोर्ट करने के लिए बहुत जटिल है @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) ऑब्जेक्ट पर कोई 3D इफ़ेक्ट नहीं है (एक्सट्रूडेड और बेवेल, रिवॉल्व, फुलाएँ या घुमाव) @msg its 3D effect builds no solid इसका 3D इफ़ेक्ट कोई ठोस नहीं बनाता -@msg bevel must be none or one of {_1} bevel को none या {_1} में से एक होना चाहिए +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel को none, {_1} में से एक, या {BEVEL_PROFILE} के साथ custom होना चाहिए +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom के लिए {BEVEL_PROFILE} चाहिए, यानी बेवल के बिंदु +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} एक स्ट्रिंग होना चाहिए +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} में 2 से {most} [x, y] बिंदु होने चाहिए, हर हिस्सा 0 और 1 के बीच, [0, 0] (सिरे की सतह का किनारा) से [1, 1] (बगल की दीवार) तक @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} इस आर्ट से ठोस नहीं बना सकता: इसके सिंबल इंस्टेंस, ब्लेंड और क्लिपिंग ग्रुप में बहुत अधिक ऑब्जेक्ट हैं @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} सिंबल "{symbol}" के इंस्टेंस से ठोस नहीं बना सकता: सिंबल का आर्ट उपलब्ध नहीं है @msg {_1}: the clipping path is too complex to cut the art with {_1}: क्लिपिंग पाथ आर्ट को काटने के लिए बहुत जटिल है diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index d8365ad8af..8832b5f6ad 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5896,7 +5896,10 @@ imageTrace Outline Körvonal @msg The 3D object is too complex to export A 3D objektum túl összetett az exportáláshoz @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) az objektumnak nincs 3D effektusa (Kihúzás és élletörés, Forgatás tengely körül, Felfújás vagy Elforgatás) @msg its 3D effect builds no solid a 3D effektusa nem hoz létre testet -@msg bevel must be none or one of {_1} a bevel értéke none vagy ezek egyike lehet: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} a bevel értéke none, ezek egyike: {_1}, vagy custom lehet {BEVEL_PROFILE} megadásával +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points a bevel custom értékéhez {BEVEL_PROFILE} kell, az élletörés pontjai +@msg {BEVEL_NAME} must be a string {BEVEL_NAME}: karakterlánc kell +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE}: legalább 2 és legfeljebb {most} [x, y] pont kell, minden arány 0 és 1 között, [0, 0]-tól (a fedőlap éle) [1, 1]-ig (az oldalfal) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1}: ebből a rajzból nem hozható létre test: a szimbólumpéldányai, összemosásai és vágócsoportjai túl sok objektumot tartalmaznak @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}: nem hozható létre test a(z) „{symbol}” szimbólum példányából: a szimbólum rajza nem érhető el @msg {_1}: the clipping path is too complex to cut the art with {_1}: a vágóútvonal túl összetett a rajz kivágásához diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 7e9f51fd86..0f9ebc3d11 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5530,7 +5530,10 @@ lighting Light Luce @msg The 3D object is too complex to export L'oggetto 3D è troppo complesso per essere esportato @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) l'oggetto non ha alcun effetto 3D (Estrusione e smusso, Rivoluzione, Gonfia o Ruota) @msg its 3D effect builds no solid il suo effetto 3D non costruisce alcun solido -@msg bevel must be none or one of {_1} bevel deve essere none o uno dei seguenti: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel deve essere none, uno dei seguenti: {_1}, oppure custom con {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom richiede {BEVEL_PROFILE}, i punti dello smusso +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} deve essere una stringa +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} deve contenere da 2 a {most} punti [x, y], ogni proporzione tra 0 e 1, da [0, 0] (il bordo della faccia) a [1, 1] (la parete laterale) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} non può costruire solidi da questo disegno: le sue istanze di simbolo, fusioni e gruppi di ritaglio contengono troppi oggetti @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} non può costruire un solido dall'istanza del simbolo «{symbol}»: il disegno del simbolo non è disponibile @msg {_1}: the clipping path is too complex to cut the art with {_1}: il tracciato di ritaglio è troppo complesso per ritagliare il disegno diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 2ea992ffa3..fc1d897439 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5572,7 +5572,10 @@ lighting Light ライト @msg The 3D object is too complex to export 3D オブジェクトが複雑すぎるため書き出せません @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) オブジェクトに 3D 効果 (押し出しとベベル、回転体、膨張、回転) がありません @msg its 3D effect builds no solid 3D 効果からソリッドが作成されません -@msg bevel must be none or one of {_1} bevel には none または {_1} のいずれかを指定してください +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel には none、{_1} のいずれか、または {BEVEL_PROFILE} を付けた custom を指定してください +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom にはベベルのポイントを表す {BEVEL_PROFILE} が必要です +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} は文字列にしてください +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} には 2 個から {most} 個の [x, y] ポイントを、各値を 0 から 1 までの割合として、[0, 0] (端面の縁) から [1, 1] (側面の壁) まで指定してください @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} はこのアートからソリッドを作成できません。シンボルインスタンス、ブレンド、クリッピンググループに含まれるオブジェクトが多すぎます @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} はシンボル「{symbol}」のインスタンスからソリッドを作成できません。シンボルのアートを使用できません @msg {_1}: the clipping path is too complex to cut the art with {_1}: クリッピングパスが複雑すぎるため、アートを切り抜けません diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 92f41cb979..cc45d1c9ac 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -5201,7 +5201,10 @@ font-technology Variable ცვლადი @msg The 3D object is too complex to export 3D ობიექტი ზედმეტად რთულია ექსპორტისთვის @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) ობიექტს არ აქვს 3D ეფექტი (ამოწევა და წაკვეთა, ბრუნვა, გაბერვა ან შემობრუნება) @msg its 3D effect builds no solid მისი 3D ეფექტი სხეულს არ ქმნის -@msg bevel must be none or one of {_1} bevel უნდა იყოს none ან ერთ-ერთი: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel უნდა იყოს none, ერთ-ერთი: {_1}, ან custom და {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom მოითხოვს {BEVEL_PROFILE}, წაკვეთის წერტილები +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} უნდა იყოს სტრიქონი +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} უნდა შეიცავდეს 2-დან {most}-მდე [x, y] წერტილს, თითოეული წილი 0-სა და 1-ს შორის, [0, 0]-დან (ბოლო წახნაგის კიდე) [1, 1]-მდე (გვერდითი კედელი) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1}: ამ ნახატიდან სხეულების შექმნა შეუძლებელია: მისი სიმბოლოს ეგზემპლარები, გადასვლები და მომჭრელი ჯგუფები ზედმეტად ბევრ ობიექტს შეიცავს @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}: სიმბოლოს „{symbol}“ ეგზემპლარიდან სხეულის შექმნა შეუძლებელია: სიმბოლოს ნახატი მიუწვდომელია @msg {_1}: the clipping path is too complex to cut the art with {_1}: მომჭრელი ტრაექტორია ზედმეტად რთულია ნახატის მოსაჭრელად diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index cfc9501444..17283b3331 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5491,7 +5491,10 @@ lighting Light 광원 @msg The 3D object is too complex to export 3D 개체가 너무 복잡하여 내보낼 수 없습니다 @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) 개체에 3D 효과(돌출 및 경사, 회전체, 부풀리기 또는 회전)가 없습니다 @msg its 3D effect builds no solid 3D 효과가 입체를 만들지 않습니다 -@msg bevel must be none or one of {_1} bevel은 none 또는 {_1} 중 하나여야 합니다 +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel은 none, {_1} 중 하나 또는 {BEVEL_PROFILE}을(를) 함께 지정한 custom이어야 합니다 +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom에는 베벨의 포인트인 {BEVEL_PROFILE}이(가) 필요합니다 +@msg {BEVEL_NAME} must be a string {BEVEL_NAME}은(는) 문자열이어야 합니다 +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE}은(는) 2개에서 {most}개의 [x, y] 포인트여야 하며, 각 값은 0과 1 사이의 비율이고 [0, 0](끝면의 가장자리)에서 [1, 1](옆면 벽)까지여야 합니다 @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1}은(는) 이 아트로 입체를 만들 수 없습니다. 심볼 인스턴스, 블렌드, 클리핑 그룹에 개체가 너무 많습니다 @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}은(는) 심볼 “{symbol}”의 인스턴스로 입체를 만들 수 없습니다. 심볼의 아트를 사용할 수 없습니다 @msg {_1}: the clipping path is too complex to cut the art with {_1}: 클리핑 패스가 너무 복잡하여 아트를 자를 수 없습니다 diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 222d94da1c..fd0f47f934 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5743,7 +5743,10 @@ mark-style Japanese Japońskie @msg The 3D object is too complex to export Obiekt 3D jest zbyt złożony, aby go wyeksportować @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) obiekt nie ma efektu 3D (Wyciągnięcie i fazowanie, Obrót, Nadmuchanie ani Obróć) @msg its 3D effect builds no solid jego efekt 3D nie tworzy żadnej bryły -@msg bevel must be none or one of {_1} bevel musi mieć wartość none lub jedną z: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel musi mieć wartość none, jedną z: {_1}, albo custom z {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom wymaga {BEVEL_PROFILE}, punktów fazy +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} musi być ciągiem znaków +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} musi zawierać od 2 do {most} punktów [x, y], każdy udział od 0 do 1, od [0, 0] (krawędź ściany czołowej) do [1, 1] (ściana boczna) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} nie może utworzyć brył z tego rysunku: jego wystąpienia symboli, przejścia i grupy przycinające zawierają zbyt wiele obiektów @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} nie może utworzyć bryły z wystąpienia symbolu „{symbol}”: rysunek symbolu jest niedostępny @msg {_1}: the clipping path is too complex to cut the art with {_1}: ścieżka przycinająca jest zbyt złożona, aby przyciąć nią rysunek diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 9ec0405da1..64ac432868 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -5862,7 +5862,10 @@ mark-style Japanese Japonesas @msg The 3D object is too complex to export O objeto 3D é complexo demais para ser exportado @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) o objeto não tem efeito 3D (Extrusão e Bisel, Revolver, Inflar ou Girar) @msg its 3D effect builds no solid seu efeito 3D não constrói nenhum sólido -@msg bevel must be none or one of {_1} bevel deve ser none ou um de {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel deve ser none, um de {_1}, ou custom com {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom precisa de {BEVEL_PROFILE}, os pontos do chanfro +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} deve ser uma string +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} deve ter de 2 a {most} pontos [x, y], cada proporção entre 0 e 1, de [0, 0] (a borda da tampa) a [1, 1] (a parede lateral) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} não pode construir sólidos a partir desta arte: suas instâncias de símbolo, mesclagens e grupos de recorte contêm objetos demais @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} não pode construir um sólido a partir da instância do símbolo “{symbol}”: a arte do símbolo não está disponível @msg {_1}: the clipping path is too complex to cut the art with {_1}: o caminho de recorte é complexo demais para recortar a arte diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 6bc6c821e7..30ad6d9d54 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5516,7 +5516,10 @@ lighting Light Свет @msg The 3D object is too complex to export 3D-объект слишком сложен для экспорта @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) у объекта нет 3D-эффекта (Выдавливание и фаска, Вращение, Надувание или Повернуть) @msg its 3D effect builds no solid его 3D-эффект не строит тела -@msg bevel must be none or one of {_1} bevel должен быть none или одним из: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel должен быть none, одним из: {_1}, или custom с {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points для bevel custom нужен {BEVEL_PROFILE}, точки фаски +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} должно быть строкой +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} должен содержать от 2 до {most} точек [x, y], каждая доля от 0 до 1, от [0, 0] (край торца) до [1, 1] (боковая стенка) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1}: нельзя построить тела из этой иллюстрации: её экземпляры символов, переходы и обтравочные группы содержат слишком много объектов @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}: нельзя построить тело из экземпляра символа «{symbol}»: иллюстрация символа недоступна @msg {_1}: the clipping path is too complex to cut the art with {_1}: обтравочный контур слишком сложен, чтобы обрезать им иллюстрацию diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 3ac5bb0167..08e094aa48 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -5384,7 +5384,10 @@ lighting Light Ljus @msg The 3D object is too complex to export 3D-objektet är för komplext för att exporteras @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) objektet har ingen 3D-effekt (Extrudera och fasa, Rotera runt axel, Blås upp eller Rotera) @msg its 3D effect builds no solid dess 3D-effekt bygger ingen solid -@msg bevel must be none or one of {_1} bevel måste vara none eller något av {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel måste vara none, något av {_1} eller custom med {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom kräver {BEVEL_PROFILE}, fasningens punkter +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} måste vara en sträng +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} måste vara 2 till {most} punkter [x, y], varje andel mellan 0 och 1, från [0, 0] (ändytans kant) till [1, 1] (sidoväggen) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} kan inte bygga solider av den här teckningen: dess symbolinstanser, blandningar och urklippsgrupper innehåller för många objekt @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} kan inte bygga en solid av instansen av symbolen ”{symbol}”: symbolens teckning är inte tillgänglig @msg {_1}: the clipping path is too complex to cut the art with {_1}: urklippsbanan är för komplex för att klippa teckningen med diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 66caa1c3a4..9f5f198548 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -2072,6 +2072,22 @@ fn three_d_refusals_translate_with_their_values() { (refuse(vectorcraft_effects::validate_three_d(&rect, CLASSIC_EXTRUDE, &json!({"depth": "deep"}))), "must be a number", vec!["`depth`"]), (refuse(vectorcraft_effects::validate_three_d(&instance, EXTRUDE, &json!({}))), "the symbol's art isn't available", vec!["Mine 7"]), (refuse(vectorcraft_effects::three_d_wireframe_in(None, &rect).map(drop)), "has no 3D effect", vec![]), + ( + refuse(vectorcraft_effects::validate_three_d(&rect, EXTRUDE, &json!({"bevel": "wavy"}))), + "or custom with", + vec!["none", "classic", "custom", "bevelProfile"], + ), + ( + refuse(vectorcraft_effects::validate_three_d(&rect, EXTRUDE, &json!({"bevel": "custom"}))), + "the bevel's points", + vec!["custom", "bevelProfile"], + ), + (refuse(vectorcraft_effects::validate_three_d(&rect, CLASSIC_EXTRUDE, &json!({"bevelName": 3}))), "must be a string", vec!["bevelName"]), + ( + refuse(vectorcraft_effects::validate_three_d(&rect, EXTRUDE, &json!({"bevel": "custom", "bevelProfile": [[0, 0]]}))), + "each share between", + vec!["bevelProfile", "[x, y]", "[0, 0]", "[1, 1]"], + ), ]; for (e, english, _) in &errors { assert!(e.starts_with("invalid parameters for `effect.apply`: ") && e.contains(english), "{e}"); @@ -3473,7 +3489,8 @@ const NAMED_KEYS: &[(&str, &[&str])] = &[ ("axis must be \"vertical\", \"horizontal\" or an angle in degrees, not `{v}`", &["axis"]), ("balance must be between 0 and 100", &["balance"]), ("before must name a panel", &["before"]), - ("bevel must be none or one of {_1}", &["bevel", "none"]), + ("bevel custom needs {BEVEL_PROFILE}, the bevel's points", &["bevel", "custom"]), + ("bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE}", &["bevel", "none", "custom"]), ("brightness must be dark|mediumDark|mediumLight|light", &["brightness", "dark", "mediumDark", "mediumLight", "light"]), ("clip must be true or false", &["clip"]), ("collapsed must be true or false", &["collapsed"]), diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index bd5f48dbf6..6a99217906 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -5179,7 +5179,10 @@ lighting Light Işık @msg The 3D object is too complex to export 3 boyutlu nesne dışa aktarmak için çok karmaşık @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) nesnenin 3 boyutlu efekti yok (Ekstrüzyon ve Eğim, Döndür, Şişir veya Döndür) @msg its 3D effect builds no solid 3 boyutlu efekti hiçbir katı oluşturmuyor -@msg bevel must be none or one of {_1} bevel, none veya {_1} değerlerinden biri olmalıdır +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel; none, {_1} değerlerinden biri veya {BEVEL_PROFILE} ile custom olmalıdır +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom için {BEVEL_PROFILE}, yani eğimin noktaları gerekir +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} bir dize olmalıdır +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE}, 2 ile {most} arasında [x, y] noktası olmalıdır; her oran 0 ile 1 arasında, [0, 0] (uç yüzeyin kenarı) ile [1, 1] (yan duvar) arasında @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} bu resimden katı oluşturamaz: sembol örnekleri, karışımları ve kırpma grupları çok fazla nesne içeriyor @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}, “{symbol}” sembolünün örneğinden katı oluşturamaz: sembolün resmi kullanılamıyor @msg {_1}: the clipping path is too complex to cut the art with {_1}: kırpma yolu resmi kesmek için çok karmaşık diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index a3315af982..8cd8dec590 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5510,7 +5510,10 @@ lighting Light Світло @msg The 3D object is too complex to export 3D-об’єкт надто складний для експорту @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) об’єкт не має 3D-ефекту (Видавлювання та фаска, Обертання, Надування або Повернути) @msg its 3D effect builds no solid його 3D-ефект не будує тіла -@msg bevel must be none or one of {_1} bevel має бути none або одним з: {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel має бути none, одним з: {_1}, або custom з {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points для bevel custom потрібен {BEVEL_PROFILE}, точки фаски +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} має бути рядком +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} має містити від 2 до {most} точок [x, y], кожна частка від 0 до 1, від [0, 0] (край торця) до [1, 1] (бічна стінка) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1}: не вдається побудувати тіла з цієї ілюстрації: її екземпляри символів, переходи та відсічні групи містять забагато об’єктів @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}: не вдається побудувати тіло з екземпляра символу «{symbol}»: ілюстрація символу недоступна @msg {_1}: the clipping path is too complex to cut the art with {_1}: відсічний контур надто складний, щоб обрізати ним ілюстрацію diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index de821105c5..ec48e28a02 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5297,7 +5297,10 @@ theme Appearance Giao diện @msg The 3D object is too complex to export Đối tượng 3D quá phức tạp để xuất @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) đối tượng không có hiệu ứng 3D (Kéo dài & vát, Xoay tròn, Phình hoặc Xoay) @msg its 3D effect builds no solid hiệu ứng 3D của nó không tạo ra khối nào -@msg bevel must be none or one of {_1} bevel phải là none hoặc một trong {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel phải là none, một trong {_1}, hoặc custom kèm {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom cần {BEVEL_PROFILE}, các điểm của kiểu vát +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} phải là một chuỗi +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} phải có từ 2 đến {most} điểm [x, y], mỗi tỷ lệ từ 0 đến 1, từ [0, 0] (cạnh của mặt đầu) đến [1, 1] (thành bên) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} không thể tạo khối từ hình vẽ này: các phiên bản ký hiệu, hòa trộn và nhóm cắt của nó chứa quá nhiều đối tượng @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} không thể tạo khối từ phiên bản của ký hiệu “{symbol}”: không có hình vẽ của ký hiệu @msg {_1}: the clipping path is too complex to cut the art with {_1}: đường dẫn cắt quá phức tạp để cắt hình vẽ diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index b30a2c156e..6e29d61f60 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5786,7 +5786,10 @@ lighting Light 光源 @msg The 3D object is too complex to export 3D 对象过于复杂,无法导出 @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) 该对象没有 3D 效果(突出与斜角、回转、膨胀或旋转) @msg its 3D effect builds no solid 其 3D 效果未生成任何实体 -@msg bevel must be none or one of {_1} bevel 必须是 none 或 {_1} 之一 +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel 必须是 none、{_1} 之一,或带 {BEVEL_PROFILE} 的 custom +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom 需要 {BEVEL_PROFILE},即斜角的点 +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} 必须是字符串 +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} 必须是 2 到 {most} 个 [x, y] 点,每个比例在 0 到 1 之间,从 [0, 0](端面的边缘)到 [1, 1](侧壁) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1}无法从此图稿生成实体:其符号实例、混合和剪切组包含的对象过多 @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}无法从符号“{symbol}”的实例生成实体:该符号的图稿不可用 @msg {_1}: the clipping path is too complex to cut the art with {_1}:剪切路径过于复杂,无法用来剪切图稿 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index c8ccb0e900..cbf85fdd24 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -5618,7 +5618,10 @@ lighting Light 光源 @msg The 3D object is too complex to export 3D 物件過於複雜,無法匯出 @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) 此物件沒有 3D 效果 (突出與斜角、迴轉、膨脹或旋轉) @msg its 3D effect builds no solid 其 3D 效果沒有產生任何實體 -@msg bevel must be none or one of {_1} bevel 必須是 none 或 {_1} 其中之一 +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel 必須是 none、{_1} 其中之一,或帶有 {BEVEL_PROFILE} 的 custom +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom 需要 {BEVEL_PROFILE},也就是斜角的點 +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} 必須是字串 +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} 必須是 2 到 {most} 個 [x, y] 點,每個比例介於 0 和 1 之間,從 [0, 0](端面的邊緣)到 [1, 1](側壁) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1}無法從此圖稿產生實體:其符號實例、漸變和剪裁群組包含的物件過多 @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label}無法從符號「{symbol}」的實例產生實體:該符號的圖稿無法使用 @msg {_1}: the clipping path is too complex to cut the art with {_1}:剪裁路徑過於複雜,無法用來剪裁圖稿 From 12fc7e19a8134e3771bcfdb6700fa395ea0b9cd9 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 07:58:04 -0800 Subject: [PATCH 09/13] i18n: Dutch rows for 3D custom bevel messages --- crates/ui-egui/src/i18n/nl.tsv | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 8f09c8b3f2..6c6d386de1 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5861,7 +5861,10 @@ mark-style Japanese Japans @msg The 3D object is too complex to export Het 3D-object is te complex om te exporteren @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) het object heeft geen 3D-effect (Extruderen en afschuinen, Draaien, Opblazen of Roteren) @msg its 3D effect builds no solid het 3D-effect ervan maakt geen massief object -@msg bevel must be none or one of {_1} bevel moet none of een van {_1} zijn +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel moet none, een van {_1} of custom met {BEVEL_PROFILE} zijn +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom heeft {BEVEL_PROFILE} nodig, de punten van de afschuining +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} moet een tekenreeks zijn +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} moet 2 tot {most} punten [x, y] bevatten, elk aandeel tussen 0 en 1, van [0, 0] (de rand van de bovenkant) tot [1, 1] (de zijwand) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} kan van deze illustratie geen massieve objecten maken: de symboolinstanties, vermengingen en knipgroepen ervan bevatten te veel objecten @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} kan geen massief object maken van de instantie van symbool "{symbol}": de illustratie van het symbool is niet beschikbaar @msg {_1}: the clipping path is too complex to cut the art with {_1}: het knippad is te complex om de illustratie mee uit te knippen From 4f4a39a756f5bd7bd5f5a8ed80ff61ccb2100064 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 20:36:23 -0800 Subject: [PATCH 10/13] 3D: Bevel Shape labels an effect's own custom bevel apart from a file bevel of the same name When the bevels file lists a bevel with the name of the effect's own custom bevel but other points, the effect's entry is now shown as " (document)", and the menu marks the current entry by its position instead of its label, so two entries are no longer both shown as selected. --- crates/ui-egui/src/dialogs/revolve.rs | 20 +++++++++++++++++--- crates/ui-egui/src/i18n/bg.tsv | 1 + crates/ui-egui/src/i18n/bs.tsv | 1 + crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/hi.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/vi.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + crates/ui-egui/src/panels/tests_three_d.rs | 22 ++++++++++++++++++++++ 29 files changed, 66 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs index 1349146f59..67cd08fda2 100644 --- a/crates/ui-egui/src/dialogs/revolve.rs +++ b/crates/ui-egui/src/dialogs/revolve.rs @@ -244,7 +244,7 @@ pub(crate) type BevelChoice = (String, Value, Option<(String, Value)>); /// The entries of [`bevel_choice`]'s menu for form `fields`, and how many are built in. The /// built-in labels are translated; custom bevels show their names as they are. The effect's own /// custom bevel, the panel's [`OWN_BEVEL`] else the form's, is listed unless the file lists it by -/// name with the same points. +/// name with the same points; while another entry has its label, " (document)" is added to it. pub(crate) fn bevel_options(app: &VectorcraftApp, fields: &serde_json::Map, effect: &str) -> (Vec, usize) { let mut options: Vec = super::effect::own_choices(effect, "bevel", false) .unwrap_or_default() @@ -266,7 +266,11 @@ pub(crate) fn bevel_options(app: &VectorcraftApp, fields: &serde_json::Map = options.iter().map(|(l, _, _)| l.as_str()).collect(); let shown = current.and_then(|i| labels.get(i)).copied().unwrap_or(""); let width = VALUE_W + rail_width(ui) + 6.0; - if let Some(k) = widgets::dropdown_names(ui, ("three-d-choice", KEY), shown, &labels, width) + // Marked by index, not label: a custom bevel's name can match another entry's label. + let picked = widgets::combo(ui, ("three-d-choice", KEY), shown, width, |ui| { + let mut chosen = None; + for (i, l) in labels.iter().enumerate() { + if ui.add(egui::Button::selectable(current == Some(i), *l)).clicked() { + chosen = Some(i); + } + } + chosen + }); + if let Some(k) = picked && let Some((_, v, c)) = options.get(k) { d.fields.insert(KEY.into(), v.clone()); diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index f02f16bf8d..ae3b94d5bd 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -2863,6 +2863,7 @@ digits Malayalam Малаялам Bevels Фаски Edit Bevels Редактиране на фаски Edit Bevels… Редактиране на фаски… + {name} (document) {name} (документ) Reload Bevels Презареждане на фаски Reset Rotate View Нулиране на изгледа на завъртане Rotate View to Selection Завъртане на изгледа спрямо селекцията diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 67a7bda96b..951f200c97 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -3969,6 +3969,7 @@ theme Appearance Izgled Bevels Zakošenja Edit Bevels Uredi zakošenja Edit Bevels… Uredi zakošenja… + {name} (document) {name} (dokument) Reload Bevels Ponovo učitaj zakošenja Stroke Options Opcije poteza Width Profiles Profili širine diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index f0fcf70843..1a5bd0db89 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -3653,6 +3653,7 @@ digits Malayalam Malaiàlam Bevels Bisells Edit Bevels Edita els bisells Edit Bevels… Edita els bisells… + {name} (document) {name} (document) Reload Bevels Torna a carregar els bisells Reset Rotate View Restableix la rotació de la vista Reset Ruler Origin Restableix l’origen de les regles diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 7551245ad4..7cd2f320d0 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -4025,6 +4025,7 @@ theme Appearance Motiv Bevels Zkosení Edit Bevels Upravit zkosení Edit Bevels… Upravit zkosení… + {name} (document) {name} (dokument) Reload Bevels Znovu načíst zkosení Stroke Options Možnosti tahu Width Profiles Profily šířky diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 647029e27b..4497c29285 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3742,6 +3742,7 @@ theme Appearance Udseende Bevels Facetter Edit Bevels Redigér facetter Edit Bevels… Redigér facetter… + {name} (document) {name} (dokument) Reload Bevels Genindlæs facetter Stroke Options Konturindstillinger Width Profiles Breddeprofiler diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 0ee03555da..77bd9379c1 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2908,6 +2908,7 @@ digits Malayalam Malayalam Bevels Abgeflachte Kanten Edit Bevels Abgeflachte Kanten bearbeiten Edit Bevels… Abgeflachte Kanten bearbeiten… + {name} (document) {name} (Dokument) Reload Bevels Abgeflachte Kanten neu laden Rotate View Ansicht drehen Reset Rotate View Ansichtsdrehung zurücksetzen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 6c33aa87dd..d1accb5171 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3645,6 +3645,7 @@ digits Malayalam Μαλαγιάλαμ Bevels Λοξοτμήσεις Edit Bevels Επεξεργασία λοξοτμήσεων Edit Bevels… Επεξεργασία λοξοτμήσεων… + {name} (document) {name} (έγγραφο) Reload Bevels Επαναφόρτωση λοξοτμήσεων Reset Rotate View Επαναφορά περιστροφής προβολής Rotate View to Selection Περιστροφή προβολής ως προς την επιλογή diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 15c12dcdcd..e8532b277f 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2942,6 +2942,7 @@ digits Malayalam Malayálam Bevels Biseles Edit Bevels Editar biseles Edit Bevels… Editar biseles… + {name} (document) {name} (documento) Reload Bevels Volver a cargar biseles Reset Rotate View Restablecer rotación de vista Rotate View to Selection Rotar vista según la selección diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 9fd972ee9a..32d59f95c6 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -3949,6 +3949,7 @@ theme Appearance Ulkoasu Bevels Viisteet Edit Bevels Muokkaa viisteitä Edit Bevels… Muokkaa viisteitä… + {name} (document) {name} (asiakirja) Reload Bevels Lataa viisteet uudelleen Stroke Options Viivan asetukset Width Profiles Leveysprofiilit diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 06df1b4bd3..a7427096d7 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2934,6 +2934,7 @@ digits Malayalam Malayalam Bevels Biseaux Edit Bevels Modifier les biseaux Edit Bevels… Modifier les biseaux… + {name} (document) {name} (document) Reload Bevels Recharger les biseaux Reset Rotate View Réinitialiser la rotation de l’affichage Rotate View to Selection Faire pivoter l’affichage selon la sélection diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 22525881b4..d00f5c1fd1 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -4016,6 +4016,7 @@ antiAlias Sharp शार्प Bevels बेवल्स Edit Bevels बेवल्स संपादित करें Edit Bevels… बेवल्स संपादित करें… + {name} (document) {name} (दस्तावेज़) Reload Bevels बेवल्स फिर से लोड करें Reset Rotate View व्यू घुमाएँ रीसेट करें Reset Ruler Origin शासकीय उत्पत्ति रीसेट करें diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 5ec8045a85..e9545c5ba7 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3500,6 +3500,7 @@ mark-style Japanese Japán Bevels Élletörések Edit Bevels Élletörések szerkesztése Edit Bevels… Élletörések szerkesztése… + {name} (document) {name} (dokumentum) Reload Bevels Élletörések újratöltése Reset Rotate View Nézetforgatás visszaállítása Rotate View to Selection Nézet elforgatása a kijelöléshez diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 5042d4217b..d50bdaa3a2 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3742,6 +3742,7 @@ theme Appearance Tampilan Bevels Bentuk bevel Edit Bevels Edit bentuk bevel Edit Bevels… Edit bentuk bevel… + {name} (document) {name} (dokumen) Reload Bevels Muat ulang bentuk bevel Stroke Options Opsi goresan Width Profiles Profil lebar diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index e6815869dc..64d173ee28 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2984,6 +2984,7 @@ digits Malayalam Malayalam Bevels Smussi Edit Bevels Modifica smussi Edit Bevels… Modifica smussi… + {name} (document) {name} (documento) Reload Bevels Ricarica smussi Rotate View Ruota vista Reset Rotate View Reimposta rotazione vista diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 3c431b95be..3069ccbb6d 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -2992,6 +2992,7 @@ mark-style Japanese 日本式 Bevels ベベル一覧 Edit Bevels ベベルを編集 Edit Bevels… ベベルを編集… + {name} (document) {name} (ドキュメント) Reload Bevels ベベルを再読み込み Reset the rows to the artwork's colors 行をアートワークのカラーにリセット Color Theme Picker カラーテーマピッカー diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index adfdb887a7..a588c5d4fa 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -3585,6 +3585,7 @@ theme Appearance იერსახე Bevels წაკვეთები Edit Bevels წაკვეთების რედაქტირება Edit Bevels… წაკვეთების რედაქტირება… + {name} (document) {name} (დოკუმენტი) Reload Bevels წაკვეთების ხელახლა ჩატვირთვა Stroke Options კონტურის პარამეტრები Width Profiles სიგანის პროფილები diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index b46074af26..ea9e95c05e 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -2981,6 +2981,7 @@ mark-style Japanese 일본식 Bevels 베벨 목록 Edit Bevels 베벨 편집 Edit Bevels… 베벨 편집… + {name} (document) {name}(문서) Reload Bevels 베벨 다시 불러오기 Reset the rows to the artwork's colors 행을 아트웍 색상으로 재설정 Color Theme Picker 색상 테마 피커 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 7f598529c7..2642155c8f 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -4259,6 +4259,7 @@ theme Appearance Vormgeving Bevels Afschuiningen Edit Bevels Afschuiningen bewerken Edit Bevels… Afschuiningen bewerken… + {name} (document) {name} (document) Reload Bevels Afschuiningen opnieuw laden Stroke Options Lijnopties Width Profiles Breedteprofielen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 8bbb4100c8..8e59033370 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3888,6 +3888,7 @@ theme Appearance Wygląd Bevels Fazy Edit Bevels Edytuj fazy Edit Bevels… Edytuj fazy… + {name} (document) {name} (dokument) Reload Bevels Wczytaj ponownie fazy Stroke Options Opcje obrysu Width Profiles Profile szerokości diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index f0a1110f02..71410dbff7 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2475,6 +2475,7 @@ digits Malayalam Malaiala Bevels Chanfros Edit Bevels Editar Chanfros Edit Bevels… Editar Chanfros… + {name} (document) {name} (documento) Reload Bevels Recarregar Chanfros Rotate View Girar Visualização Reset Rotate View Redefinir Visualização Girada diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index dc2c2e54b9..957042a1c1 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2971,6 +2971,7 @@ digits Malayalam Малаялам Bevels Фаски Edit Bevels Редактировать фаски Edit Bevels… Редактировать фаски… + {name} (document) {name} (документ) Reload Bevels Перезагрузить фаски Rotate View Повернуть вид Reset Rotate View Сбросить поворот вида diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 791dec357e..ef1cb74a6f 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -2878,6 +2878,7 @@ digits Malayalam Malayalam Bevels Fasningar Edit Bevels Redigera fasningar Edit Bevels… Redigera fasningar… + {name} (document) {name} (dokument) Reload Bevels Läs in fasningar igen Reset Rotate View Återställ Rotera vy Rotate View to Selection Rotera vyn efter markeringen diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index b1ae6df145..6a1b615d69 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2721,6 +2721,7 @@ digits Malayalam Malayalam Bevels Eğimler Edit Bevels Eğimleri Düzenle Edit Bevels… Eğimleri Düzenle… + {name} (document) {name} (belge) Reload Bevels Eğimleri Yeniden Yükle Reset Rotate View Döndürme Görünümünü Sıfırla Rotate View to Selection Görünümü Seçime Döndür diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 36ca63094b..a30e3df5c7 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2976,6 +2976,7 @@ digits Malayalam Малаялам Bevels Фаски Edit Bevels Редагувати фаски Edit Bevels… Редагувати фаски… + {name} (document) {name} (документ) Reload Bevels Перезавантажити фаски Rotate View Повернути вид Reset Rotate View Скинути поворот виду diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 20f21181bc..fa5a3718d0 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3269,6 +3269,7 @@ mark-style Japanese Kiểu Nhật Bevels Các kiểu vát Edit Bevels Chỉnh sửa kiểu vát Edit Bevels… Chỉnh sửa kiểu vát… + {name} (document) {name} (tài liệu) Reload Bevels Tải lại kiểu vát Rotate View Xoay chế độ xem Reset Rotate View Đặt lại xoay chế độ xem diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 2b5732b80e..3a25db6cc2 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2838,6 +2838,7 @@ digits Malayalam 马拉雅拉姆数字 Bevels 斜角列表 Edit Bevels 编辑斜角 Edit Bevels… 编辑斜角… + {name} (document) {name} (文档) Reload Bevels 重新载入斜角 Reset Rotate View 重置旋转视图 Rotate View to Selection 按所选对象旋转视图 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 2bb793d5e1..ea7b547462 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -4055,6 +4055,7 @@ digits Malayalam 馬來亞拉姆數字 Bevels 斜角清單 Edit Bevels 編輯斜角 Edit Bevels… 編輯斜角… + {name} (document) {name} (文件) Reload Bevels 重新載入斜角 Rotate View 旋轉檢視 Reset Rotate View 重設旋轉檢視 diff --git a/crates/ui-egui/src/panels/tests_three_d.rs b/crates/ui-egui/src/panels/tests_three_d.rs index 76e205745a..bb03045dea 100644 --- a/crates/ui-egui/src/panels/tests_three_d.rs +++ b/crates/ui-egui/src/panels/tests_three_d.rs @@ -311,6 +311,28 @@ fn a_mixed_selection_still_lists_the_first_effects_own_custom_bevel() { } } +/// An effect's own custom bevel named like a bevel of the bevels file with other points is listed +/// under its own label, so Bevel Shape does not show two entries of one name. +#[test] +fn an_own_custom_bevel_named_like_a_file_bevel_gets_its_own_label() { + use crate::dialogs::revolve::bevel_options; + let dir = std::env::temp_dir().join(format!("vectorcraft-ui-bevels-own-label-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + let mut app = app(); + app.session.attach_bevels_file(dir.join(vectorcraft_engine::cmd::bevels::FILE_NAME).to_string_lossy().to_string()); + app.run("threeD.bevels.edit", json!({})).unwrap(); + let file = app.session.bevels.get("Example Bevel").unwrap().profile_json(); + let other = json!([[0.0, 0.0], [0.5, 0.5], [1.0, 1.0]]); + assert_ne!(file, other); + let fields = json!({"bevel": "custom", "bevelName": "Example Bevel", "bevelProfile": other}).as_object().cloned().unwrap(); + let (options, builtin) = bevel_options(&app, &fields, "threeD.extrude"); + let _ = std::fs::remove_dir_all(&dir); + let labels: Vec<&str> = options[builtin..].iter().map(|(l, _, _)| l.as_str()).collect(); + assert_eq!(labels, ["Example Bevel", "Example Bevel (document)"]); + assert_eq!(options[builtin + 1].2, Some(("Example Bevel".to_string(), other))); +} + #[test] fn the_panel_finds_a_3d_effect_on_a_fill() { let mut app = app(); From 118b27d3adc34ec34853d19a3af2d316ab429735 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 21:17:27 -0800 Subject: [PATCH 11/13] 3D: keep agents to the bevels file inside their read roots Under automation read roots, threeD.bevels.list gives `file` as null for a bevels file outside them and names it by its file name in `error`. threeD.bevels.edit and threeD.bevels.reload refuse such a file with the root-check error, naming it by its file name: edit makes no folder or file and neither opens nor activates the file, and reload does not read it. Inside the roots, edit opens the file under the client's roots. The 3D and Materials panel's Edit Bevels... is not confined. --- crates/engine/src/cmd/arrowheads.rs | 4 +- crates/engine/src/cmd/bevels.rs | 19 +++++-- crates/engine/src/tests/bevels.rs | 82 +++++++++++++++++++++++++++++ docs/mcp.md | 7 +++ 4 files changed, 106 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/arrowheads.rs b/crates/engine/src/cmd/arrowheads.rs index d77724d8dc..cef54db187 100644 --- a/crates/engine/src/cmd/arrowheads.rs +++ b/crates/engine/src/cmd/arrowheads.rs @@ -413,13 +413,13 @@ fn skipped(s: &Session) -> Vec { /// The arrowheads file at `path` checked for reading against the automation roots in force: an agent /// confined to read roots reaches the file only inside them. The error names the file by its file /// name outside them. -fn may_reach(path: &str) -> Result<()> { +pub(super) fn may_reach(path: &str) -> Result<()> { crate::file_access::check_read(path).map_err(|e| super::fileio::naming_in_error(EngineError::Other(e), path)) } /// `msg`, an error about the arrowheads file at `path`, as the request being served may see it: the /// file named whole inside the read roots, else by its file name. -fn shown_error(msg: &str, path: Option<&str>) -> String { +pub(super) fn shown_error(msg: &str, path: Option<&str>) -> String { let Some(path) = path else { return msg.to_string() }; match super::fileio::naming_in_error(EngineError::Other(msg.to_string()), path) { EngineError::Other(m) => m, diff --git a/crates/engine/src/cmd/bevels.rs b/crates/engine/src/cmd/bevels.rs index cd68bd7f1b..3fcaa1094c 100644 --- a/crates/engine/src/cmd/bevels.rs +++ b/crates/engine/src/cmd/bevels.rs @@ -16,7 +16,7 @@ use vectorcraft_doc::{Appearance, Document, Node, NodeId, NodeKind, Symbol}; use vectorcraft_geom::{Affine, PathData, PathEl, Point, SubPath}; use vectorcraft_render::effects::{BEVEL_NAME, BEVEL_PROFILE, BevelProfile}; -use super::arrowheads::{read, same_file}; +use super::arrowheads::{may_reach, read, same_file, shown_error}; use super::{CommandSpec, Result, Session, always, bad, cmd}; /// The bevels file's name, in the folder of the preferences. @@ -325,11 +325,18 @@ fn skipped(s: &Session) -> Vec { fn list(s: &mut Session, _: &Value) -> Result { let bevels: Vec = s.bevels.bevels.iter().map(|b| json!({"name": b.name, "points": b.profile_json()})).collect(); - Ok(json!({"bevels": bevels, "file": s.bevels.path, "skipped": skipped(s), "error": s.bevels.error})) + // Under automation read roots, a file outside them is not shown and its error names it by its file name. + let path = s.bevels.path.as_deref(); + let file = path.filter(|p| crate::file_access::check_read(p).is_ok()); + let error = s.bevels.error.as_deref().map(|e| shown_error(e, path)); + Ok(json!({"bevels": bevels, "file": file, "skipped": skipped(s), "error": error})) } fn reload(s: &mut Session, _: &Value) -> Result { const C: &str = "threeD.bevels.reload"; + if let Some(path) = &s.bevels.path { + may_reach(path)?; + } s.reload_bevels(); if let Some(e) = &s.bevels.error { return Err(bad(C, e.clone())); @@ -340,8 +347,11 @@ fn reload(s: &mut Session, _: &Value) -> Result { fn edit(s: &mut Session, _: &Value) -> Result { const C: &str = "threeD.bevels.edit"; let path = s.bevels.path.clone().ok_or_else(|| bad(C, "no bevels file here"))?; + // Checked before anything is made, brought to the front or opened. + may_reach(&path)?; if let Some(dir) = std::path::Path::new(&path).parent() { - std::fs::create_dir_all(dir).map_err(|e| bad(C, format!("{}: {e}", dir.display())))?; + let dir = dir.to_string_lossy(); + std::fs::create_dir_all(&*dir).map_err(|e| super::fileio::naming_in_error(bad(C, format!("{dir}: {e}")), &dir))?; } // Made only when no file is there, also when another run makes one at the same moment. let bytes = vectorcraft_format::save_file(&starter()); @@ -360,7 +370,8 @@ fn edit(s: &mut Session, _: &Value) -> Result { s.set_active(i); } None => { - crate::file_access::unconfined(|| s.execute("document.open", &json!({ "path": path })))?; + // Opened in the request's own scope, so the document keeps the roots it was opened under. + s.execute("document.open", &json!({ "path": path }))?; } } Ok(json!({"path": path, "created": created})) diff --git a/crates/engine/src/tests/bevels.rs b/crates/engine/src/tests/bevels.rs index 662a026023..301ed61905 100644 --- a/crates/engine/src/tests/bevels.rs +++ b/crates/engine/src/tests/bevels.rs @@ -310,3 +310,85 @@ fn without_a_bevels_file_editing_is_refused_and_none_are_listed() { assert!(s.execute("threeD.bevels.reload", &json!({})).is_err()); let _ = std::fs::remove_dir_all(&dir); } + +/// Automation roots that grant reading `read` alone. +fn read_roots(read: &[&std::path::Path]) -> Arc { + crate::file_access::AutomationRoots::new(read, &[]).unwrap().unwrap() +} + +#[test] +fn an_agent_outside_the_bevels_files_folder_sees_its_file_name_alone_and_cannot_reload_it() { + let dir = folder("roots-list"); + let (prefs, other) = (dir.join("prefs"), dir.join("other")); + std::fs::create_dir_all(&prefs).unwrap(); + std::fs::create_dir_all(&other).unwrap(); + let file = prefs.join(bevels::FILE_NAME); + std::fs::write(&file, b"not a drawing").unwrap(); + let (file, prefs_text) = (file.to_string_lossy().to_string(), prefs.to_string_lossy().to_string()); + let mut s = Session::new(); + s.attach_bevels_file(file.clone()); + let (outside, inside) = (read_roots(&[&other]), read_roots(&[&prefs])); + let list = crate::file_access::confine(Some(&outside), || s.execute("threeD.bevels.list", &json!({}))).unwrap(); + assert_eq!(list["file"], Value::Null, "{list}"); + let error = list["error"].as_str().unwrap(); + assert!(error.starts_with(bevels::FILE_NAME) && !error.contains(&prefs_text), "{error}"); + let list = crate::file_access::confine(Some(&inside), || s.execute("threeD.bevels.list", &json!({}))).unwrap(); + assert_eq!(list["file"].as_str(), Some(file.as_str())); + assert!(list["error"].as_str().unwrap().starts_with(&file), "{list}"); + // A good file now: an agent outside the folder cannot have it read. + std::fs::write(&file, vectorcraft_format::save_file(&bevels::starter())).unwrap(); + let e = crate::file_access::confine(Some(&outside), || s.execute("threeD.bevels.reload", &json!({}))).unwrap_err().to_string(); + assert!(e.contains("outside the read root") && e.ends_with(bevels::FILE_NAME) && !e.contains(&prefs_text), "{e}"); + let list = s.execute("threeD.bevels.list", &json!({})).unwrap(); + assert!(list["bevels"].as_array().unwrap().is_empty() && list["error"].is_string(), "not read again: {list}"); + let r = crate::file_access::confine(Some(&inside), || s.execute("threeD.bevels.reload", &json!({}))).unwrap(); + assert_eq!(r["count"], 1); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn an_agent_edits_the_bevels_file_only_inside_its_read_roots() { + let dir = folder("roots-edit"); + let (prefs, other) = (dir.join("prefs"), dir.join("other")); + std::fs::create_dir_all(&other).unwrap(); + let file = prefs.join(bevels::FILE_NAME).to_string_lossy().to_string(); + let prefs_text = prefs.to_string_lossy().to_string(); + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap(); + s.attach_bevels_file(file.clone()); + let first_doc = s.doc().unwrap().uid; + let outside = read_roots(&[&other]); + let edit = |s: &mut Session, roots: &Arc| { + crate::file_access::confine(Some(roots), || s.execute("threeD.bevels.edit", &json!({}))) + }; + // Refused before the folder or the file is made, or anything is opened. + let e = edit(&mut s, &outside).unwrap_err().to_string(); + assert!(e.ends_with(bevels::FILE_NAME) && !e.contains(&prefs_text), "{e}"); + assert!(!prefs.exists(), "no folder made"); + assert_eq!((s.documents().len(), s.doc().unwrap().uid), (1, first_doc)); + // From the 3D and Materials panel (no roots), the file is made and opened. + assert_eq!(s.execute("threeD.bevels.edit", &json!({})).unwrap()["created"], true); + assert_eq!(s.documents().len(), 2); + // Open already: still not brought to the front for an agent outside the folder. + s.execute("document.activate", &json!({"index": 0})).unwrap(); + assert!(edit(&mut s, &outside).is_err()); + assert_eq!((s.documents().len(), s.doc().unwrap().uid), (2, first_doc)); + // Inside the read roots: opened under them, with its path. + let inside = read_roots(&[&prefs]); + let mut agent = Session::new(); + agent.attach_bevels_file(file.clone()); + let r = edit(&mut agent, &inside).unwrap(); + assert_eq!((r["path"].as_str(), &r["created"]), (Some(file.as_str()), &json!(false))); + let st = agent.doc().unwrap(); + assert_eq!(st.path.as_deref(), Some(file.as_str())); + assert!(st.opened_by.as_ref().is_some_and(|r| Arc::ptr_eq(r, &inside)), "opened under the agent's roots"); + // A missing file inside the roots is still made first. + let fresh = dir.join("fresh").join(bevels::FILE_NAME).to_string_lossy().to_string(); + let mut agent = Session::new(); + agent.attach_bevels_file(fresh.clone()); + let r = edit(&mut agent, &read_roots(&[&dir])).unwrap(); + assert_eq!(r["created"], true); + assert!(std::path::Path::new(&fresh).is_file()); + assert_eq!(agent.doc().unwrap().path.as_deref(), Some(fresh.as_str())); + let _ = std::fs::remove_dir_all(&dir); +} diff --git a/docs/mcp.md b/docs/mcp.md index 7c9514ea17..d3bac3d8b9 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3892,6 +3892,13 @@ the file may take, has ends that are not apart both across and down, or repeats listed in `skipped`. `threeD.bevels.list` returns each bevel's `name` and `points`, the `file` path, the `skipped` symbols and any read `error`. +Under automation read roots, the bevels file counts as a path the client did not give. `threeD.bevels.list` returns +`file` as `null` when the file is outside the read roots, and its `error` names the file by its file name; the bevels, +`skipped` and the reason stay. `threeD.bevels.edit` and `threeD.bevels.reload` refuse a file outside the read roots +with the root-check error, naming the file by its file name: `edit` then makes no folder or file and neither opens the +file nor brings it to the front, and `reload` does not read it. Inside the read roots, `edit` opens the file under the +client's roots. The 3D and Materials panel's Edit Bevels… is not confined. + `threeD.extrude` and `threeD.classicExtrude` take `bevel: {"custom": name}` in `effect.apply` and `effect.setParams`, and store it as `bevel: "custom"` with `bevelName` and `bevelProfile`, a copy of the points (`[[x, y], …]`, 2 to 64 shares 0..1 of the width and height from `[0, 0]` to `[1, 1]`), so the document draws the bevel without the file. An From 8a7f0a2c392ca7b796c1709f96676ad4faf18d82 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 14:58:17 -0800 Subject: [PATCH 12/13] i18n: Danish rows for custom bevel messages --- crates/ui-egui/src/i18n/da.tsv | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 0770ce4d1d..d0af6ffe96 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -292,7 +292,10 @@ @msg The 3D object is too complex to export 3D-objektet er for komplekst til at blive eksporteret @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) objektet har ingen 3D-effekt (Ekstrudér og facet, Omdrej, Pust op eller Rotér) @msg its 3D effect builds no solid dens 3D-effekt danner intet legeme -@msg bevel must be none or one of {_1} bevel skal være none eller en af {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel skal være none, en af {_1} eller custom med {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom kræver {BEVEL_PROFILE}, facettens punkter +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} skal være en streng +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} skal være 2 til {most} punkter [x, y], hver andel mellem 0 og 1, fra [0, 0] (dækfladens kant) til [1, 1] (sidevæggen) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} kan ikke danne legemer af denne grafik: dens symbolforekomster, blandinger og beskæringsgrupper indeholder for mange objekter @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} kan ikke danne et legeme af forekomsten af symbolet "{symbol}": symbolets grafik er ikke tilgængelig @msg {_1}: the clipping path is too complex to cut the art with {_1}: beskæringskurven er for kompleks til at skære grafikken med From 0393a9780411f93ed0db43914c1e042731f111a9 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 06:36:42 -0800 Subject: [PATCH 13/13] i18n: Indonesian rows for custom bevel messages --- crates/ui-egui/src/i18n/id.tsv | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 97214bded6..12c3babb7e 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -314,7 +314,10 @@ @msg the object has no 3D effect (Extrude & Bevel, Revolve, Inflate or Rotate) objek tidak memiliki efek 3D (Ekstrusi & bevel, Revolusi, Gelembungkan, atau Putar) @msg `render` must be an object holding only `mode`, set to shaded or wireframe `render` harus berupa objek yang hanya berisi `mode`, bernilai shaded atau wireframe @msg its 3D effect builds no solid efek 3D-nya tidak membangun bentuk padat -@msg bevel must be none or one of {_1} bevel harus none atau salah satu dari {_1} +@msg bevel must be none or one of {_1}, or custom with {BEVEL_PROFILE} bevel harus none, salah satu dari {_1}, atau custom dengan {BEVEL_PROFILE} +@msg bevel custom needs {BEVEL_PROFILE}, the bevel's points bevel custom memerlukan {BEVEL_PROFILE}, yaitu titik-titik bevel +@msg {BEVEL_NAME} must be a string {BEVEL_NAME} harus berupa string +@msg {BEVEL_PROFILE} must be 2 to {most} [x, y] points, each share between 0 and 1, from [0, 0] (the cap's edge) to [1, 1] (the side wall) {BEVEL_PROFILE} harus berisi 2 sampai {most} titik [x, y], masing-masing bernilai antara 0 dan 1, dari [0, 0] (tepi tutup) hingga [1, 1] (dinding samping) @msg {_1} can't build solids from this art: its symbol instances, blends and clipping groups hold too many objects {_1} tidak dapat membangun bentuk padat dari karya ini: instans simbol, blend, dan grup klipingnya berisi terlalu banyak objek @msg {label} can't build a solid from the instance of symbol "{symbol}": the symbol's art isn't available {label} tidak dapat membangun bentuk padat dari instans simbol "{symbol}": karya simbol tidak tersedia @msg {_1}: the clipping path is too complex to cut the art with {_1}: jalur kliping terlalu rumit untuk memotong karya