diff --git a/crates/engine/src/cmd/effectcmd.rs b/crates/engine/src/cmd/effectcmd.rs index 308305fe04..cafe5daa23 100644 --- a/crates/engine/src/cmd/effectcmd.rs +++ b/crates/engine/src/cmd/effectcmd.rs @@ -97,7 +97,7 @@ fn effect_specs() -> Vec { "Expand Appearance", ["Object"], None, - "{ids?|id?: [..], target?} turn each object's appearance into objects: every fill and stroke becomes an object of its own (a stroke stays a stroke, with its weight, dashes, arrowheads and width profile, on its own copy of the path, which object.expand or object.path.outlineStroke outline; brushed strokes become their brush art) grouped in paint order under the object's id and transparency, geometry effects are baked, raster effects become an embedded image (shadows and outer glows below the art; blur, feather and inner glow replace it; an object whose only raster effect is its own Rasterize becomes the image object.rasterize makes with the effect's options), type with effects or fills of its own is outlined; Crop Marks become a group of the object and its marks; Vector Halftone (addon.color.halftone) becomes a group of its dot paths, one per ink; a group's or layer's own fills and strokes become objects among its members, which are expanded too; a symbol instance whose topmost fill or stroke is visible, has an opacity above 0 and has a geometry or raster effect becomes a group of its art, that fill's effects reshaping the art's filled shapes and that stroke's effects reshaping its stroked shapes, as the canvas draws them, its raster effects an image as for other objects; a symbol instance in that art whose topmost fill or stroke has such an effect (its own or one the outer instance passes on) becomes its art and image in turn. An outlined frame of threaded text leaves its thread with the text it shows, and a frame kept as type in a group stays in its thread. A dimension whose art it changes becomes a plain group of its art, except one selected with art it measures, directly or in groups without fills, strokes or effects of their own: its lines and label stay as they are, and if the new art no longer fits its link it stays where it was, no longer linked. Hidden fills, strokes and effects are dropped. In Safe Mode, an object with a visible plug-in effect (in it, or in a symbol it places) is an error and nothing changes. Enabled when a selected or targeted object's appearance isn't basic (`ids` then pick which objects) → {ids, warning? (an image in the art couldn't be decoded, as object.rasterize says)}", + "{ids?|id?: [..], target?} turn each object's appearance into objects: every fill and stroke becomes an object of its own (a stroke stays a stroke, with its weight, dashes, arrowheads and width profile, on its own copy of the path, which object.expand or object.path.outlineStroke outline; brushed strokes become their brush art) grouped in paint order under the object's id and transparency, geometry effects are baked, raster effects become an embedded image (shadows and outer glows below the art; blur, feather and inner glow replace it; an object whose only raster effect is its own Rasterize becomes the image object.rasterize makes with the effect's options), type with effects or fills of its own is outlined; Crop Marks become a group of the object and its marks; Vector Halftone (addon.color.halftone) becomes a group of its dot paths, one per ink; a group's or layer's own fills and strokes become objects among its members, which are expanded too; a symbol instance whose topmost fill or stroke is visible, has an opacity above 0 and has a geometry or raster effect becomes a group of its art, that fill's effects reshaping the art's filled shapes and that stroke's effects reshaping its stroked shapes, as the canvas draws them, its raster effects an image as for other objects; a symbol instance in that art whose topmost fill or stroke has such an effect (its own or one the outer instance passes on) becomes its art and image in turn. An outlined frame of threaded text leaves its thread with the text it shows, and a frame kept as type in a group stays in its thread. A dimension whose art it changes becomes a plain group of its art, except one selected with art it measures, directly or in groups without fills, strokes or effects of their own: its lines and label stay as they are, and if the new art no longer fits its link it stays where it was, no longer linked. Hidden fills, strokes and effects are dropped. One expansion makes at most 1,024 images of raster effects, 256 megapixels in all (VectorCraft's own limits): an object or symbol instance whose image would go past them stays as it is, with its effects, and when nothing else expands that is an error. In Safe Mode, an object with a visible plug-in effect (in it, or in a symbol it places) is an error and nothing changes. Enabled when a selected or targeted object's appearance isn't basic (`ids` then pick which objects) → {ids, warning? (an image in the art couldn't be decoded, as object.rasterize says; or raster effects were left past the limits), rasterLeft? (how many objects were left so)}", can_expand, expand_appearance ), @@ -960,13 +960,62 @@ fn is_container(n: &Node) -> bool { /// all paint below it (shadows and outer glows: the image then holds just them). A group's or /// layer's image leaves out its members' raster effects, which are expanded with them. `None` /// when it has none. -fn raster_image(d: &mut Document, n: &Node) -> Option<(Node, bool)> { +/// `Err` when that image would take `budget` past its limits: the object then stays as it is. +fn raster_image(d: &mut Document, n: &Node, budget: &mut RasterBudget) -> std::result::Result, OverBudget> { let fx = rasterfx::raster_fx(n); if fx.is_empty() { - return None; + return Ok(None); } let below = fx.iter().all(effects::RasterFx::is_below); - Some((rasterfx::raster_image(d, n, below, true)?, below)) + let pixels = budget.take(rasterfx::raster_pixels(d, n, below, true))?; + let image = rasterfx::raster_image(d, n, below, true); + if image.is_none() { + // No image was made: it takes nothing from the budget. + budget.images += 1; + budget.pixels += pixels; + } + Ok(image.map(|image| (image, below))) +} + +/// The most images of raster effects one Expand Appearance makes. +const MAX_RASTER_IMAGES: u32 = 1_024; + +/// The most pixels the images of raster effects one Expand Appearance makes hold in all. +const MAX_RASTER_PIXELS: u64 = 256_000_000; + +/// The note when objects keep their raster effects because their images would take an Expand +/// Appearance past [`MAX_RASTER_IMAGES`] or [`MAX_RASTER_PIXELS`]. +pub(crate) const RASTER_EFFECTS_LEFT: &str = + "some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all"; + +/// An image of raster effects that would take a [`RasterBudget`] past its limits. +#[derive(Debug)] +struct OverBudget; + +/// What one Expand Appearance has left of [`MAX_RASTER_IMAGES`] and [`MAX_RASTER_PIXELS`], and the +/// objects whose raster effects it left as they are because their images would go past them. +pub(crate) struct RasterBudget { + images: u32, + pixels: u64, + pub(crate) left: usize, +} + +impl RasterBudget { + pub(crate) fn new() -> Self { + Self { images: MAX_RASTER_IMAGES, pixels: MAX_RASTER_PIXELS, left: 0 } + } + + /// Take an image of `pixels` ([`rasterfx::raster_pixels`]) before it is made, and return + /// them; `Err`, with its object counted in `left`, when it would go past what is left. + fn take(&mut self, pixels: u64) -> std::result::Result { + if self.images == 0 || pixels > self.pixels { + self.left += 1; + return Err(OverBudget); + } + self.images -= 1; + self.pixels -= pixels; + Ok(pixels) + } } /// Expand the pieces of `m`, art evaluated from the object of the same id (its pieces share that @@ -982,6 +1031,7 @@ fn expand_pieces( all: bool, brushes: &[vectorcraft_brush::Brush], stroke_art: effects::StrokeArt, + raster: &mut RasterBudget, ) -> std::collections::HashMap> { let id = m.id; let mut seen = std::collections::HashSet::from([id]); @@ -996,7 +1046,7 @@ fn expand_pieces( if all || c.id == id { effects::expand_art(d, c, stroke_art); } else if has_seeded(c) && repeats_an_id(c, &seen) { - listed = Some(expand_in_place(d, c, brushes)); + listed = Some(expand_in_place(d, c, brushes, raster)); } fresh_ids_listed(d, c, &mut seen, listed.as_deref_mut().unwrap_or_default()); if let Some(listed) = listed { @@ -1010,15 +1060,15 @@ fn expand_pieces( /// active fill or stroke has a geometry or raster effect ([`effects::has_item_geometry`], /// [`effects::has_instance_row_raster`]) by its art ([`expanded_instance`]), and the instances in /// that art in turn, so [`expand_pieces`] bakes their effects with the rest. -fn expand_nested_instances(d: &mut Document, m: &mut Node, depth: usize, budget: &mut u64) { +fn expand_nested_instances(d: &mut Document, m: &mut Node, depth: usize, budget: &mut u64, raster: &mut RasterBudget) { for c in m.children_mut().into_iter().flatten() { if !matches!(c.kind, NodeKind::SymbolInstance { .. }) { if c.children().is_some() { - expand_nested_instances(d, Arc::make_mut(c), depth, budget); + expand_nested_instances(d, Arc::make_mut(c), depth, budget, raster); } continue; } - if let Some(a) = expanded_instance(d, c, depth, budget) { + if let Some(a) = expanded_instance(d, c, depth, budget, raster) { *c = Arc::new(a); } } @@ -1031,12 +1081,13 @@ fn expand_nested_instances(d: &mut Document, m: &mut Node, depth: usize, budget: /// it has no geometry effect, with the instances in that art expanded in turn. `None`, the instance /// staying as it is, when its active fill and stroke have no such effect, it is more than /// [`vectorcraft_doc::depth::MAX_DEPTH`] instances deep, its symbol is missing, or its art would -/// take the objects placed so far past `budget`. When the image of its raster effects can't be -/// made, they stay on the art its geometry effects make, and without one it stays as it is. -fn expanded_instance(d: &mut Document, c: &Node, depth: usize, budget: &mut u64) -> Option { +/// take the objects placed so far past `budget`, or the image of its raster effects would take +/// `raster` past its limits. When that image can't be made, they stay on the art its geometry +/// effects make, and without one it stays as it is. +fn expanded_instance(d: &mut Document, c: &Node, depth: usize, budget: &mut u64, raster: &mut RasterBudget) -> Option { let NodeKind::SymbolInstance { symbol, .. } = &c.kind else { return None }; - let raster = effects::has_instance_row_raster(c); - if depth >= vectorcraft_doc::depth::MAX_DEPTH || !(raster || effects::has_item_geometry(c)) { + let has_raster = effects::has_instance_row_raster(c); + if depth >= vectorcraft_doc::depth::MAX_DEPTH || !(has_raster || effects::has_item_geometry(c)) { return None; } let sym = d.symbols.iter().find(|s| s.name == *symbol)?; @@ -1044,9 +1095,9 @@ fn expanded_instance(d: &mut Document, c: &Node, depth: usize, budget: &mut u64) if count > *budget { return None; } - *budget -= count; let art = vectorcraft_render::instance_art(&sym.art, c); - let image = if raster { raster_image(d, c) } else { None }; + let image = if has_raster { raster_image(d, c, raster).ok()? } else { None }; + *budget -= count; let mut v = c.clone(); if image.is_some() { rasterfx::strip_raster(&mut v, false); @@ -1058,7 +1109,7 @@ fn expanded_instance(d: &mut Document, c: &Node, depth: usize, budget: &mut u64) }; let mut a = effects::expand_outlined(Some(&*d), &v, Some(&art)) .or_else(|| if below.is_some() { effects::instance_as_art(Some(&*d), &v, Some(&art)) } else { None })?; - expand_nested_instances(d, &mut a, depth + 1, budget); + expand_nested_instances(d, &mut a, depth + 1, budget, raster); if let Some(image) = below { rasterfx::put_below(d, &mut a, image); } @@ -1079,9 +1130,9 @@ fn repeats_an_id(n: &Node, seen: &std::collections::HashSet) -> bool { type Listed = (NodeId, usize); /// [`expanded_node`] of `c` in place. Returns what the expansion lists, by places in the walk of `c`. -fn expand_in_place(d: &mut Document, c: &mut Node, brushes: &[vectorcraft_brush::Brush]) -> Vec { +fn expand_in_place(d: &mut Document, c: &mut Node, brushes: &[vectorcraft_brush::Brush], raster: &mut RasterBudget) -> Vec { let mut listed = vec![]; - if let Some(e) = expanded_node(d, c.clone(), brushes, &mut listed) { + if let Some(e) = expanded_node(d, c.clone(), brushes, &mut listed, raster) { *c = e; } listed @@ -1103,11 +1154,12 @@ fn fresh_ids_listed(d: &mut Document, c: &mut Node, seen: &mut std::collections: /// Expand Appearance of `id` (and, recursively, of a group's or layer's members): every fill and /// stroke becomes an object of its own (a stroke a path stroked by it alone, brushes as their art), /// geometry effects are baked, raster effects become an embedded image, and the object keeps its -/// transparency. -pub(crate) fn expand_node(d: &mut Document, id: NodeId, brushes: &[vectorcraft_brush::Brush], out: &mut Vec) { +/// transparency. An object whose raster effects' image would take `raster` past its limits stays +/// as it is, with what is inside it. +pub(crate) fn expand_node(d: &mut Document, id: NodeId, brushes: &[vectorcraft_brush::Brush], out: &mut Vec, raster: &mut RasterBudget) { let Some(n) = d.node(id).cloned() else { return }; let mut listed = vec![]; - let m = expanded_node(d, n, brushes, &mut listed); + let m = expanded_node(d, n, brushes, &mut listed, raster); out.extend(listed.into_iter().map(|(id, _)| id)); if let Some(mut m) = m { // Art made from type takes its emoji's pixels into the document. @@ -1121,7 +1173,13 @@ pub(crate) fn expand_node(d: &mut Document, id: NodeId, brushes: &[vectorcraft_b /// [`expand_node`] of `n`, which need not be in `d`: `n` with its appearance expanded, `None` when /// it has nothing to expand. `out` gets the objects whose appearance expands, by places in the walk /// of the expanded `n`, `n`'s first when its own does. -fn expanded_node(d: &mut Document, mut n: Node, brushes: &[vectorcraft_brush::Brush], out: &mut Vec) -> Option { +fn expanded_node( + d: &mut Document, + mut n: Node, + brushes: &[vectorcraft_brush::Brush], + out: &mut Vec, + raster: &mut RasterBudget, +) -> Option { let id = n.id; if !expandable(&n) { return None; @@ -1160,7 +1218,7 @@ fn expanded_node(d: &mut Document, mut n: Node, brushes: &[vectorcraft_brush::Br for (i, c) in m.children_mut().into_iter().flatten().enumerate() { let c = Arc::make_mut(c); if i == 0 { - expanded = expand_in_place(d, c, brushes); + expanded = expand_in_place(d, c, brushes, raster); fresh_ids_listed(d, c, &mut seen, &mut expanded); } else { effects::fresh_ids(d, c, &mut seen); @@ -1183,7 +1241,9 @@ fn expanded_node(d: &mut Document, mut n: Node, brushes: &[vectorcraft_brush::Br } return Some(m); } - let image = raster_image(d, &n); + // Raster effects whose image would go past the budget stay: so does the object, with what is + // inside it (a color adjustment already made stays made). + let Ok(image) = raster_image(d, &n, raster) else { return changed.then_some(n) }; let mut v = n.clone(); rasterfx::strip_raster(&mut v, false); let mut stroke_art = @@ -1201,7 +1261,7 @@ fn expanded_node(d: &mut Document, mut n: Node, brushes: &[vectorcraft_brush::Br } else if container { // A group's or layer's own fills and strokes become art among its members. effects::evaluate_container(Some(&*d), &v).map(|mut m| { - members = expand_pieces(d, &mut m, false, brushes, &mut stroke_art); + members = expand_pieces(d, &mut m, false, brushes, &mut stroke_art, raster); m }) } else if matches!(n.kind, NodeKind::Path { .. } | NodeKind::Compound { .. }) @@ -1226,8 +1286,8 @@ fn expanded_node(d: &mut Document, mut n: Node, brushes: &[vectorcraft_brush::Br .or_else(|| if row_raster { effects::instance_as_art(Some(&*d), &v, symbol.as_ref()) } else { None }); outlined.map(|mut m| { let mut budget = vectorcraft_doc::MAX_SYMBOL_NODES; - expand_nested_instances(d, &mut m, 1, &mut budget); - expand_pieces(d, &mut m, true, brushes, &mut stroke_art); + expand_nested_instances(d, &mut m, 1, &mut budget, raster); + expand_pieces(d, &mut m, true, brushes, &mut stroke_art, raster); m }) }; @@ -1261,7 +1321,7 @@ fn expanded_node(d: &mut Document, mut n: Node, brushes: &[vectorcraft_brush::Br match members.remove(&c.id) { Some(listed) => out.extend(listed), None => { - if let Some(e) = expanded_node(d, (**c).clone(), brushes, out) { + if let Some(e) = expanded_node(d, (**c).clone(), brushes, out, raster) { *c = Arc::new(e); changed = true; } @@ -1324,6 +1384,7 @@ fn expand_appearance(s: &mut Session, p: &Value) -> Result { } let failed = vectorcraft_render::decode_failures(); let colorized_ok = super::paint::check_colorized(&s.doc()?.doc).is_ok(); + let mut raster = RasterBudget::new(); let ids = s.edit("Expand Appearance", |d, _| { let before = d.clone(); // The art of graph designs in the graphs and series among the roots stays as the graph draws it. A group whose @@ -1339,7 +1400,7 @@ fn expand_appearance(s: &mut Session, p: &Value) -> Result { let mut out = vec![]; let threaded = super::threads::frames(d); for id in &roots { - expand_node(d, *id, &brushes, &mut out); + expand_node(d, *id, &brushes, &mut out, &mut raster); } for id in &designs { if let (Some(was), Some(slot)) = (before.node(*id), d.node_mut(*id)) { @@ -1357,6 +1418,9 @@ fn expand_appearance(s: &mut Session, p: &Value) -> Result { // stays type under a new id takes its frame's place. super::threads::leave_threads(d, &threaded); if out.is_empty() || (kept && d.layers == before.layers) { + if raster.left > 0 { + return Err(EngineError::Other(RASTER_EFFECTS_LEFT.into())); + } return Err(EngineError::Other("Expand Appearance: the selection has a basic appearance".into())); } super::paint::check_colorized_kept(colorized_ok, d).map_err(|e| bad("Expand Appearance", e))?; @@ -1364,8 +1428,12 @@ fn expand_appearance(s: &mut Session, p: &Value) -> Result { })?; let mut out = json!({ "ids": ids_json(&ids) }); // Raster effects become images rendered from the art. - if let Some(w) = rasterfx::undecoded_warning(failed) { - out["warning"] = json!(w); + let warnings: Vec<&str> = rasterfx::undecoded_warning(failed).into_iter().chain((raster.left > 0).then_some(RASTER_EFFECTS_LEFT)).collect(); + if !warnings.is_empty() { + out["warning"] = json!(warnings.join("; ")); + } + if raster.left > 0 { + out["rasterLeft"] = json!(raster.left); } Ok(out) } diff --git a/crates/engine/src/cmd/effectcmd/tests.rs b/crates/engine/src/cmd/effectcmd/tests.rs index b3389e190d..f7e7206c57 100644 --- a/crates/engine/src/cmd/effectcmd/tests.rs +++ b/crates/engine/src/cmd/effectcmd/tests.rs @@ -1082,3 +1082,28 @@ fn radial_blur_center_stays_in_the_object_when_the_stack_splits() { let differ = (0..300 * 300).filter(|i| plain[i * 4 + 3].abs_diff(split[i * 4 + 3]) > 8).count(); assert!(differ < 50, "{differ} pixels' coverage moved with the room around the art"); } + +/// The raster budget charges each image its pixels before it is made: an image past what is left +/// is refused and counted, and the object keeps its blur. +#[test] +fn an_image_past_the_pixels_left_stays_unmade() { + let (mut s, id) = session_with_rect(); + s.execute("effect.apply", &json!({"ids": [id.0], "effect": "blur.gaussian", "params": {"radius": 3}})).unwrap(); + let mut d = s.doc().unwrap().doc.as_ref().clone(); + let n = d.node(id).cloned().unwrap(); + let pixels = super::rasterfx::raster_pixels(&d, &n, false, true); + assert!(pixels > 10_000, "a 100 pt square at 72 ppi: {pixels}"); + + let mut budget = super::RasterBudget { images: 10, pixels: pixels - 1, left: 0 }; + assert!(super::raster_image(&mut d, &n, &mut budget).is_err()); + assert_eq!((budget.images, budget.pixels, budget.left), (10, pixels - 1, 1), "nothing is taken"); + + let mut budget = super::RasterBudget { images: 10, pixels, left: 0 }; + let (image, _) = super::raster_image(&mut d, &n, &mut budget).unwrap().expect("the image is made"); + let NodeKind::Image(img) = &image.kind else { panic!("not an image") }; + assert_eq!(u64::from(img.width) * u64::from(img.height), pixels, "the charge is the image's size"); + assert_eq!((budget.images, budget.pixels, budget.left), (9, 0, 0)); + + let mut budget = super::RasterBudget { images: 0, pixels, left: 0 }; + assert!(super::raster_image(&mut d, &n, &mut budget).is_err(), "no image is left"); +} diff --git a/crates/engine/src/cmd/fileio/legacy_ai.rs b/crates/engine/src/cmd/fileio/legacy_ai.rs index 23168f1e25..028d9fe5a6 100644 --- a/crates/engine/src/cmd/fileio/legacy_ai.rs +++ b/crates/engine/src/cmd/fileio/legacy_ai.rs @@ -142,7 +142,9 @@ pub(super) fn encode(cmd: &str, f: &Format, doc: &Document, p: &Value) -> Result let one = super::save::artboard_doc(doc, b); let (full, placed) = crate::cmd::place::document::full_documents(&one); let mut d = full.into_owned(); - expand_appearances(&mut d); + if expand_appearances(&mut d) { + note(&mut enc.warnings, super::super::effectcmd::RASTER_EFFECTS_LEFT); + } if mode == SeeThrough::Flatten { expand_image_patterns(&mut d)?; } @@ -175,14 +177,17 @@ pub(super) fn encode(cmd: &str, f: &Format, doc: &Document, p: &Value) -> Result Ok(enc) } -/// Expand Appearance of every layer's art whose appearance the format can't hold. -fn expand_appearances(d: &mut Document) { +/// Expand Appearance of every layer's art whose appearance the format can't hold. Returns whether +/// objects kept raster effects whose images would go past Expand Appearance's limits. +fn expand_appearances(d: &mut Document) -> bool { let brushes = vectorcraft_brush::library(d); let layers: Vec = d.layers.iter().map(|l| l.id).collect(); let mut out = vec![]; + let mut raster = super::super::effectcmd::RasterBudget::new(); for id in layers { - super::super::effectcmd::expand_node(d, id, &brushes, &mut out); + super::super::effectcmd::expand_node(d, id, &brushes, &mut out, &mut raster); } + raster.left > 0 } /// Expand every layer's pattern fills that paint an image with see-through pixels, a colorize paint, diff --git a/crates/engine/src/cmd/rasterfx.rs b/crates/engine/src/cmd/rasterfx.rs index 5f412e080d..aaaef531bf 100644 --- a/crates/engine/src/cmd/rasterfx.rs +++ b/crates/engine/src/cmd/rasterfx.rs @@ -174,19 +174,14 @@ pub(crate) fn effects_scale(doc: &Document) -> f64 { (doc.raster_effects_ppi / 72.0).clamp(1.0 / 72.0, 2400.0 / 72.0) } -/// An embedded image (a new node of `out`, its pixels in `out.images`) of `whole` rendered alone -/// with `out`'s resources at `scale` over all it paints (the reach of its own, its members' and its -/// fills' and strokes' raster effects included). With `knockout`, the coverage of that art is knocked out -/// of the image, which then only holds what the effects add around it (a shadow to go under the -/// vector object). The document's raster effects settings add room around it and finish its pixels. -/// `None` when it paints nothing, when the area it covers overflows `f64` or the scale is not -/// positive, or when its PNG can't be encoded. -pub(crate) fn effect_image(out: &mut Document, whole: &Node, knockout: Option<&Node>, scale: f64) -> Option { +/// The region [`effect_image`] renders `whole` over in `d`, and the scale it renders at (`scale`, or +/// less for an image past 64 Mpx or a side the renderer can't address). `None` when it paints +/// nothing, when the area it covers overflows `f64` or the scale is not positive. +fn effect_region(d: &Document, whole: &Node, scale: f64) -> Option<(Rect, f64)> { // What it paints (its members' effects included), and how far its fills' and strokes' raster // effects reach beyond that. - let b = vectorcraft_render::painted_bounds(out, whole)?; - let look = out.raster_effects.clone(); - let reach = whole.appearance.items.iter().map(|i| effects::outset(i.effects(), b)).fold(0.0, f64::max) + 2.0 + look.add_around; + let b = vectorcraft_render::painted_bounds(d, whole)?; + let reach = whole.appearance.items.iter().map(|i| effects::outset(i.effects(), b)).fold(0.0, f64::max) + 2.0 + d.raster_effects.add_around; let b = b.inflate(reach, reach); // An area too large for f64 gives a zero scale and an image transform that is not finite. let area = b.width() * b.height(); @@ -201,6 +196,19 @@ pub(crate) fn effect_image(out: &mut Document, whole: &Node, knockout: Option<&N return None; } let region = Rect::new(b.x0, b.y0, b.x0 + (b.width() * scale).ceil().max(1.0) / scale, b.y0 + (b.height() * scale).ceil().max(1.0) / scale); + Some((region, scale)) +} + +/// An embedded image (a new node of `out`, its pixels in `out.images`) of `whole` rendered alone +/// with `out`'s resources at `scale` over all it paints (the reach of its own, its members' and its +/// fills' and strokes' raster effects included). With `knockout`, the coverage of that art is knocked out +/// of the image, which then only holds what the effects add around it (a shadow to go under the +/// vector object). The document's raster effects settings add room around it and finish its pixels. +/// `None` when it paints nothing, when the area it covers overflows `f64` or the scale is not +/// positive, or when its PNG can't be encoded. +pub(crate) fn effect_image(out: &mut Document, whole: &Node, knockout: Option<&Node>, scale: f64) -> Option { + let (region, scale) = effect_region(out, whole, scale)?; + let look = out.raster_effects.clone(); // Anti-alias off: hard edges (the effects themselves stay smooth). let anti_alias = if look.anti_alias { AntiAlias::Art } else { AntiAlias::None }; let mut img = render(out, vec![whole.clone()], region, scale, anti_alias); @@ -311,6 +319,19 @@ pub(crate) fn raster_image(d: &mut Document, n: &Node, below: bool, members: boo if !below && let Some(image) = rasterize_effect_image(d, n) { return Some(image); } + let whole = effect_art(n, below, members); + let bare = below.then(|| { + let mut b = whole.clone(); + strip_raster(&mut b, false); + b + }); + effect_image(d, &whole, bare.as_ref(), image_scale(d, n)) +} + +/// The art [`raster_image`] renders the raster effects of `n` from with `below` and `members`: +/// `n` without its transparency, a group's or layer's members without their raster effects when +/// both are set. +fn effect_art(n: &Node, below: bool, members: bool) -> Node { let mut whole = n.clone(); (whole.opacity, whole.blend) = (1.0, Default::default()); whole.extras_mut().mask = None; @@ -319,17 +340,39 @@ pub(crate) fn raster_image(d: &mut Document, n: &Node, below: bool, members: boo strip_raster(Arc::make_mut(c), true); } } - let bare = below.then(|| { - let mut b = whole.clone(); - strip_raster(&mut b, false); - b - }); - // A Rasterize effect at a finer resolution than the document's is rendered at its own. - let scale = raster_fx(n) - .iter() - .filter_map(|fx| if let RasterFx::Rasterize(r) = fx { r.ppi } else { None }) - .fold(effects_scale(d), |s, ppi| s.max(ppi / 72.0)); - effect_image(d, &whole, bare.as_ref(), scale) + whole +} + +/// Pixels per point of the image of the raster effects of `n`: the document's raster effects +/// resolution, or a Rasterize effect's finer one, which is rendered at its own. +fn image_scale(d: &Document, n: &Node) -> f64 { + raster_fx(n).iter().filter_map(|fx| if let RasterFx::Rasterize(r) = fx { r.ppi } else { None }).fold(effects_scale(d), |s, ppi| s.max(ppi / 72.0)) +} + +/// The pixels of the image [`raster_image`] makes of the raster effects of `n` in `d` with `below` +/// and `members`, as [`effect_image`] sizes it, or at the resolution and with the room around the +/// art of the object's own Rasterize effect when that is its only one ([`rasterize_effect_image`]); +/// 0 when it paints nothing. +pub(crate) fn raster_pixels(d: &Document, n: &Node, below: bool, members: bool) -> u64 { + if !below && let Some((art, r, _)) = rasterize_effect_art(d, n) { + // Measured as Object › Rasterize measures it. + let scale = r.ppi.unwrap_or(d.raster_effects_ppi) / 72.0; + let side = f64::from(vectorcraft_render::MAX_RASTER_SIDE); + let size = vectorcraft_render::drawn_bounds(d, &art).map(|b| { + let b = b.inflate(r.add_around, r.add_around); + ((b.width() * scale).ceil().max(1.0), (b.height() * scale).ceil().max(1.0)) + }); + // Past Object › Rasterize's limits that image is not made, and the effect's image is. + if let Some((w, h)) = size + && w * h <= super::menucmds::MAX_PIXELS + && w <= side + && h <= side + { + return (w * h) as u64; + } + } + effect_region(d, &effect_art(n, below, members), image_scale(d, n)) + .map_or(0, |(r, scale)| ((r.width() * scale).round() * (r.height() * scale).round()) as u64) } /// The image Object › Rasterize makes of `n` with the options of `n`'s Effect › Rasterize, when @@ -339,15 +382,7 @@ pub(crate) fn raster_image(d: &mut Document, n: &Node, below: bool, members: boo /// the image is made of the art before them and moved by them, as the canvas draws it. `None` /// otherwise, when those Transform effects flatten the image, or when the image can't be made. fn rasterize_effect_image(d: &mut Document, n: &Node) -> Option { - let [RasterFx::Rasterize(r)] = raster_fx(n)[..] else { return None }; - let staged = vectorcraft_render::rasterize_stage(d, n); - if let Some((_, map)) = &staged - && !(map.determinant().is_finite() && map.determinant().abs() > 1e-12) - { - return None; - } - let n = staged.as_ref().map_or(n, |(stage, _)| stage); - let at = n.appearance.effects.iter().position(|e| e.visible && e.id == effects::RASTERIZE)?; + let (whole, r, map) = rasterize_effect_art(d, n)?; let p = json!({ "ppi": r.ppi.unwrap_or(d.raster_effects_ppi), "colorModel": r.color_model.id(), @@ -356,20 +391,39 @@ fn rasterize_effect_image(d: &mut Document, n: &Node) -> Option { "clippingMask": r.clipping_mask, "addAround": r.add_around, }); - let mut whole = n.clone(); - whole.appearance.effects.remove(at); - (whole.opacity, whole.blend) = (1.0, Default::default()); - whole.extras_mut().mask = None; // shortcut: expanded Rasterize effects stay RGB, as the object keeps its own opacity mask and the // image's transparency would need one too; upgrade when CMYK images carry alpha. let image = super::menucmds::rasterize_art(d, vec![whole], &p, "object.rasterize", false).ok()?; let mut image = image.into_node(d); - if let Some((_, map)) = staged { + if let Some(map) = map { image.transform(map, false); } Some(image) } +/// What [`rasterize_effect_image`] makes its image of: `n`, or the art before the Transform effects +/// that move the image, without the Rasterize effect and without its transparency; that effect's +/// options; and the map those Transform effects move the image by. `None` when `n` has another +/// raster effect, when the Rasterize effect is not its own, or when those Transform effects +/// flatten the image. +fn rasterize_effect_art(d: &Document, n: &Node) -> Option<(Node, effects::Rasterize, Option)> { + let [RasterFx::Rasterize(r)] = raster_fx(n)[..] else { return None }; + let staged = vectorcraft_render::rasterize_stage(d, n); + if let Some((_, map)) = &staged + && !(map.determinant().is_finite() && map.determinant().abs() > 1e-12) + { + return None; + } + let (stage, map) = staged.map_or((None, None), |(stage, map)| (Some(stage), Some(map))); + let n = stage.as_ref().unwrap_or(n); + let at = n.appearance.effects.iter().position(|e| e.visible && e.id == effects::RASTERIZE)?; + let mut whole = n.clone(); + whole.appearance.effects.remove(at); + (whole.opacity, whole.blend) = (1.0, Default::default()); + whole.extras_mut().mask = None; + Some((whole, r, map)) +} + /// `v` (an object without its raster effects) replaced by `image` of the object with them: the /// image takes its place with its id, name and transparency (a layer keeps the image as its only /// member). diff --git a/crates/engine/src/tests/expand.rs b/crates/engine/src/tests/expand.rs index 0d2ce9d9f5..1039dab493 100644 --- a/crates/engine/src/tests/expand.rs +++ b/crates/engine/src/tests/expand.rs @@ -646,6 +646,46 @@ fn a_nested_instance_of_a_missing_symbol_stays_an_instance() { assert_eq!(instances_and_images(&n), (1, 0), "the inner instance stays, without an image"); } +/// 1,100 blurred instances in the outer art, far fewer objects than the symbol limit: one Expand +/// Appearance makes 1,024 images of them, and the other 76 stay instances with their blur, which +/// the result reports. +#[test] +fn nested_instance_raster_effects_stop_at_the_image_limit() { + let mut s = session(); + // Images of a pixel or two each. + run(&mut s, "document.rasterEffectsSettings", json!({"resolution": 1})); + let blur = |s: &mut Session, id: NodeId, row: usize| { + run(s, "effect.apply", json!({"ids": [id.0], "item": row, "effect": "blur.gaussian", "params": {"radius": 3}})); + }; + let (id, row) = nested_with_row(&mut s, blur); + offset_row(&mut s, id, row, 10.0); + { + let d = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc); + let outer = d.symbols.iter().position(|sym| sym.name == "Outer").unwrap(); + let inner = (*d.symbols[outer].art).clone(); + assert!(matches!(inner.kind, NodeKind::SymbolInstance { .. }), "the outer art is the inner instance"); + let copies = (0..1_100) + .map(|_| { + let mut copy = inner.clone(); + copy.id = d.alloc_id(); + std::sync::Arc::new(copy) + }) + .collect(); + d.symbols[outer].art = std::sync::Arc::new(Node::group(d.alloc_id(), copies)); + } + + let r = run(&mut s, "effect.expandAppearance", json!({})); + assert_eq!(r["rasterLeft"], 76, "{r}"); + assert!(r["warning"].as_str().is_some_and(|w| w.contains("1,024 images")), "{r}"); + let n = node(&s, id); + assert_eq!(instances_and_images(&n), (76, 1_024), "1,024 instances become images and the rest stay"); + n.walk(&mut |part| { + if matches!(part.kind, NodeKind::SymbolInstance { .. }) { + assert!(part.appearance.items.iter().any(|i| i.effects().iter().any(|e| e.id == "blur.gaussian")), "a left instance keeps its blur"); + } + }); +} + /// Export draws a symbol instance's fill shadow on the filled shapes of its art: baking leaves the /// shadow on the art's fill, not its stroke, and PDF export makes an image of it. #[test] diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 8bfcb382ff..147c28c065 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -5778,6 +5778,7 @@ digits Malayalam Malaiàlam @msg every numbered name for {name} is taken in the document's folder tots els noms numerats per a {name} estan ocupats a la carpeta del document @msg every search thread stopped on an internal error (please report this bug) tots els fils de cerca s’han aturat per un error intern (informeu d’aquest error) @msg Expand Appearance: the selection has a basic appearance Expandeix l’aparença: la selecció té una aparença bàsica +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all alguns efectes ràster no s’han convertit en imatges: ocuparien més de 1.024 imatges o 256 megapíxels en total @msg Expand: no brush strokes selected Expandeix: no s’ha seleccionat cap traç de pinzell @msg Expand: no gradient fills Expandeix: no hi ha farciments de degradat @msg Expand: nothing to expand Expandeix: no hi ha res per expandir diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index b56e4e4546..16a8333665 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -4837,6 +4837,7 @@ imageTrace Outline Obrys @msg Divide Objects Below: select exactly one path Rozdělit objekty pod: vyberte právě jednu cestu @msg Downloaded {what} Staženo: {what} @msg Expand Appearance: the selection has a basic appearance Rozložit vzhled: výběr má základní vzhled +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all některé rastrové efekty nebyly převedeny na obrazy: zabraly by více než 1 024 obrazů nebo celkem 256 megapixelů @msg Expand: no brush strokes selected Rozložit: nejsou vybrány žádné tahy štětcem @msg Expand: no gradient fills Rozložit: žádné přechodové výplně @msg Expand: nothing to expand Rozložit: není co rozložit diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 0856c10ddb..2e05208bca 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -5044,6 +5044,7 @@ imageTrace Outline Kontur @msg Divide Objects Below: select exactly one path Opdel objekter nedenunder: markér præcis én kurve @msg Downloaded {what} Downloadede {what} @msg Expand Appearance: the selection has a basic appearance Udvid udseende: markeringen har et grundlæggende udseende +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all nogle rastereffekter blev ikke lavet om til billeder: de ville kræve mere end 1.024 billeder eller i alt 256 megapixel @msg Expand: no brush strokes selected Udvid: ingen penselstrøg er markeret @msg Expand: no gradient fills Udvid: ingen gradientfyld @msg Expand: nothing to expand Udvid: intet at udvide diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 9c8a5719fb..56c644de68 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -4442,6 +4442,7 @@ theme Appearance Erscheinungsbild @msg Divide Objects Below: select exactly one path Darunterliegende Objekte aufteilen: Wählen Sie genau einen Pfad aus @msg Downloaded {what} {what} heruntergeladen @msg Expand Appearance: the selection has a basic appearance Aussehen umwandeln: Die Auswahl hat ein einfaches Aussehen +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all einige Rastereffekte wurden nicht in Bilder umgewandelt: Sie würden mehr als 1.024 Bilder oder insgesamt 256 Megapixel benötigen @msg Expand: no brush strokes selected Umwandeln: keine Pinselkonturen ausgewählt @msg Expand: no gradient fills Umwandeln: keine Verlaufsflächen @msg Expand: nothing to expand Umwandeln: nichts umzuwandeln diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 4593b28320..8046bfedbb 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -2535,6 +2535,7 @@ axis Both Και τα δύο @msg Divide Objects Below: select exactly one path Διαίρεση αντικειμένων από κάτω: επιλέξτε ακριβώς μία διαδρομή @msg Downloaded {what} Έγινε λήψη του {what} @msg Expand Appearance: the selection has a basic appearance Επέκταση εμφάνισης: η επιλογή έχει βασική εμφάνιση +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all ορισμένα εφέ ράστερ δεν μετατράπηκαν σε εικόνες: θα χρειάζονταν περισσότερες από 1.024 εικόνες ή συνολικά 256 megapixel @msg Expand: no brush strokes selected Επέκταση: δεν επιλέχθηκαν πινελιές @msg Expand: no gradient fills Επέκταση: δεν υπάρχουν γεμίσματα ντεγκραντέ @msg Expand: nothing to expand Επέκταση: δεν υπάρχει περιεχόμενο προς επέκταση diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 3bc56f7710..d9e8eaeba2 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -4531,6 +4531,7 @@ axis Both Ambos @msg Divide Objects Below: select exactly one path Dividir objetos inferiores: selecciona exactamente un trazado @msg Downloaded {what} Se descargó {what} @msg Expand Appearance: the selection has a basic appearance Expandir apariencia: la selección tiene una apariencia básica +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all algunos efectos ráster no se convirtieron en imágenes: ocuparían más de 1024 imágenes o 256 megapíxeles en total @msg Expand: no brush strokes selected Expandir: no hay trazos de pincel seleccionados @msg Expand: no gradient fills Expandir: no hay rellenos de degradado @msg Expand: nothing to expand Expandir: no hay nada que expandir diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 3c650e1fae..d788bcd082 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -4761,6 +4761,7 @@ imageTrace Outline Ääriviiva @msg Divide Objects Below: select exactly one path Jaa alla olevat objektit: valitse tasan yksi polku @msg Downloaded {what} Ladattiin {what} @msg Expand Appearance: the selection has a basic appearance Laajenna ulkoasu: valinnalla on perusulkoasu +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all joitakin rasteritehosteita ei muunnettu kuviksi: ne veisivät yli 1 024 kuvaa tai yhteensä 256 megapikseliä @msg Expand: no brush strokes selected Laajenna: sivellinviivoja ei ole valittu @msg Expand: no gradient fills Laajenna: ei liukuväritäyttöjä @msg Expand: nothing to expand Laajenna: ei laajennettavaa diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8fa5197575..fac071bae1 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -4509,6 +4509,7 @@ axis Both Les deux @msg select a path sélectionnez un tracé @msg Divide Objects Below: select exactly one path Diviser les objets inférieurs : sélectionnez exactement un tracé @msg Downloaded {what} {what} téléchargé +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all certains effets pixellisés n’ont pas été convertis en images, car ils occuperaient plus de 1024 images ou 256 mégapixels au total @msg Expand Appearance: the selection has a basic appearance Décomposer l’aspect : la sélection a un aspect de base @msg Expand: no brush strokes selected Décomposer : aucun contour de forme sélectionné @msg Expand: no gradient fills Décomposer : aucun fond en dégradé diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 46dcd33df0..738d4c2b55 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -6966,6 +6966,7 @@ antiAlias Sharp शार्प @msg every search thread stopped on an internal error (please report this bug) प्रत्येक खोज धागा एक आंतरिक त्रुटि पर बंद कर दिया (कृपया इस बग की रिपोर्ट करें) @msg exit isolation mode first पहले अलगाव मोड से बाहर निकलें @msg Expand Appearance: the selection has a basic appearance उपस्थिति का विस्तार: सिलेक्शन में एक बुनियादी उपस्थिति है +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all कुछ रास्टर इफ़ेक्ट इमेज में नहीं बदले गए: उनके लिए 1,024 से अधिक इमेज या कुल 256 मेगापिक्सेल लगते @msg Expand: no brush strokes selected विस्तार: सिलेक्टेड कोई ब्रश स्ट्रोक नहीं @msg Expand: no gradient fills एक्सपैंड: कोई ग्रेडिएंट फ़िल नहीं @msg Expand: nothing to expand विस्तार: विस्तार करने के लिए कुछ नहीं diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index c8e2630a80..3ac13e2ece 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5359,6 +5359,7 @@ imageTrace Outline Körvonal @msg the art of a graph design in a graph series is drawn again from the design: edit the design to change it egy diagram adatsorában a diagramminta grafikája a mintából rajzolódik újra: a módosításához szerkeszd a mintát @msg every search thread stopped on an internal error (please report this bug) minden keresési szál belső hibával leállt (kérjük, jelentsd ezt a hibát) @msg Expand Appearance: the selection has a basic appearance Megjelenés kibontása: a kijelölésnek alapmegjelenése van +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all néhány raszteres effektus nem lett képpé alakítva: több mint 1024 képet vagy összesen 256 megapixelt foglalnának @msg Expand: no brush strokes selected Kibontás: nincs kijelölt ecsetvonás @msg Expand: no gradient fills Kibontás: nincs színátmenetes kitöltés @msg Expand: nothing to expand Kibontás: nincs mit kibontani diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index fd18bf468a..1273a12a59 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4572,6 +4572,7 @@ axis Both Entrambi @msg Divide Objects Below: select exactly one path Dividi oggetti sottostanti: seleziona esattamente un tracciato @msg Downloaded {what} Scaricato {what} @msg Expand Appearance: the selection has a basic appearance Espandi aspetto: la selezione ha un aspetto di base +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all alcuni effetti raster non sono stati trasformati in immagini: richiederebbero più di 1.024 immagini o 256 megapixel in totale @msg Expand: no brush strokes selected Espandi: nessuna traccia di pennello selezionata @msg Expand: no gradient fills Espandi: nessun riempimento con sfumatura @msg Expand: nothing to expand Espandi: niente da espandere diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index ad5e529014..0fb16b8a70 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -4587,6 +4587,7 @@ swatch Bright Violet ビビッドバイオレット @msg no history to clear 消去するヒストリーがありません @msg no history state {v} ヒストリーの状態 {v} はありません @msg Expand Appearance: the selection has a basic appearance アピアランスを分割: 選択範囲は基本アピアランスです +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all 一部のラスター効果は画像になりませんでした: 1,024 枚または合計 256 メガピクセルを超えるためです @msg select (or target) objects whose appearance isn't basic 基本アピアランスではないオブジェクトを選択するか、ターゲットに指定してください @msg {C}: no effect at index {from} {C}: インデックス {from} に効果がありません @msg Expand: no gradient fills 拡張: グラデーションの塗りがありません diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 8012630d19..ef8dd85c77 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -4221,6 +4221,7 @@ font-technology Variable ცვლადი @msg Divide Objects Below: select exactly one path ქვედა ობიექტების დაყოფა: მონიშნეთ ზუსტად ერთი ტრაექტორია @msg Downloaded {what} ჩამოტვირთულია: {what} @msg Expand Appearance: the selection has a basic appearance იერსახის გაშლა: მონიშნულს საბაზისო იერსახე აქვს +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all ზოგიერთი რასტრული ეფექტი გამოსახულებად არ გადაიქცა: მათ დასჭირდებოდა 1024-ზე მეტი გამოსახულება ან ჯამში 256 მეგაპიქსელი @msg Expand: no brush strokes selected გაშლა: ფუნჯის შტრიხები მონიშნული არ არის @msg Expand: no gradient fills გაშლა: გრადიენტული შევსებები არ არის @msg Expand: nothing to expand გაშლა: გასაშლელი არაფერია diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 59ea323380..6aef199132 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -4514,6 +4514,7 @@ theme Appearance 외관 @msg no history to clear 지울 히스토리가 없습니다 @msg no history state {v} 히스토리 상태 {v}이(가) 없습니다 @msg Expand Appearance: the selection has a basic appearance 모양새 확장: 선택 항목은 기본 모양새입니다 +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all 일부 래스터 효과는 이미지로 만들지 않았습니다: 이미지 1,024개 또는 총 256메가픽셀을 넘기 때문입니다 @msg select (or target) objects whose appearance isn't basic 모양새가 기본이 아닌 개체를 선택(또는 대상 지정)하세요 @msg {C}: no effect at index {from} {C}: 인덱스 {from}에 효과가 없습니다 @msg Expand: no gradient fills 확장: 그레이디언트 칠이 없습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 3781549296..8da289b2d2 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -4941,6 +4941,7 @@ imageTrace Outline Contour @msg Divide Objects Below: select exactly one path Objecten eronder verdelen: selecteer precies één pad @msg Downloaded {what} {what} gedownload @msg Expand Appearance: the selection has a basic appearance Vormgeving uitbreiden: de selectie heeft een basisvormgeving +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all sommige rastereffecten zijn niet omgezet in afbeeldingen: ze zouden meer dan 1.024 afbeeldingen of in totaal 256 megapixel nodig hebben @msg Expand: no brush strokes selected Uitbreiden: geen penseelstreken geselecteerd @msg Expand: no gradient fills Uitbreiden: geen verloopvullingen @msg Expand: nothing to expand Uitbreiden: niets om uit te breiden diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index e014e51459..de3b790e1c 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -4660,6 +4660,7 @@ imageTrace Outline Kontur @msg Divide Objects Below: select exactly one path Podziel obiekty poniżej: zaznacz dokładnie jedną ścieżkę @msg Downloaded {what} Pobrano {what} @msg Expand Appearance: the selection has a basic appearance Rozszerz wygląd: zaznaczenie ma wygląd podstawowy +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all niektóre efekty rastrowe nie zostały zamienione na obrazy: zajęłyby więcej niż 1024 obrazy lub łącznie 256 megapikseli @msg Expand: no brush strokes selected Rozszerz: nie zaznaczono pociągnięć pędzla @msg Expand: no gradient fills Rozszerz: brak wypełnień gradientem @msg Expand: nothing to expand Rozszerz: nie ma czego rozszerzać diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 7ea80a830f..2251937be2 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -3904,6 +3904,7 @@ axis Both Ambos @msg Divide Objects Below: select exactly one path Dividir objetos abaixo: selecione exatamente um traçado @msg Downloaded {what} {what} baixado @msg Expand Appearance: the selection has a basic appearance Expandir aparência: a seleção tem uma aparência básica +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all alguns efeitos de raster não foram transformados em imagens: ocupariam mais de 1.024 imagens ou 256 megapixels no total @msg Expand: no brush strokes selected Expandir: nenhum traço de pincel selecionado @msg Expand: no gradient fills Expandir: nenhum preenchimento em gradiente @msg Expand: nothing to expand Expandir: nada para expandir diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 654bd10f09..ed090ba34f 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -4568,6 +4568,7 @@ axis Both Оба @msg Divide Objects Below: select exactly one path Разделение объектов ниже: выделите ровно один контур @msg Downloaded {what} Скачано: {what} @msg Expand Appearance: the selection has a basic appearance Разбор оформления: у выделения основное оформление +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all некоторые растровые эффекты не преобразованы в изображения: для них нужно больше 1024 изображений или 256 мегапикселей в сумме @msg Expand: no brush strokes selected Разбор: не выделены мазки кисти @msg Expand: no gradient fills Разбор: нет градиентных заливок @msg Expand: nothing to expand Разбор: нечего разбирать diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 439bda73f3..a506c93eee 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -4441,6 +4441,7 @@ axis Both Båda @msg Divide Objects Below: select exactly one path Dela objekt under: markera exakt en bana @msg Downloaded {what} Hämtade {what} @msg Expand Appearance: the selection has a basic appearance Expandera utseende: markeringen har ett grundläggande utseende +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all vissa rastereffekter gjordes inte om till bilder: de skulle kräva mer än 1 024 bilder eller totalt 256 megapixlar @msg Expand: no brush strokes selected Expandera: inga penseldrag är markerade @msg Expand: no gradient fills Expandera: inga gradientfyllningar @msg Expand: nothing to expand Expandera: ingenting att expandera diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 2d34869ac9..35cd79cf9a 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4286,6 +4286,7 @@ axis Both Her İkisi @msg Divide Objects Below: select exactly one path Aşağıdaki Nesneleri Böl: tam olarak bir yol seçin @msg Downloaded {what} {what} indirildi @msg Expand Appearance: the selection has a basic appearance Görünümü Genişlet: seçimin temel bir görünümü vardır +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all bazı raster efektleri görüntüye dönüştürülmedi: toplamda 1.024'ten fazla görüntü veya 256 megapiksel gerektirirlerdi @msg Expand: no brush strokes selected Genişlet: seçili fırça darbesi yok @msg Expand: no gradient fills Genişlet: degrade dolgu yok @msg Expand: nothing to expand Genişlet: genişletilecek bir şey yok diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 3ca32f6ee5..2899dc07d4 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -4556,6 +4556,7 @@ axis Both Обидві @msg Divide Objects Below: select exactly one path Поділ об’єктів нижче: виділіть рівно один контур @msg Downloaded {what} Завантажено: {what} @msg Expand Appearance: the selection has a basic appearance Розбір оформлення: виділення основне оформлення +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all деякі растрові ефекти не перетворено на зображення: для них потрібно понад 1024 зображення або загалом 256 мегапікселів @msg Expand: no brush strokes selected Розбір: не виділено мазки пензлі @msg Expand: no gradient fills Розбір: немає градієнтних заливок @msg Expand: nothing to expand Розбір: нема чого розбирати diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 1747a8ac37..ac42755e39 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5021,6 +5021,7 @@ theme Appearance Giao diện @msg every numbered name for {name} is taken in the document's folder mọi tên đánh số cho {name} đã được dùng trong thư mục tài liệu @msg every search thread stopped on an internal error (please report this bug) mọi luồng tìm kiếm đã dừng do lỗi nội bộ (vui lòng báo cáo lỗi này) @msg Expand Appearance: the selection has a basic appearance Mở rộng diện mạo: vùng chọn có diện mạo cơ bản +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all một số hiệu ứng raster không được chuyển thành hình ảnh: chúng sẽ cần hơn 1.024 hình ảnh hoặc tổng cộng 256 megapixel @msg Expand: no brush strokes selected Mở rộng: chưa chọn nét cọ @msg Expand: no gradient fills Mở rộng: không có tô chuyển sắc @msg Expand: nothing to expand Mở rộng: không có gì để mở rộng diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index a8846a9bac..90384bff68 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -4288,6 +4288,7 @@ imageTrace Outline 轮廓 @msg no history to clear 没有可清除的历史记录 @msg no history state {v} 没有历史记录状态 {v} @msg Expand Appearance: the selection has a basic appearance 扩展外观:所选对象只有基本外观 +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all 部分栅格效果未转换为图像:它们会超过 1,024 个图像或总计 256 兆像素 @msg select (or target) objects whose appearance isn't basic 请选择 (或定位) 外观不是基本外观的对象 @msg {C}: no effect at index {from} {C}:索引 {from} 处没有效果 @msg Expand: no gradient fills 扩展:没有渐变填色 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index c4235260ab..0cd675f57b 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -1936,6 +1936,7 @@ file-filter Templates 範本 @msg no history to clear 沒有可清除的步驟記錄 @msg no history state {v} 沒有步驟記錄 {v} @msg Expand Appearance: the selection has a basic appearance 展開外觀:選取範圍只有基本外觀 +@msg some raster effects were not made into images: they would take more than 1,024 images or 256 megapixels in all 部分點陣效果未轉換為影像:它們會超過 1,024 個影像或總計 256 百萬像素 @msg select (or target) objects whose appearance isn't basic 請選取 (或指定目標) 外觀不是基本外觀的物件 @msg {C}: no effect at index {from} {C}:索引 {from} 處沒有效果 @msg Expand: no gradient fills 展開:沒有漸層填色 diff --git a/docs/mcp.md b/docs/mcp.md index 17982bf02c..55ed65bec1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5251,6 +5251,10 @@ instance in the art whose topmost fill or stroke has a geometry or raster effect passes on, becomes its art and image the same way, and so do the instances in that art (VectorCraft's own rule). Before, an instance whose fill or stroke had only a shadow or glow stayed an instance over the image, and a raster effect on an instance in the art stayed live. +One Expand Appearance makes at most 1,024 images of raster effects, holding 256 megapixels in all (VectorCraft's own +limits). An object or symbol instance whose image would go past them stays as it is, with its effects and the objects +in it; the result then carries a `warning` and `rasterLeft`, the number of objects left so, and when nothing else +expands the command fails with the same message. A legacy `.ai` save notes it the same way. The result is `{ids}`; when an image in the art can't be decoded, the images made from raster effects do not show it, and the result also carries the `warning` that Flatten Transparency gives. A path's strokes stay strokes, as the