Merge pull request #8790 from storytold/train/carry8741

3D and Materials: graphics map onto Inflate objects (#7767) (#8741)
This commit is contained in:
BFlat authored and GitHub committed 2026-11-20 06:08:13 +07:00
commit 45f4050b2f
50 files changed
+1247 -189

No files matched your search

+2 -2
View File
@@ -198,8 +198,8 @@ pub fn effect_catalog() -> Vec<EffectInfo> {
INFLATE,
"Inflate…",
&["Effect", "3D and Materials"],
"{depth: pt (0..2000, 0; flat depth between front and back), twist: degrees (0..360, 0; the back turned against the front), taper: % (1..100, 100; the back's size), cap: bool (true: solid; false: no back, a shell open behind), volume: % (0..100, 50; 50 rounds the edge like a half sphere), bothSides: bool (false: flat back), 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, and how much it blurs the shadow), 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 shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it), 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), render: object ({mode: shaded}; mode: shaded|wireframe, as Revolve's)}. Painted with the top fill (else the top stroke).",
json!({"depth":0.0,"twist":0.0,"taper":100.0,"cap":true,"volume":50.0,"bothSides":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,"render":{"mode":"shaded"}}),
"{depth: pt (0..2000, 0; flat depth between front and back), twist: degrees (0..360, 0; the back turned against the front), taper: % (1..100, 100; the back's size), cap: bool (true: solid; false: no back, a shell open behind), volume: % (0..100, 50; 50 rounds the edge like a half sphere), bothSides: bool (false: flat back), 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, and how much it blurs the shadow), 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 shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it), 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), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the puffed front and back, see threeD.mapGraphic: symbol: name of a document symbol, face: front|back (front; the back reads left to right as seen from behind and takes graphics with bothSides and cap on), x: pt (0; the offset of the graphic's center from the center of the object's bounds, in the art's plane), y: pt (0), scale: % (1..10000, 100; of the symbol's own size), rotation: degrees (-360..360, 0; counterclockwise); carried straight out from the art's plane onto the puffed face, twist and taper turning and shrinking the back's with it, shaded with the surface and drawn only where its outside faces the viewer), render: object ({mode: shaded}; mode: shaded|wireframe, as Revolve's)}. Painted with the top fill (else the top stroke).",
json!({"depth":0.0,"twist":0.0,"taper":100.0,"cap":true,"volume":50.0,"bothSides":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,"graphics":[],"render":{"mode":"shaded"}}),
),
g(
ROTATE,
+11 -2
View File
@@ -229,11 +229,20 @@ pub(crate) fn seamed_fill(path: &vectorcraft_geom::PathData, seam: f64) -> Optio
/// footprints. Where two facets' antialiased edges meet, the underlay fills what they leave
/// uncovered with the neighbors' own colors, so the background does not show through. `None` unless
/// every face is a facet a surface draws: a path filled and stroked by its seam, or a facet composed
/// in a clip of its footprint, neither with an opacity mask.
/// in a clip of its footprint, neither with an opacity mask. A face drawn with the parts of Inflate's
/// graphics on it, a group of the facet and those parts, takes its facet's underlay and stays in the
/// order with its parts, which are cut to the facet's outline, so the clip keeps them.
pub(crate) fn sealed(id: vectorcraft_doc::NodeId, faces: &[std::sync::Arc<vectorcraft_doc::Node>]) -> Option<vectorcraft_doc::Node> {
use std::sync::Arc;
use vectorcraft_doc::{Node, NodeKind};
let (clip, mut underlay) = underlay(id, faces)?;
let facets: Vec<Arc<Node>> = faces
.iter()
.map(|face| match &face.kind {
NodeKind::Group { children, clip: false } if face.extras().mask.is_none() => children.first().cloned(),
_ => Some(face.clone()),
})
.collect::<Option<_>>()?;
let (clip, mut underlay) = underlay(id, &facets)?;
underlay.extend(faces.iter().cloned());
Some(Node::new(id, NodeKind::Group { children: vec![Arc::new(clip), Arc::new(Node::group(id, underlay))], clip: true }))
}
+2 -1
View File
@@ -382,7 +382,8 @@ fn revolve_takes_graphics_on_its_side_only() {
let kept = three_d_params_as(crate::EXTRUDE, &both, REVOLVE);
assert_eq!(kept["graphics"].as_array().map(Vec::len), Some(1));
assert_eq!(kept["graphics"][0]["symbol"], "Red");
assert_eq!(three_d_params_as(REVOLVE, &front, crate::INFLATE).get("graphics"), None);
// Inflate keeps them, and its front takes them.
assert_eq!(three_d_params_as(REVOLVE, &front, crate::INFLATE)["graphics"], front["graphics"]);
}
#[test]
+136 -35
View File
@@ -98,13 +98,15 @@ pub fn three_d_params_as(from: &str, params: &Value, to: &str) -> Value {
}
}
// A plane has only a front, and Revolve's graphics go on its side, named the front, so graphics
// on the back cap and on Extrude & Bevel's side are dropped.
if (to == ROTATE || to == crate::REVOLVE)
// on the back cap and on Extrude & Bevel's side are dropped. Inflate takes graphics on its front
// and back, so it drops those on the side.
if (to == ROTATE || to == crate::REVOLVE || to == INFLATE)
&& let Some(Value::Array(list)) = out.get_mut(GRAPHICS)
{
let back = to != INFLATE;
list.retain(|g| {
let face = g.get("face").and_then(Value::as_str);
face != Some(PlanarFace::Back.id()) && face != Some(PlanarFace::Side.id())
!(back && face == Some(PlanarFace::Back.id())) && face != Some(PlanarFace::Side.id())
});
}
Value::Object(out)
@@ -259,6 +261,7 @@ pub fn inflate_options(p: &Value) -> Inflate {
twist: num(p, "twist", 0.0),
taper: num(p, "taper", 100.0) / 100.0,
cap: flag(p, "cap", true),
map_surface: false,
}
}
@@ -444,7 +447,8 @@ pub fn validate_solid_in(doc: Option<&Document>, n: &Node, id: &str, p: &Value)
/// Inflate or Rotate, as drawn, or a new one after its other effects when it has none.
fn validate_solid_for(doc: Option<&Document>, n: &Node, id: &str, p: &Value, at: (Option<usize>, Option<usize>)) -> Result<(), String> {
validate_solid_params(id, p)?;
if let Some(doc) = doc {
// In wireframe mode the edges are drawn with no graphics, and their art is not checked.
if let Some(doc) = doc.filter(|_| !wireframe::wireframe_params(id, p)) {
graphics::validate_symbols(doc, p)?;
}
let label = label_of(id);
@@ -461,7 +465,8 @@ fn validate_solid_for(doc: Option<&Document>, n: &Node, id: &str, p: &Value, at:
let b = union_bounds(&shapes).ok_or_else(|| format!("{label} requires a group holding a shape with at least two anchors"))?;
check_profiles(id, p, &shapes, b)?;
check_solids(id, p, &shapes)?;
return check_side_graphics(doc, n, id, p, &shapes);
check_side_graphics(doc, n, id, p, &shapes)?;
return check_membrane_graphics(doc, n, id, p, &shapes);
}
let (path, rule) = object_profile(n, label)?;
let anchors = || format!("{label} requires a shape with at least two anchors");
@@ -479,7 +484,8 @@ fn validate_solid_for(doc: Option<&Document>, n: &Node, id: &str, p: &Value, at:
let shapes = [Profile { path, rule, items, opacity: 1.0, scopes: vec![] }];
check_profiles(id, p, &shapes, b)?;
check_solids(id, p, &shapes)?;
check_side_graphics(doc, n, id, p, &shapes)
check_side_graphics(doc, n, id, p, &shapes)?;
check_membrane_graphics(doc, n, id, p, &shapes)
}
/// Does 3D effect `id` with parameters `p` cast a shadow: is it Extrude & Bevel, Inflate or Rotate
@@ -493,6 +499,30 @@ fn visible(item: &AppearanceItem, member: f32) -> bool {
paint_of(item, member).1 > 0.0
}
/// An error when the graphics of Inflate `id` with parameters `p`, with the symbols of `doc`, are
/// past their limits on the front and puffed back of the solids of `shapes`: their art, or the
/// parts they draw on its pieces ([`graphics::surface_parts`]), or when the solids can't be built
/// with their pieces carrying the graphics. They are built as the art builds them
/// ([`surfaces_with`]). Without `doc` nothing is drawn, and nothing is checked. In wireframe mode no
/// graphics are drawn, and none are checked.
fn check_membrane_graphics(doc: Option<&Document>, n: &Node, id: &str, p: &Value, shapes: &[Profile]) -> Result<(), String> {
let Some(doc) = doc else { return Ok(()) };
if id != INFLATE || wireframe::wireframe_params(id, p) || mapped_graphics(p).is_empty() {
return Ok(());
}
for face in [PlanarFace::Front, PlanarFace::Back] {
graphics::validate_surface_symbols(doc, p, face)?;
}
let fx = Effect { id: id.into(), params: p.clone(), visible: true };
let mut dropped = false;
// Art that can't be built with the graphics draws without them.
let built = surfaces_with(Some(doc), n, &fx, shapes, false, true, &mut dropped);
if dropped || built.is_none() {
return Err("The graphics are too complex: simplify the symbols' art".into());
}
Ok(())
}
/// An error when the graphics on the side of Extrude & Bevel `id` with parameters `p`, with the
/// symbols of `doc`, are past their limits on the side of the solid of `shapes` that takes them
/// ([`side_carrier`]): their art, or the parts they draw on its pieces
@@ -521,7 +551,7 @@ fn check_side_graphics(doc: Option<&Document>, n: &Node, id: &str, p: &Value, sh
let fx = Effect { id: id.into(), params: p.clone(), visible: true };
let mut dropped = false;
// Art that can't be built draws the source path, without the side's graphics.
let built = surfaces_with(Some(doc), n, &fx, shapes, false, &mut dropped);
let built = surfaces_with(Some(doc), n, &fx, shapes, false, false, &mut dropped);
if dropped || built.is_none() {
return Err("The graphics are too complex: simplify the symbols' art".into());
}
@@ -572,7 +602,7 @@ fn check_solids(id: &str, p: &Value, shapes: &[Profile]) -> Result<(), String> {
if !cast {
return built_solids(id, p, &parts, bounds, MAX_OBJECT_FACES).try_for_each(|r| r.map(|_| ()));
}
let built = built_solids_cast(id, p, &parts, bounds, MAX_OBJECT_FACES, true, None)
let built = built_solids_cast(id, p, &parts, bounds, MAX_OBJECT_FACES, true, false, None)
.map(|r| r.map(|solid| solid.and_then(|(_, faces)| faces)))
.collect::<Result<Vec<_>, String>>()?;
cast_built(id, p, shapes, built).map(|_| ())
@@ -846,11 +876,37 @@ fn surface(n: &Node, facets: Vec<Facet>, paint: &Paint, opacity: f32, blend: Ble
group
}
/// The parts of `graphics` that fall on each of `facets`, the facets of one of Inflate's solids in
/// drawing order, built with their front and puffed back carrying the graphics
/// ([`vectorcraft_three_d::Inflate::map_surface`]): for each facet, the parts of the graphics on
/// its face to draw right after it ([`graphics::surface_parts`]), shaded as a solid color is on
/// that facet. `copies` counts the bytes of the paint copies of the object's graphics. `None` past
/// the graphics' limits.
fn membrane_parts(
doc: Option<&Document>,
id: NodeId,
graphics: &[MappedGraphic],
facets: &[Facet],
copies: &mut usize,
) -> Option<Vec<Vec<Arc<Node>>>> {
let shade = |f: &graphics::OnFace<'_>, c: vectorcraft_doc::color::Color| Paint::solid(crate::lighting::shade(c, f.facet.illumination));
let mut out: Vec<Vec<Arc<Node>>> = vec![vec![]; facets.len()];
for face in [PlanarFace::Front, PlanarFace::Back].into_iter().filter(|face| graphics.iter().any(|g| g.face == *face)) {
let on: Vec<graphics::OnFace<'_>> = facets.iter().map(|facet| graphics::OnFace { facet, face }).collect();
let parts = graphics::surface_parts(doc, id, (graphics, face), &on, &shade, copies)?;
for (slot, extra) in out.iter_mut().zip(parts) {
slot.extend(extra);
}
}
Some(out)
}
/// `surface`, a plain group of one face for each facet ([`surface`]), with each face followed by
/// the parts of the side's graphics that `parts` holds for its facet ([`graphics::surface_parts`]):
/// a face with parts becomes a group of the face and its parts, so nearer faces drawn after it
/// cover them too. `surface` is returned as it is when no facet has a part or it is not such a group.
fn with_side_parts(id: NodeId, mut surface: Node, parts: Vec<Vec<Arc<Node>>>) -> Node {
/// the parts of the graphics that `parts` holds for its facet (on Extrude & Bevel's side
/// [`graphics::surface_parts`], on Inflate's front and back [`membrane_parts`]): a face with parts
/// becomes a group of the face and its parts, so nearer faces drawn after it cover them too.
/// `surface` is returned as it is when no facet has a part or it is not such a group.
fn with_surface_parts(id: NodeId, mut surface: Node, parts: Vec<Vec<Arc<Node>>>) -> Node {
if parts.iter().all(Vec::is_empty) {
return surface;
}
@@ -984,7 +1040,7 @@ fn built_solids<'a>(
bounds: Rect,
limit: usize,
) -> impl Iterator<Item = Result<Option<Vec<Facet>>, String>> + 'a {
built_solids_cast(id, p, parts, bounds, limit, false, None).map(|r| r.map(|s| s.map(|(f, _)| f)))
built_solids_cast(id, p, parts, bounds, limit, false, false, None).map(|r| r.map(|s| s.map(|(f, _)| f)))
}
/// One solid's facets and, when its shadow is cast, the faces it is cast from.
@@ -995,9 +1051,12 @@ type CastingSolid = (Vec<Facet>, Option<SolidFaces>);
type SurfacesAndFaces = (Vec<Arc<Node>>, Vec<Option<SolidFaces>>);
/// [`built_solids`], and with `cast` for Extrude & Bevel or Inflate each solid's faces its shadow
/// is cast from, from the same build ([`SolidFaces`]). The solid of part `side`, when there is one,
/// is built with the pieces of its side carrying where they lie on it unrolled, for the graphics
/// on Extrude & Bevel's side ([`side_carrier`]).
/// is cast from, from the same build ([`SolidFaces`]). With `membrane`, Inflate's solids are built
/// with the pieces of their front and puffed back carrying where they lie in the art's plane, for
/// the graphics drawn on them ([`vectorcraft_three_d::Inflate::map_surface`]). The solid of part
/// `side`, when there is one, is built with the pieces of its side carrying where they lie on it
/// unrolled, for the graphics on Extrude & Bevel's side ([`side_carrier`]).
#[allow(clippy::too_many_arguments)] // the build's inputs and the two surfaces that carry graphics
fn built_solids_cast<'a>(
id: &'a str,
p: &'a Value,
@@ -1005,12 +1064,13 @@ fn built_solids_cast<'a>(
bounds: Rect,
limit: usize,
cast: bool,
membrane: bool,
side: Option<usize>,
) -> impl Iterator<Item = Result<Option<CastingSolid>, String>> + 'a {
// Inflate's eye is placed for every puff together, as far away as the highest needs.
let mut inflated = (id == INFLATE).then(|| -> Box<dyn Iterator<Item = Result<CastingSolid, String>>> {
let shapes: Vec<(&PathData, FillRule)> = parts.iter().map(|(_, _, area, rule, _, _)| (area, *rule)).collect();
let (o, view) = (inflate_options(p), view_options(p));
let (o, view) = (Inflate { map_surface: membrane, ..inflate_options(p) }, view_options(p));
if cast {
Box::new(vectorcraft_three_d::inflate_shadowed(&shapes, bounds, o, view).map(|r| r.map(|(f, faces)| (f, Some(faces)))))
} else {
@@ -1962,14 +2022,33 @@ fn seen_ends(f: &[Facet]) -> impl Iterator<Item = &Facet> {
/// [`art_for`] without the shadow: the solids' surfaces, with the graphics mapped onto their planar
/// faces drawn right after the last of the solids' surfaces that holds that face. With `cast`, each
/// solid built also keeps the faces its shadow is cast from, from the same build, in the order the
/// solids are built ([`cast_built`]); `None` for a stroke's solid left out of the art.
/// solids are built ([`cast_built`]); `None` for a stroke's solid left out of the art. Inflate's
/// graphics are drawn on the pieces of its front and puffed back; when its solids can't be built
/// with those pieces, or the graphics are past their limits on them, the solids draw without them.
fn surfaces_for(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profile], cast: bool) -> Option<SurfacesAndFaces> {
surfaces_with(doc, n, fx, shapes, cast, &mut false)
let p = crate::merged_params(&fx.id, &fx.params);
if fx.id == INFLATE && doc.is_some() && !mapped_graphics(&p).is_empty() {
let mut dropped = false;
if let Some(built) = surfaces_with(doc, n, fx, shapes, cast, true, &mut dropped).filter(|_| !dropped) {
return Some(built);
}
}
surfaces_with(doc, n, fx, shapes, cast, false, &mut false)
}
/// [`surfaces_for`], setting `side_dropped` when the graphics on Extrude & Bevel's side are past
/// their limits on the pieces drawn, and the solid that takes them draws without them.
fn surfaces_with(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profile], cast: bool, side_dropped: &mut bool) -> Option<SurfacesAndFaces> {
/// [`surfaces_for`], with `membrane` building Inflate's solids with their front and puffed back
/// carrying the graphics ([`built_solids_cast`]), and setting `dropped` when those graphics, or the
/// graphics on Extrude & Bevel's side, are past their limits on the pieces drawn and the solid that
/// takes them draws without them.
fn surfaces_with(
doc: Option<&Document>,
n: &Node,
fx: &Effect,
shapes: &[Profile],
cast: bool,
membrane: bool,
dropped: &mut bool,
) -> Option<SurfacesAndFaces> {
let b = union_bounds(shapes)?;
let p = crate::merged_params(&fx.id, &fx.params);
let classic = fx.id == CLASSIC_EXTRUDE || fx.id == CLASSIC_ROTATE;
@@ -2025,7 +2104,7 @@ fn surfaces_with(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profil
let map_art = MapArt::of(doc, &fx.id, &p).filter(|_| fx.id == CLASSIC_EXTRUDE);
let mut layouts: Vec<SolidLayout> = vec![];
let mut surfaces_before = 0usize;
let made = built_solids_cast(&fx.id, &p, &parts, bounds, MAX_OBJECT_FACES, cast, carrier);
let made = built_solids_cast(&fx.id, &p, &parts, bounds, MAX_OBJECT_FACES, cast, membrane, carrier);
for (k, ((item, opacity, area, rule, scopes, member), f)) in parts.iter().zip(made).enumerate() {
let item: &AppearanceItem = item;
let layout = map_art.as_ref().map(|_| {
@@ -2044,11 +2123,12 @@ fn surfaces_with(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profil
layouts.extend(layout);
built.push(faces);
}
// A stroke's outline past the limits is left out; the fill's solid still draws, and
// A stroke's outline past the limits is left out; the fill's solid still draws. Built
// with the graphics' pieces, a stroke past the limits draws without the graphics, and
// the side's graphics on that outline are not drawn.
Ok(None) => {
built.push(None);
*side_dropped |= carrier == Some(k);
*dropped |= membrane || carrier == Some(k);
}
// A loaded file or a shape edited past the limits (its own, or those of the object's
// solids together) keeps drawing its source path instead of failing the frame;
@@ -2161,8 +2241,10 @@ fn surfaces_with(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profil
// ([`in_one_order`], [`underlaid_surface`]).
let seals: Vec<bool> = solids.iter().map(|(.., f, _)| underlaid(f, colored)).collect();
let seal = |range: std::ops::Range<usize>| seals.get(range).is_some_and(|s| s.iter().any(|s| *s));
let membrane_graphics = if membrane && graphics_on { mapped_graphics(&p) } else { vec![] };
let side_graphics = carrier.map(|_| mapped_graphics(&p)).unwrap_or_default();
// The paint copies of the side's graphics, apart from those of the surfaces, as on Revolve.
// The paint copies of Inflate's graphics and of the side's, apart from those of the surfaces,
// as on Revolve.
let mut graphic_copies = 0usize;
let surfaces: Vec<BuiltSurface> = solids
.into_iter()
@@ -2171,22 +2253,29 @@ fn surfaces_with(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profil
let depths: Vec<Placed> = f.iter().map(|f| Placed::of(f, shape, paints)).collect();
let ends = f.iter().map(|f| f.end.filter(|_| !f.away)).collect();
let (paint, opacity, blend) = paint_of(item, member);
// The carrier's pieces draw the parts of the side's graphics that fall on them; past
// the graphics' limits the solid draws without them.
let parts = if side_graphics.is_empty() || !f.iter().any(|f| f.surface.is_some()) {
// The pieces of Inflate's front and back, and the carrier's pieces of Extrude & Bevel's
// side, draw the parts of the graphics that fall on them; past the graphics' limits the
// solid draws without them.
let parts = if !f.iter().any(|f| f.surface.is_some()) {
vec![]
} else {
} else if !membrane_graphics.is_empty() {
let parts = membrane_parts(doc, n.id, &membrane_graphics, &f, &mut graphic_copies);
*dropped |= parts.is_none();
parts.unwrap_or_default()
} else if !side_graphics.is_empty() {
let shade = |f: &Facet, c: vectorcraft_doc::color::Color| Paint::solid(crate::lighting::shade(c, f.illumination));
let parts = graphics::surface_parts(doc, n.id, (&side_graphics, PlanarFace::Side), &f, &shade, &mut graphic_copies);
*side_dropped |= parts.is_none();
*dropped |= parts.is_none();
parts.unwrap_or_default()
} else {
vec![]
};
let drawn = parts.iter().any(|p| !p.is_empty());
let art = if classic {
classic_arts.next().unwrap_or_else(|| Node::group(n.id, vec![]))
} else {
let faces = drawn || (split && shared.get(shape).copied().unwrap_or(false));
with_side_parts(n.id, surface(n, f, &paint, opacity, blend, colored, faces), parts)
with_surface_parts(n.id, surface(n, f, &paint, opacity, blend, colored, faces), parts)
};
(depths, art, scopes, ends)
})
@@ -2476,14 +2565,15 @@ fn group_solid_art(doc: Option<&Document>, n: &Node) -> Option<Node> {
/// Where the graphics of the 3D effect of `n` (on the object itself with `item` `None`, else on its
/// fill or stroke `item`) are drawn: the bounds its solids are built with and the maps of their
/// planar faces ([`graphics::GraphicFrame`]). `None` when `n` has no visible Extrude & Bevel or
/// Rotate there, or its art can't be built.
/// planar faces, or Inflate's puffed faces ([`graphics::GraphicFrame`]). `None` when `n` has no
/// visible Extrude & Bevel, Inflate or Rotate there, or its art can't be built.
pub fn graphic_frame(doc: Option<&Document>, n: &Node, item: Option<usize>) -> Option<graphics::GraphicFrame> {
frame_of(doc, n, item, &solid)
}
/// [`graphic_frame`] of the 3D effect at `index` in that list, which must be a visible Extrude &
/// Bevel, Rotate or Revolve. Revolve's frame is its unrolled side seen from the front, centered on
/// Bevel, Rotate, Revolve or Inflate. Inflate's frame places handles on the pieces of its puffed
/// front and back the viewer sees. Revolve's frame is its unrolled side seen from the front, centered on
/// the origin, with no face maps: it sizes a new graphic and places no handles.
pub fn graphic_frame_at(doc: Option<&Document>, n: &Node, item: Option<usize>, index: usize) -> Option<graphics::GraphicFrame> {
frame_of(doc, n, item, &|fx: &[Effect]| fx.get(index).filter(|e| e.visible && is_three_d(&e.id)).map(|e| (index, e)))
@@ -2546,6 +2636,17 @@ fn frame_of(doc: Option<&Document>, n: &Node, item: Option<usize>, pick: &Pick<'
return Some(graphics::GraphicFrame::new(b, plane, None));
}
let (parts, bounds) = solid_parts(&shapes, b);
if fx.id == INFLATE {
// Inflate's graphics lie on its puffed front and back: the pieces the viewer sees place
// their handles. A stroke left out places none of its own. When a fill's solid can't be
// built, or the solids together pass the limit, the art draws its source and no piece
// places a handle.
let built: Vec<Facet> = built_solids_cast(INFLATE, &p, &parts, bounds, MAX_OBJECT_FACES, false, true, None)
.collect::<Result<Vec<_>, String>>()
.map(|solids| solids.into_iter().flatten().flat_map(|(f, _)| f).collect())
.unwrap_or_default();
return Some(graphics::GraphicFrame::inflated(bounds, graphics::MembraneFrame::of(&built)));
}
let options = extrude_options(&p);
let map = |face| vectorcraft_three_d::extrude_face_map(bounds, options, view, face);
let frame = graphics::GraphicFrame::new(bounds, map(PlanarFace::Front), map(PlanarFace::Back));
+242 -56
View File
@@ -16,7 +16,14 @@
//! Bevel's side (face `side`) lie on its walls and bevels unrolled the same way, x along the
//! outline and y from the front toward the back, drawn on the pieces of the side of the solid with
//! the longest outline.
//!
//! On Inflate the graphics lie on the puffed front, and on the puffed back when Both Sides is on:
//! each is placed in the art's plane as on Extrude & Bevel's caps and carried straight out onto
//! the surface above it, so it follows the puff. Each piece of the surface draws the part of the
//! graphics that falls on it, as on Revolve's side, and the twist and taper carry the back's
//! graphics with the back.
use std::borrow::Cow;
use std::sync::Arc;
use serde_json::{Map, Value, json};
@@ -24,7 +31,7 @@ use vectorcraft_doc::color::{BlendMode, Paint};
use vectorcraft_doc::{Appearance, AppearanceItem, Document, FillLayer, Node, NodeId, NodeKind, Symbol};
use vectorcraft_geom::kurbo::{CubicBez, ParamCurve, PathEl, Shape};
use vectorcraft_geom::{Affine, BezPath, FillRule, PathData, Point, Rect, SubPath, Vec2};
use vectorcraft_three_d::{FaceMap, Facet, PlanarFace};
use vectorcraft_three_d::{DepthPlane, FaceMap, Facet, PlanarFace};
/// The effect parameter that holds the graphics.
pub const GRAPHICS: &str = "graphics";
@@ -50,7 +57,7 @@ const MAX_NESTING: usize = 8;
const MAX_LEVELS: usize = 4 * vectorcraft_doc::MAX_DEPTH;
/// The error for graphics on a 3D effect that takes none.
pub const NOT_TAKEN: &str = "Graphics map onto the Plane, Extrude and Revolve object types";
pub const NOT_TAKEN: &str = "Graphics map onto the Plane, Extrude, Revolve and Inflate object types";
/// The buckets around the unrolled side surface that the pieces of Revolve's graphics are sorted
/// into, so each face looks only at the pieces near it.
@@ -151,10 +158,10 @@ impl MappedGraphic {
}
}
/// The 3D effects that take graphics: Extrude & Bevel (its caps and its side), Rotate (the plane)
/// and Revolve (its swept side).
/// The 3D effects that take graphics: Extrude & Bevel (its caps and its side), Rotate (the plane),
/// Revolve (its swept side) and Inflate (its puffed front and back).
pub fn takes_graphics(id: &str) -> bool {
id == super::EXTRUDE || id == super::ROTATE || id == crate::REVOLVE
id == super::EXTRUDE || id == super::ROTATE || id == crate::REVOLVE || id == super::INFLATE
}
/// The graphics in parameters `p`, leaving out entries that are not valid (a file may hold
@@ -166,9 +173,9 @@ pub fn mapped_graphics(p: &Value) -> Vec<MappedGraphic> {
}
}
/// Are the graphics in parameters `p` of 3D effect `id` valid? Only Extrude & Bevel, Rotate and
/// Revolve take graphics; a plane has only a front, and Revolve's graphics go on its side, named
/// the front. Only Extrude & Bevel takes graphics on its side.
/// Are the graphics in parameters `p` of 3D effect `id` valid? Only Extrude & Bevel, Rotate,
/// Revolve and Inflate take graphics; a plane has only a front, and Revolve's graphics go on its
/// side, named the front. Only Extrude & Bevel takes graphics on its side.
pub fn validate(id: &str, p: &Value) -> Result<(), String> {
// Map Art's maps are checked with the graphics: an effect that takes none refuses them.
map_art::validate(id, p)?;
@@ -194,6 +201,9 @@ pub fn validate(id: &str, p: &Value) -> Result<(), String> {
if id == crate::REVOLVE && g.face != PlanarFace::Front {
return Err("Revolve maps graphics onto its side: map them onto the front".into());
}
if id == super::INFLATE && g.face == PlanarFace::Side {
return Err("Inflate maps graphics onto its front and back, not onto a side".into());
}
}
Ok(())
}
@@ -629,10 +639,11 @@ struct Unrolled {
place: Affine,
}
/// The areas of `graphics` on `face` (the front, for Revolve's side, or Extrude & Bevel's side)
/// placed on the unrolled side surface, cut into straight pieces. A graphic whose symbol `doc` does
/// not have, or whose art is past the limits of [`pieces_of`], is left out. `None` when the pieces
/// take more than [`MAX_ELEMENTS`] points together.
/// The areas of `graphics` on `face` (the front, for Revolve's side; Extrude & Bevel's side;
/// Inflate's front or back) placed on the unrolled side surface, or in the art's plane about the
/// center of the object's bounds, cut into straight pieces. A graphic whose symbol `doc` does not
/// have, or whose art is past the limits of [`pieces_of`], is left out. `None` when the pieces take
/// more than [`MAX_ELEMENTS`] points together.
fn unrolled(doc: &Document, graphics: &[MappedGraphic], face: PlanarFace) -> Option<Vec<Unrolled>> {
let mut pieces = vec![];
let mut points = 0usize;
@@ -713,9 +724,9 @@ fn straight_pieces(path: &BezPath, points: &mut usize) -> Option<Vec<Vec<Point>>
(*points <= MAX_ELEMENTS).then_some(polygons)
}
/// Do the graphics on `face` in parameters `p` (the front of Revolve, Extrude & Bevel's side) fit
/// the limits with the symbols of `doc`? Their art, cut into straight pieces on the side surface,
/// may take up to [`MAX_ELEMENTS`] points together.
/// Do the graphics on `face` in parameters `p` (the front of Revolve; Extrude & Bevel's side;
/// Inflate's front or back) fit the limits with the symbols of `doc`? Their art, cut into straight
/// pieces on the surface, may take up to [`MAX_ELEMENTS`] points together.
pub(crate) fn validate_surface_symbols(doc: &Document, p: &Value, face: PlanarFace) -> Result<(), String> {
let list = mapped_graphics(p);
if !list.iter().any(|g| g.face == face) || unrolled(doc, &list, face).is_some() {
@@ -724,16 +735,16 @@ pub(crate) fn validate_surface_symbols(doc: &Document, p: &Value, face: PlanarFa
Err("The graphics are too complex: simplify the symbols' art".into())
}
/// A face of a side surface that graphics are drawn on ([`surface_parts`]): a face of Revolve's
/// swept side, or a piece of Extrude & Bevel's walls and bevels.
/// A face of a surface that graphics are drawn on ([`surface_parts`]): a face of Revolve's swept
/// side, a piece of Extrude & Bevel's walls and bevels, or a piece of Inflate's front or back.
pub(crate) trait SurfaceFace {
/// Where the face lies on the side unrolled, when it is a face of the side that shows its
/// outside to the viewer.
/// Where the face lies on the surface, when it carries graphics and shows the surface's outside
/// to the viewer.
fn outer_cell(&self) -> Option<&vectorcraft_three_d::SurfaceCell>;
/// The outline the face's parts are cut to, when it is not the polygon of its cell's corners:
/// its curved outline, when its edges along an end are curved, or the outline of a piece cut
/// from a larger face.
fn curved(&self) -> Option<std::borrow::Cow<'_, PathData>>;
fn curved(&self) -> Option<Cow<'_, PathData>>;
fn rgb_light(&self) -> Option<vectorcraft_three_d::RgbGradient>;
fn light(&self) -> [f64; 3];
fn outline_path(&self) -> PathData;
@@ -743,8 +754,8 @@ impl SurfaceFace for vectorcraft_three_d::Face {
fn outer_cell(&self) -> Option<&vectorcraft_three_d::SurfaceCell> {
self.surface.as_ref().filter(|c| c.outward && !self.cap)
}
fn curved(&self) -> Option<std::borrow::Cow<'_, PathData>> {
self.outline.as_ref().map(std::borrow::Cow::Borrowed)
fn curved(&self) -> Option<Cow<'_, PathData>> {
self.outline.as_ref().map(Cow::Borrowed)
}
fn rgb_light(&self) -> Option<vectorcraft_three_d::RgbGradient> {
self.rgb_gradient
@@ -757,17 +768,18 @@ impl SurfaceFace for vectorcraft_three_d::Face {
}
}
/// A piece of Extrude & Bevel's side ([`Facet::surface`]).
impl SurfaceFace for Facet {
fn outer_cell(&self) -> Option<&vectorcraft_three_d::SurfaceCell> {
self.surface.as_ref().filter(|c| c.outward)
}
fn curved(&self) -> Option<std::borrow::Cow<'_, PathData>> {
fn curved(&self) -> Option<Cow<'_, PathData>> {
if let Some(outline) = &self.outline {
return Some(std::borrow::Cow::Borrowed(outline));
return Some(Cow::Borrowed(outline));
}
// A piece of a stroke's face cut where it passes through a wall keeps its face's cell.
let cut = self.surface.as_ref().is_some_and(|c| self.contours.len() != 1 || self.contours.first() != Some(&c.page));
cut.then(|| std::borrow::Cow::Owned(self.path()))
cut.then(|| Cow::Owned(self.path()))
}
fn rgb_light(&self) -> Option<vectorcraft_three_d::RgbGradient> {
self.rgb_gradient
@@ -780,18 +792,48 @@ impl SurfaceFace for Facet {
}
}
/// The parts of the graphics on `face` of `graphics` (the front of Revolve, Extrude & Bevel's side)
/// that fall on each of `faces`, a side surface's faces in drawing order, for an object with id
/// `id`: for each face, the nodes to draw right after it. Only faces of the side that show their
/// outside to the viewer carry a part, so a graphic narrows toward the silhouette, is hidden past
/// it and is covered by the nearer faces drawn after it. `shade` gives the paint of a solid color
/// on a face, as the surface under it is shaded; the colors of gradients and patterns are
/// multiplied by the face's light. A graphic whose symbol `doc` does not have, or that is past the
/// limits of its art, draws nothing. `None` past [`MAX_ELEMENTS`] points together before they are
/// cut at the faces, [`MAX_SURFACE_POINTS`] after, [`MAX_SURFACE_CUTS`] points cut, or when the
/// copies of their paints in the parts take `copies`, the bytes of the copies of the object's
/// graphics so far, past Revolve's budget for them: commands refuse such graphics, and a loaded
/// file draws the surface without them.
/// A piece of Inflate's front or back ([`Facet::membrane`]) that carries graphics on `face` only.
pub(crate) struct OnFace<'a> {
pub(crate) facet: &'a Facet,
pub(crate) face: PlanarFace,
}
impl SurfaceFace for OnFace<'_> {
fn outer_cell(&self) -> Option<&vectorcraft_three_d::SurfaceCell> {
self.facet.surface.as_ref().filter(|c| c.outward && self.facet.membrane == Some(self.face))
}
fn curved(&self) -> Option<Cow<'_, PathData>> {
if let Some(outline) = &self.facet.outline {
return Some(Cow::Borrowed(outline));
}
// A piece of a stroke's face cut where it passes through another face keeps its face's
// cell, and its parts are cut to its own outline.
let cut = self.facet.surface.as_ref().is_some_and(|c| self.facet.contours.len() != 1 || self.facet.contours.first() != Some(&c.page));
cut.then(|| Cow::Owned(self.facet.path()))
}
fn rgb_light(&self) -> Option<vectorcraft_three_d::RgbGradient> {
self.facet.rgb_gradient
}
fn light(&self) -> [f64; 3] {
self.facet.illumination
}
fn outline_path(&self) -> PathData {
self.facet.path()
}
}
/// The parts of the graphics on `face` of `graphics` (the front of Revolve; Extrude & Bevel's side;
/// Inflate's front or back) that fall on each of `faces`, a surface's faces in drawing order, for
/// an object with id `id`: for each face, the nodes to draw right after it. Only faces of the
/// surface that show their outside to the viewer carry a part, so a graphic narrows toward the
/// silhouette, is hidden past it and is covered by the nearer faces drawn after it.
/// `shade` gives the paint of a solid color on a face, as the surface under it is shaded; the
/// colors of gradients and patterns are multiplied by the face's light. A graphic whose symbol
/// `doc` does not have, or that is past the limits of its art, draws nothing. `None` past
/// [`MAX_ELEMENTS`] points together before they are cut at the faces, [`MAX_SURFACE_POINTS`]
/// after, [`MAX_SURFACE_CUTS`] points cut, or when the copies of their paints in the parts take
/// `copies`, the bytes of the copies of the object's graphics so far, past Revolve's budget for
/// them: commands refuse such graphics, and a loaded file draws the surface without them.
pub(crate) fn surface_parts<F: SurfaceFace>(
doc: Option<&Document>,
id: NodeId,
@@ -1092,13 +1134,22 @@ pub(super) fn art_bounds(doc: &Document, name: &str) -> Option<Rect> {
/// Where a 3D object's graphics are drawn: the bounds its solids are built with (the graphics'
/// offsets are from their center), the maps of its front and back faces, when it has them, and
/// the visible part of its side unrolled, when it has graphics there.
/// the visible part of its side unrolled, when it has graphics there, and for Inflate the pieces of
/// its puffed faces the viewer sees.
#[derive(Clone, Debug, PartialEq)]
pub struct GraphicFrame {
pub bounds: Rect,
front: Option<FaceMap>,
back: Option<FaceMap>,
side: Option<SideFrame>,
membrane: Option<MembraneFrame>,
}
/// Does triangle `t` hold point `q`, its edges included?
fn in_triangle(t: &[Point; 3], q: Point) -> bool {
let side = |a: Point, b: Point| (b - a).cross(q - a);
let s = [side(t[0], t[1]), side(t[1], t[2]), side(t[2], t[0])];
s.iter().all(|v| *v >= -1e-9) || s.iter().all(|v| *v <= 1e-9)
}
/// The pieces of Extrude & Bevel's side that show their outside to the viewer, as the graphics are
@@ -1137,11 +1188,6 @@ impl SideFrame {
/// triangle of its corners on the same side of its diagonal from corner 0 to corner 2, grown and
/// cut to its outline as [`surface_parts`] cuts the parts. `None` when no piece holds it.
fn map(&self, p: Point, from_page: bool) -> Option<Point> {
let inside = |t: &[Point; 3], q: Point| {
let side = |a: Point, b: Point| (b - a).cross(q - a);
let s = [side(t[0], t[1]), side(t[1], t[2]), side(t[2], t[0])];
s.iter().all(|v| *v >= -1e-9) || s.iter().all(|v| *v <= 1e-9)
};
let mut best: Option<(Point, f64)> = None;
for piece in &self.pieces {
let (from, to) = if from_page { (&piece.page, &piece.uv) } else { (&piece.uv, &piece.page) };
@@ -1150,7 +1196,7 @@ impl SideFrame {
let pick = |of: &[Point]| Some([*of.get(corners[0])?, *of.get(corners[1])?, *of.get(corners[2])?]);
let (Some(a), Some(b)) = (pick(from), pick(to)) else { continue };
let window = if piece.outline.is_some() { grown(a, 3.0) } else { a };
if !inside(&window, p) {
if !in_triangle(&window, p) {
continue;
}
// A four-cornered piece's two triangles meet along its diagonal: each holds its side.
@@ -1176,9 +1222,136 @@ impl SideFrame {
}
}
/// The pieces of Inflate's front and puffed back that show their outside to the viewer, as the
/// graphics are drawn on them ([`surface_parts`]): each piece's face, its corners in the art's plane
/// (offsets from the center of the object's bounds) and on the page, its depth (larger is nearer)
/// and its plane, for its depth at a point of the page. The other facets the viewer sees (the
/// sides, and pieces that show the surface's inside) are kept as `covers`, for where they hide
/// a piece.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct MembraneFrame {
pieces: Vec<MembranePiece>,
covers: Vec<Cover>,
}
/// A facet that can hide a piece of Inflate's front or back: its contours on the page (nonzero
/// winding), its depth, its plane and its place among the solid's facets.
#[derive(Clone, Debug, PartialEq)]
struct Cover {
contours: Vec<Vec<Point>>,
depth: f64,
plane: Option<DepthPlane>,
index: usize,
}
impl Cover {
/// Does the facet hold page point `p`?
fn holds(&self, p: Point) -> bool {
let mut winding = 0i32;
for c in &self.contours {
for (a, b) in c.iter().zip(c.iter().cycle().skip(1)).take(c.len()) {
let side = (*b - *a).cross(p - *a);
if a.y <= p.y && b.y > p.y && side > 0.0 {
winding += 1;
} else if a.y > p.y && b.y <= p.y && side < 0.0 {
winding -= 1;
}
}
}
winding != 0
}
}
#[derive(Clone, Debug, PartialEq)]
struct MembranePiece {
face: PlanarFace,
uv: [Point; 3],
page: [Point; 3],
depth: f64,
plane: Option<DepthPlane>,
/// The piece's place among the solid's facets: of two facets drawn last, the later one is drawn
/// over the other.
index: usize,
}
impl MembranePiece {
/// The piece's depth at page point `p`: its plane's depth there, or its own depth when it has
/// no plane or the plane gives none.
fn depth_at(&self, p: Point) -> f64 {
self.plane.and_then(|plane| plane.depth_at(p)).unwrap_or(self.depth)
}
}
impl MembraneFrame {
/// The pieces of `facets` that carry where they lie in the art's plane and show the outside of
/// Inflate's front or back, and the other facets not turned away from the viewer as covers.
pub(super) fn of<'a>(facets: impl IntoIterator<Item = &'a Facet>) -> Self {
let (mut pieces, mut covers) = (Vec::new(), Vec::new());
for (index, f) in facets.into_iter().enumerate() {
let piece = f.membrane.zip(f.surface.as_ref().filter(|c| c.outward)).and_then(|(face, cell)| {
let uv = <[Point; 3]>::try_from(cell.uv.as_slice()).ok()?;
let page = <[Point; 3]>::try_from(cell.page.as_slice()).ok()?;
Some(MembranePiece { face, uv, page, depth: f.depth, plane: f.plane, index })
});
match piece {
Some(piece) => pieces.push(piece),
None if !f.away => covers.push(Cover { contours: f.contours.clone(), depth: f.depth, plane: f.plane, index }),
None => {}
}
}
Self { pieces, covers }
}
/// Point `p` of `face` in the art's plane mapped onto the page, or with `from_page` a page point
/// mapped into the art's plane, through the piece of that face that holds it and is nearest at
/// that point of the page. `None` when no piece the viewer sees holds it, or when another nearer
/// piece, of either face, or a nearer cover hides that point of the page.
fn map(&self, face: PlanarFace, p: Point, from_page: bool) -> Option<Point> {
let inside = in_triangle;
let mut best: Option<(Point, f64, &MembranePiece)> = None;
for piece in self.pieces.iter().filter(|piece| piece.face == face) {
let (from, to) = if from_page { (&piece.page, &piece.uv) } else { (&piece.uv, &piece.page) };
if !inside(from, p) {
continue;
}
let Some(q) = triangle_map(from, to).map(|m| m * p).filter(|q| q.is_finite()) else { continue };
let depth = piece.depth_at(if from_page { p } else { q });
// A piece drawn last is drawn over every other one, and the later of two drawn last is
// drawn over the other, whatever their planes' depths.
let over = |(_, nearest, other): (Point, f64, &MembranePiece)| match (piece.depth == f64::MAX, other.depth == f64::MAX) {
(true, true) => piece.index > other.index,
(true, false) => true,
(false, true) => false,
(false, false) => depth > nearest,
};
if best.is_none_or(over) {
best = Some((q, depth, piece));
}
}
let (q, depth, shown) = best?;
let at = if from_page { p } else { q };
// A facet drawn last (depth `f64::MAX`) is drawn over every other one, and over another
// drawn last before it. Otherwise, where the front, the back and the sides meet, they give
// the same depth there, and only a facet clearly nearer covers.
let hides = |raw: f64, there: f64, index: usize| match (raw == f64::MAX, shown.depth == f64::MAX) {
(true, true) => index > shown.index,
(true, false) => true,
(false, true) => false,
(false, false) => there > depth + 1e-6 * depth.abs().max(1.0),
};
let covered = self
.pieces
.iter()
.filter(|piece| !std::ptr::eq(*piece, shown))
.any(|piece| inside(&piece.page, at) && hides(piece.depth, piece.depth_at(at), piece.index))
|| self.covers.iter().any(|c| c.holds(at) && hides(c.depth, c.plane.and_then(|plane| plane.depth_at(at)).unwrap_or(c.depth), c.index));
(!covered).then_some(q)
}
}
impl GraphicFrame {
pub(super) fn new(bounds: Rect, front: Option<FaceMap>, back: Option<FaceMap>) -> Self {
Self { bounds, front, back, side: None }
Self { bounds, front, back, side: None, membrane: None }
}
/// The frame with the visible part of the side `side`, for its graphics' handles.
@@ -1186,6 +1359,12 @@ impl GraphicFrame {
Self { side: Some(side), ..self }
}
/// The frame of an Inflate object built about `bounds`, whose graphics are drawn on the pieces
/// of `membrane`.
pub(super) fn inflated(bounds: Rect, membrane: MembraneFrame) -> Self {
Self { bounds, front: None, back: None, side: None, membrane: Some(membrane) }
}
pub fn map(&self, face: PlanarFace) -> Option<&FaceMap> {
match face {
PlanarFace::Front => self.front.as_ref(),
@@ -1208,27 +1387,34 @@ impl GraphicFrame {
/// Where graphic `g`'s center lands on the page, and whether its face is turned toward the
/// viewer. `None` when the object has no such face or the point has no page point. A graphic on
/// the side lands where its center is on the part of the side the viewer sees, and is `None`
/// elsewhere.
/// elsewhere. On Inflate the center lands on the puffed face above it, and is `None` where the
/// viewer does not see that face.
pub fn handle(&self, g: &MappedGraphic) -> Option<(Point, bool)> {
if g.face == PlanarFace::Side {
return Some((self.side.as_ref()?.map(Point::new(g.x, g.y), false)?, true));
}
if let Some(membrane) = &self.membrane {
let uv = if g.face == PlanarFace::Back { Point::new(-g.x, g.y) } else { Point::new(g.x, g.y) };
return Some((membrane.map(g.face, uv, false)?, true));
}
let map = self.map(g.face)?;
Some((map.to_page(self.art_point(g.face, (g.x, g.y)))?, map.visible))
}
/// The offset of a graphic on `face` whose center lands on page point `page`. On the side, only
/// a point on the part of the side the viewer sees has one.
/// a point on the part of the side the viewer sees has one, and on Inflate only a point on the
/// part of the puffed face the viewer sees.
pub fn offset_at(&self, face: PlanarFace, page: Point) -> Option<(f64, f64)> {
let art = match face {
PlanarFace::Side => self.side.as_ref()?.map(page, true)?,
_ => self.map(face)?.to_art(page)?,
};
let c = self.bounds.center();
let (x, y) = match face {
PlanarFace::Front => (art.x - c.x, art.y - c.y),
PlanarFace::Back => (c.x - art.x, art.y - c.y),
PlanarFace::Side => (art.x, art.y),
let (x, y) = if face == PlanarFace::Side {
let art = self.side.as_ref()?.map(page, true)?;
(art.x, art.y)
} else if let Some(membrane) = &self.membrane {
let uv = membrane.map(face, page, true)?;
if face == PlanarFace::Back { (-uv.x, uv.y) } else { (uv.x, uv.y) }
} else {
let art = self.map(face)?.to_art(page)?;
let c = self.bounds.center();
if face == PlanarFace::Back { (c.x - art.x, art.y - c.y) } else { (art.x - c.x, art.y - c.y) }
};
(x.abs() <= MAX_OFFSET && y.abs() <= MAX_OFFSET).then_some((x, y))
}
+52
View File
@@ -587,6 +587,30 @@ fn drawn_face_bounds(f: &Node) -> Rect {
}
}
/// Under a colored light, an Inflate in a solid color with a graphic on its front lies over an
/// underlay of its faces, the faces that carry parts of the graphic included.
#[test]
fn a_colored_inflate_with_a_graphic_lies_over_an_underlay_of_its_faces() {
let mut d = Document::new(1000.0, 1000.0);
let mark = Node::path(
NodeId(0),
vectorcraft_geom::shapes::rectangle(Rect::new(500.0, 500.0, 510.0, 510.0)),
Appearance::basic(Paint::solid(BLUE), Paint::None, 0.0),
);
d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Mark".into(), art: Arc::new(mark) });
let square = vectorcraft_geom::shapes::rectangle(Rect::new(0.0, 0.0, 100.0, 100.0));
let mut n = Node::path(NodeId(7), square, Appearance::basic(Paint::solid(RED), Paint::None, 0.0));
let p = json!({"rotationX": -20, "rotationY": -30, "rotationZ": 0, "lights": [{"color": "#ff8080"}], "graphics": [{"symbol": "Mark", "scale": 300.0}]});
n.appearance.effects.push(fx(INFLATE, p));
let art = solid_art_in(Some(&d), &n).unwrap();
let order = art.children().unwrap()[0].children().unwrap();
let faces: Vec<Arc<Node>> = order.iter().flat_map(unsealed).collect();
assert!(faces.len() > order.len(), "the faces lie over an underlay");
let carrying = faces.iter().filter(|f| matches!(f.kind, NodeKind::Group { clip: false, .. })).count();
assert!(carrying > 0, "faces carry parts of the graphic");
assert!(order.iter().all(|run| !Arc::ptr_eq(&unsealed(run)[0], run)), "every face is in a sealed run");
}
/// Under a light that is not white, a solid-color fill and a solid-color stroke, plain, dashed or
/// with a width profile, draw their faces in one order, the faces of both solids in the order of
/// their depths where they overlap, in Inflate and in Extrude & Bevel, with and without perspective
@@ -775,6 +799,7 @@ fn a_stroke_face_through_a_fill_wall_is_cut_where_their_depths_meet() {
away: false,
end: None,
surface: None,
membrane: None,
plane: Some(DepthPlane { normal, offset, center: Point::ZERO, eye: None }),
cell: None,
};
@@ -1206,6 +1231,33 @@ fn a_groups_solids_together_past_the_limit_draw_the_source() {
assert_eq!(three_d_wireframe_in(None, &past), Err(vectorcraft_three_d::TOO_COMPLEX_SOLID.to_string()));
}
/// An Inflate group whose second member's fill is past the limits draws its source art, and its
/// frame places no graphic handle on the first member's puff.
#[test]
fn an_inflate_frame_places_no_handle_when_a_fill_is_past_the_limits() {
let mut b = BezPath::new();
b.move_to((0.0, 0.0));
b.line_to((40_000.0, 0.0));
b.line_to((40_000.0, 40_000.0));
b.line_to((0.0, 40_000.0));
b.close_path();
let square = Node::path(NodeId(1), PathData::from_bezpath(&b), Appearance::basic(Paint::solid(RED), Paint::None, 0.0));
let view = json!({"rotationX": 0.0, "rotationY": 0.0, "rotationZ": 0.0});
let group = |members: Vec<Node>| {
let mut g = Node::group(NodeId(9999), members.into_iter().map(Arc::new).collect());
g.appearance.effects.push(fx(INFLATE, view.clone()));
g
};
let center = MappedGraphic::from_value(&json!({"symbol": "Mark"})).unwrap();
// The square alone builds, and the graphic's handle sits on its puff.
let alone = group(vec![square.clone()]);
assert!(graphic_frame(None, &alone, None).unwrap().handle(&center).is_some());
// 70,000 corners: more points than a fill's solid takes.
let past = group(vec![square, polygon_node(2, 70_000)]);
assert!(solid_art(&past).is_none(), "the source art draws");
assert!(graphic_frame(None, &past, None).unwrap().handle(&center).is_none());
}
/// A fill and strokes whose solids each fit, but not all of them together, draw the source art,
/// and the strokes after the one past the limit are not left out to make room.
#[test]
+207 -1
View File
@@ -505,6 +505,31 @@ fn the_symbol_check_counts_what_the_view_draws() {
assert!(validate_three_d_in(Some(&dense_document(true)), &n, EXTRUDE, &flat).is_ok());
}
#[test]
fn a_wireframe_is_not_refused_for_graphics_it_does_not_draw() {
let check = |d: &Document, id: &str, mut p: Value, wire: bool| {
if wire {
p["render"] = json!({"mode": "wireframe"});
}
validate_three_d_in(Some(d), &object(id, p.clone()), id, &p)
};
// The straight 30,000-sided polygon at 1000% fits the symbol limit, but cut into pieces on
// Inflate's puffed front it is too complex.
let straight = dense_document(false);
let big = json!({"perspectiveAngle": 0.0, "graphics": [{"symbol": "Dense", "scale": 1000.0}]});
assert!(validate_symbols(&straight, &big).is_ok());
let e = check(&straight, INFLATE, big.clone(), false).unwrap_err();
assert!(e.contains("too complex"), "{e}");
// Two copies of the curved one under a perspective are past the symbol limit on Extrude & Bevel.
let curved = dense_document(true);
let two = json!({"perspectiveAngle": 60.0, "graphics": [{"symbol": "Dense"}, {"symbol": "Dense", "face": "back"}]});
let e = check(&curved, EXTRUDE, two.clone(), false).unwrap_err();
assert!(e.contains("too complex"), "{e}");
// A wireframe draws the faces' edges and no graphics, so neither is checked.
assert_eq!(check(&straight, INFLATE, big, true), Ok(()));
assert_eq!(check(&curved, EXTRUDE, two, true), Ok(()));
}
#[test]
fn a_plane_and_a_hollow_solid() {
let d = document();
@@ -548,7 +573,9 @@ fn graphics_are_checked() {
}
assert!(check(ROTATE, json!([{"symbol": "Mark", "face": "back"}])).is_err());
assert!(check(ROTATE, json!([{"symbol": "Mark", "face": "side"}])).is_err());
assert!(check(INFLATE, json!([{"symbol": "Mark"}])).is_err());
// Inflate takes graphics on its front and its puffed back, and none on a side.
assert!(check(INFLATE, json!([{"symbol": "Mark"}, {"symbol": "Mark", "face": "back"}])).is_ok());
assert!(check(INFLATE, json!([{"symbol": "Mark", "face": "side"}])).is_err());
// Revolve takes graphics on its side, named the front; Revolve (Classic) takes none.
assert!(validate_three_d_params(crate::REVOLVE, &json!({"graphics": [{"symbol": "Mark"}]})).is_ok());
assert!(validate_three_d_params(crate::REVOLVE, &json!({"graphics": [{"symbol": "Mark", "face": "back"}]})).is_err());
@@ -579,6 +606,10 @@ fn a_change_to_a_plane_drops_the_back_caps_graphics() {
// Revolve drops the side's graphics too; Extrude & Bevel keeps every face's.
assert_eq!(three_d_params_as(EXTRUDE, &p, crate::REVOLVE)["graphics"], json!([{"symbol": "Mark", "face": "front"}]));
assert_eq!(three_d_params_as(EXTRUDE, &p, EXTRUDE)["graphics"], p["graphics"]);
// Inflate keeps the front's and the back's graphics and drops the side's.
let inflated = three_d_params_as(EXTRUDE, &p, INFLATE);
assert_eq!(inflated["graphics"], json!([{"symbol": "Mark", "face": "front"}, {"symbol": "Mark", "face": "back"}]));
assert!(validate_three_d_params(INFLATE, &inflated).is_ok());
// Back to Extrude & Bevel, the front's graphic stays.
assert_eq!(three_d_params_as(ROTATE, &plane, EXTRUDE)["graphics"], plane["graphics"]);
}
@@ -981,3 +1012,178 @@ fn only_an_opaque_part_on_revolve_takes_a_seam_stroke() {
// A pattern's tile may hold transparent art, which the overlap would show.
assert!(!takes_seam(&piece(Paint::Pattern { pattern: "Dots".into(), xf: Affine::IDENTITY }, 1.0, BlendMode::Normal)));
}
/// The paths in `art` filled in a shade of red: the parts of the "Mark" graphic.
fn red_parts(art: &Node) -> Vec<PathData> {
let mut out = vec![];
art.walk(&mut |n| {
let Some(path) = n.path_data() else { return };
let red = n.appearance.items.iter().any(|i| match i {
AppearanceItem::Fill(f) => f.paint.color().is_some_and(|c| c.to_rgb()[0] > 0.3 && c.to_rgb()[1] < 0.1 && c.to_rgb()[2] < 0.1),
AppearanceItem::Stroke(_) => false,
});
if red {
out.push(path.clone());
}
});
out
}
fn reach(parts: &[PathData]) -> Rect {
parts.iter().filter_map(PathData::bounds).reduce(|a, b| a.union(b)).unwrap()
}
#[test]
fn an_inflate_graphic_lies_on_its_puffed_front_where_the_art_is() {
let d = document();
let n = object(INFLATE, json!({"graphics": [{"symbol": "Mark", "x": 20.0, "y": -10.0, "scale": 200.0}]}));
let art = solid_art_in(Some(&d), &n).unwrap();
// Straight on, the puff rises toward the viewer and the graphic is carried straight out onto it:
// a 20 × 20 square centered 20 right of and 10 above (50, 50).
let parts = red_parts(&art);
assert!(!parts.is_empty());
assert!(close(reach(&parts), Rect::new(60.0, 30.0, 80.0, 50.0)), "{:?}", reach(&parts));
// Turned, the graphic moves and foreshortens with the puff under it.
let n = object(INFLATE, json!({"rotationY": 40.0, "graphics": [{"symbol": "Mark", "scale": 200.0}]}));
let turned = reach(&red_parts(&solid_art_in(Some(&d), &n).unwrap()));
assert!(turned.width() < 20.0 - 0.5 && (turned.height() - 20.0).abs() < 2.0, "{turned:?}");
// Without the document nothing is drawn.
assert!(red_parts(&solid_art_in(None, &n).unwrap()).is_empty());
}
#[test]
fn an_inflate_back_takes_its_graphic_with_both_sides_and_twist_carries_it() {
let d = document();
let back = |extra: Value| {
let mut p = json!({"rotationY": 180.0, "graphics": [{"symbol": "Mark", "face": "back", "x": 20.0, "scale": 200.0}]});
p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone());
red_parts(&solid_art_in(Some(&d), &object(INFLATE, p)).unwrap())
};
// Without Both sides the back is flat and open, with no puffed face to carry the graphic.
assert!(back(json!({})).is_empty());
// Seen from behind, the back reads left to right: 20 to the right as seen from behind is 20 to
// the left of the art's center, which turned half a turn lies 20 right on the page.
let plain = back(json!({"bothSides": true}));
assert!(!plain.is_empty());
let r = reach(&plain);
assert!((r.center().x - 70.0).abs() < 0.5 && (r.center().y - 50.0).abs() < 0.5 && (r.width() - 20.0).abs() < 0.5, "{r:?}");
// Twist turns the back, and the graphic turns with it.
let twisted = reach(&back(json!({"bothSides": true, "twist": 45.0})));
assert!(twisted.width() > r.width() + 3.0, "{twisted:?} {r:?}");
}
#[test]
fn an_inflate_frame_puts_the_handle_on_the_puff_and_reads_it_back() {
let d = document();
let n = object(INFLATE, json!({"bothSides": true}));
let frame = graphic_frame(Some(&d), &n, None).unwrap();
let g = MappedGraphic::from_value(&json!({"symbol": "Mark", "x": 20.0, "y": -10.0})).unwrap();
let (page, shown) = frame.handle(&g).unwrap();
assert!(shown && (page.x - 70.0).abs() < 1e-6 && (page.y - 40.0).abs() < 1e-6, "{page:?}");
let (x, y) = frame.offset_at(PlanarFace::Front, page).unwrap();
assert!((x - 20.0).abs() < 1e-6 && (y + 10.0).abs() < 1e-6, "{x} {y}");
// From the front the back is out of sight: it has no handle and no offset.
let g = MappedGraphic::from_value(&json!({"symbol": "Mark", "face": "back"})).unwrap();
assert!(frame.handle(&g).is_none());
assert!(frame.offset_at(PlanarFace::Back, Point::new(50.0, 50.0)).is_none());
// Turned half a turn, the back's handle reads back its offset, as seen from behind.
let n = object(INFLATE, json!({"bothSides": true, "rotationY": 180.0}));
let frame = graphic_frame(Some(&d), &n, None).unwrap();
let g = MappedGraphic::from_value(&json!({"symbol": "Mark", "face": "back", "x": 15.0, "y": 5.0})).unwrap();
let (page, _) = frame.handle(&g).unwrap();
let (x, y) = frame.offset_at(PlanarFace::Back, page).unwrap();
assert!((x - 15.0).abs() < 1e-6 && (y - 5.0).abs() < 1e-6, "{x} {y}");
}
/// Where two pieces of an Inflate face overlap on the page, a point maps through the piece nearer
/// at that point, though the other is nearer at its center.
#[test]
fn overlapping_inflate_pieces_map_a_point_through_the_one_nearer_there() {
let page = [Point::new(0.0, 0.0), Point::new(20.0, 0.0), Point::new(10.0, 20.0)];
let piece = |shift: f64, depth: f64, normal: [f64; 3], offset: f64| MembranePiece {
face: PlanarFace::Front,
uv: page.map(|p| p + Vec2::new(shift, 0.0)),
page,
depth,
plane: Some(DepthPlane { normal, offset, center: Point::ORIGIN, eye: None }),
index: 0,
};
// The tilted piece is nearer at its center (depth 10) but at depth 0 where x is 10; the flat
// one lies at depth 5 everywhere.
let tilted = piece(0.0, 10.0, [1.0, 0.0, 1.0], 10.0);
let flat = piece(100.0, 5.0, [0.0, 0.0, 1.0], 5.0);
let frame = GraphicFrame::inflated(Rect::new(0.0, 0.0, 20.0, 20.0), MembraneFrame { pieces: vec![tilted, flat], covers: vec![] });
let (x, y) = frame.offset_at(PlanarFace::Front, Point::new(10.0, 5.0)).unwrap();
assert!((x - 110.0).abs() < 1e-6 && (y - 5.0).abs() < 1e-6, "{x} {y}");
// Near the tilted piece's left corner it is the nearer one.
let (x, _) = frame.offset_at(PlanarFace::Front, Point::new(2.0, 0.5)).unwrap();
assert!((x - 2.0).abs() < 1e-6, "{x}");
// A graphic's center has a handle only where its own piece is the nearer one, and the handle
// maps back to the same offset.
let mark = |x: f64, y: f64| MappedGraphic::from_value(&json!({"symbol": "Mark", "face": "front", "x": x, "y": y})).unwrap();
assert!(frame.handle(&mark(10.0, 5.0)).is_none());
for (x, y) in [(2.0, 0.5), (110.0, 5.0)] {
let (at, _) = frame.handle(&mark(x, y)).unwrap();
let (bx, by) = frame.offset_at(PlanarFace::Front, at).unwrap();
assert!((bx - x).abs() < 1e-6 && (by - y).abs() < 1e-6, "{x} {y}: {bx} {by}");
}
// Of two overlapping pieces drawn last, the later one is drawn over the other, though the
// earlier one's plane is nearer.
let last = |shift: f64, offset: f64, index: usize| MembranePiece { index, ..piece(shift, f64::MAX, [0.0, 0.0, 1.0], offset) };
let pieces = vec![last(0.0, 10.0, 0), last(100.0, 0.0, 1)];
let frame = GraphicFrame::inflated(Rect::new(0.0, 0.0, 20.0, 20.0), MembraneFrame { pieces, covers: vec![] });
let (x, _) = frame.offset_at(PlanarFace::Front, Point::new(10.0, 5.0)).unwrap();
assert!((x - 110.0).abs() < 1e-6, "{x}");
assert!(frame.handle(&mark(10.0, 5.0)).is_none());
assert!(frame.handle(&mark(110.0, 5.0)).is_some());
}
/// A graphic on Inflate's back has no handle where a nearer piece of the front covers its center
/// on the page, and the back has no offset there; where the back is nearer, it has both.
#[test]
fn an_inflate_back_graphic_covered_by_a_nearer_front_piece_has_no_handle() {
let page = [Point::new(0.0, 0.0), Point::new(20.0, 0.0), Point::new(10.0, 20.0)];
let piece = |face: PlanarFace, depth: f64| MembranePiece { face, uv: page, page, depth, plane: None, index: 0 };
let frame = |front: f64, back: f64| {
let pieces = vec![piece(PlanarFace::Front, front), piece(PlanarFace::Back, back)];
GraphicFrame::inflated(Rect::new(0.0, 0.0, 20.0, 20.0), MembraneFrame { pieces, covers: vec![] })
};
let g = MappedGraphic::from_value(&json!({"symbol": "Mark", "face": "back", "x": -10.0, "y": 5.0})).unwrap();
let covered = frame(10.0, 5.0);
assert!(covered.handle(&g).is_none());
assert!(covered.offset_at(PlanarFace::Back, Point::new(10.0, 5.0)).is_none());
assert!(covered.offset_at(PlanarFace::Front, Point::new(10.0, 5.0)).is_some());
let seen = frame(5.0, 10.0);
let (at, _) = seen.handle(&g).unwrap();
assert!((at.x - 10.0).abs() < 1e-6 && (at.y - 5.0).abs() < 1e-6, "{at:?}");
assert!(seen.offset_at(PlanarFace::Back, Point::new(10.0, 5.0)).is_some());
}
/// A nearer side facet that covers a graphic's center on Inflate's front hides its handle; one
/// behind the front, or beside the center, leaves it. A facet drawn last (a back cap) hides it
/// whatever its plane's depth, unless the front piece is drawn last too, after it.
#[test]
fn an_inflate_graphic_covered_by_a_nearer_side_has_no_handle() {
let page = [Point::new(0.0, 0.0), Point::new(20.0, 0.0), Point::new(10.0, 20.0)];
let front = |depth: f64, index: usize| MembranePiece { face: PlanarFace::Front, uv: page, page, depth, plane: None, index };
let side = |x0: f64, depth: f64, index: usize| Cover {
contours: vec![vec![Point::new(x0, 0.0), Point::new(x0 + 4.0, 0.0), Point::new(x0 + 4.0, 20.0), Point::new(x0, 20.0)]],
depth,
// A plane behind the front, as a back cap's is.
plane: Some(DepthPlane { normal: [0.0, 0.0, 1.0], offset: 1.0, center: Point::ORIGIN, eye: None }),
index,
};
let frame = |piece: MembranePiece, cover: Cover| {
GraphicFrame::inflated(Rect::new(0.0, 0.0, 20.0, 20.0), MembraneFrame { pieces: vec![piece], covers: vec![cover] })
};
let g = MappedGraphic::from_value(&json!({"symbol": "Mark", "face": "front", "x": 10.0, "y": 5.0})).unwrap();
let mut nearer = side(8.0, 10.0, 1);
nearer.plane = None;
assert!(frame(front(5.0, 0), nearer.clone()).handle(&g).is_none());
assert!(frame(front(5.0, 0), nearer).offset_at(PlanarFace::Front, Point::new(10.0, 5.0)).is_none());
assert!(frame(front(5.0, 0), side(8.0, 10.0, 1)).handle(&g).is_some());
assert!(frame(front(5.0, 0), side(14.0, 10.0, 1)).handle(&g).is_some());
assert!(frame(front(5.0, 0), side(8.0, f64::MAX, 1)).handle(&g).is_none());
assert!(frame(front(f64::MAX, 0), side(8.0, f64::MAX, 1)).handle(&g).is_none());
assert!(frame(front(f64::MAX, 2), side(8.0, f64::MAX, 1)).handle(&g).is_some());
}
@@ -185,6 +185,7 @@ fn a_piece_cut_from_a_face_draws_its_own_part() {
away: false,
end: None,
surface: Some(vectorcraft_three_d::SurfaceCell { page: square, uv, outward: true }),
membrane: None,
plane: Some(vectorcraft_three_d::DepthPlane { normal, offset, center: Point::ZERO, eye: None }),
cell: None,
}
@@ -207,6 +207,7 @@ fn art_on_a_facet_with_a_curved_edge_is_clipped_to_that_edge() {
end: None,
plane: None,
surface: None,
membrane: None,
cell: None,
};
let cell = MapCell { surface: 0, page: quad.clone(), uv: quad.clone() };
@@ -251,6 +252,7 @@ fn art_on_a_facet_whose_curved_edge_bows_out_covers_the_whole_facet() {
end: None,
plane: None,
surface: None,
membrane: None,
cell: None,
};
let cell = MapCell { surface: 0, page: quad.clone(), uv: quad };
@@ -290,6 +292,7 @@ fn the_bounds_tests_of_contours_away_from_a_cell_count_as_cuts() {
end: None,
plane: None,
surface: None,
membrane: None,
cell: None,
};
let cell = MapCell { surface: 0, page: quad.clone(), uv: quad };
+1 -1
View File
@@ -379,7 +379,7 @@ fn a_stroke_left_out_of_the_art_casts_no_shadow() {
let p = crate::merged_params(id, &json!({"shadow": true}));
let (parts, bounds) = solid_parts(&shapes, union_bounds(&shapes).unwrap());
let mut built: Vec<Option<SolidFaces>> =
built_solids_cast(id, &p, &parts, bounds, MAX_OBJECT_FACES, true, None).map(|r| r.unwrap().and_then(|(_, faces)| faces)).collect();
built_solids_cast(id, &p, &parts, bounds, MAX_OBJECT_FACES, true, false, None).map(|r| r.unwrap().and_then(|(_, faces)| faces)).collect();
let stroke = parts.iter().position(|(item, ..)| matches!(item, AppearanceItem::Stroke(_))).unwrap();
assert!(built.len() == 2 && built.iter().all(Option::is_some), "{id}");
let (both, _, cast) = cast_built(id, &p, &shapes, built.clone()).unwrap().unwrap();
+10 -2
View File
@@ -1,5 +1,6 @@
//! Window › 3D and Materials › Materials › Graphics: art kept as a document symbol (Add as Single
//! Graphic) and mapped onto 3D objects (Extrude & Bevel's caps, a plane, Revolve's side). The
//! Graphic) and mapped onto 3D objects (Extrude & Bevel's caps, a plane, Revolve's side, Inflate's
//! puffed front and back). The
//! graphics an object shows are the `graphics` parameter of its 3D effect, which `effect.setParams`
//! also edits.
@@ -28,7 +29,7 @@ pub(super) fn specs() -> Vec<CommandSpec> {
"Map Graphic",
[],
None,
"{symbol: name of a document symbol, face?: front|back|side (front; Plane has only a front; the back reads left to right as seen from behind; side is Extrude & Bevel's walls and bevels; on Revolve the front is its swept side, which is the only face), x?: pt, y?: pt (0, 0: the offset of the graphic's center from the center of the object's bounds, in the face's own plane; on a side from the middle of the side unrolled flat: on Extrude & Bevel x along the outline, clockwise from its top, and y from the front toward the back; on Revolve x around the axis and y along the profile), scale?: % (1..10000; default 100, or less so the graphic fits inside the object, on Extrude & Bevel's side inside the side unrolled about x = 0, short of its cut, on Revolve inside the half of the side seen from the front), rotation?: degrees (-360..360, 0; counterclockwise), index?: int (the 3D effect's position; default: each object's first 3D effect, its own before its fills' and strokes'), item?: appearance item index|null (refused without index; as effect.setParams), ids?|id?} add a graphic to the 3D effect of each selected object, drawn on that face turned, foreshortened and shaded with it and clipped to it (on a side wrapped around it, and drawn only where its outside faces the viewer); every object's 3D effect must be Extrude & Bevel (on a solid cap, or on the side, hollow or not), Rotate (the Plane type) or Revolve; one undo step → {ids, graphic}",
"{symbol: name of a document symbol, face?: front|back|side (front; Plane has only a front; the back reads left to right as seen from behind; side is Extrude & Bevel's walls and bevels; on Revolve the front is its swept side, which is the only face; on Inflate the back takes graphics only with Both sides and Cap on), x?: pt, y?: pt (0, 0: the offset of the graphic's center from the center of the object's bounds, in the face's own plane; on Inflate in the art's plane, the graphic carried straight out onto the puffed face; on a side from the middle of the side unrolled flat: on Extrude & Bevel x along the outline, clockwise from its top, and y from the front toward the back; on Revolve x around the axis and y along the profile), scale?: % (1..10000; default 100, or less so the graphic fits inside the object, on Extrude & Bevel's side inside the side unrolled about x = 0, short of its cut, on Revolve inside the half of the side seen from the front), rotation?: degrees (-360..360, 0; counterclockwise), index?: int (the 3D effect's position; default: each object's first 3D effect, its own before its fills' and strokes'), item?: appearance item index|null (refused without index; as effect.setParams), ids?|id?} add a graphic to the 3D effect of each selected object, drawn on that face turned, foreshortened and shaded with it and clipped to it (on a side wrapped around it, and on Inflate following the puff, Twist and Taper carrying the back's, each drawn only where its outside faces the viewer); every object's 3D effect must be Extrude & Bevel (on a solid cap, or on the side, hollow or not), Rotate (the Plane type), Revolve or Inflate; one undo step → {ids, graphic}",
has_doc,
map_graphic
),
@@ -134,6 +135,13 @@ fn map_graphic(s: &mut Session, p: &Value) -> Result<Value> {
if base.face != effects::PlanarFace::Front && extrude.is_some_and(|o| o.depth <= 0.0) {
return Err(bad(C, format!("object {}: with a depth of 0 the object has one face: map its graphics onto the front", id.0)));
}
// Inflate's back takes graphics where it puffs out: with Both sides and Cap on.
if base.face == effects::PlanarFace::Back && effect.id == effects::INFLATE {
let o = effects::inflate_options(&merged);
if !(o.both_sides && o.cap) {
return Err(bad(C, format!("object {}: Inflate's back takes graphics with Both sides and Cap on", id.0)));
}
}
let mut graphic = base.clone();
if p.get("scale").is_none()
&& let Some(art) = effects::graphic_bounds(d, &graphic.symbol)
@@ -95,10 +95,10 @@ fn map_graphic_puts_a_graphic_on_the_side_of_a_revolve() {
#[test]
fn map_graphic_refuses_what_cannot_take_it_and_changes_nothing() {
let (mut s, id) = setup("threeD.inflate");
let (mut s, id) = setup("threeD.classicExtrude");
let history = undo_len(&s);
let e = s.execute("threeD.mapGraphic", &json!({"symbol": "Mark", "ids": [id.0]})).unwrap_err().to_string();
assert!(e.contains("Plane, Extrude and Revolve"), "{e}");
assert!(e.contains("Plane, Extrude, Revolve and Inflate"), "{e}");
let (mut s, id) = setup("threeD.rotate");
for (p, says) in [
(json!({"symbol": "Gone"}), "no symbol named"),
@@ -188,11 +188,36 @@ fn set_params_edits_graphics_and_checks_them() {
let null = json!({"ids": [id.0], "index": 0, "item": null, "params": {"graphics": null}});
assert!(s.execute("effect.setParams", &null).is_err());
assert_eq!(graphics(&s, id), moved);
// Extrude to Plane keeps the graphics; to Inflate drops them.
// Extrude to Plane keeps the graphics, and so does Inflate.
s.execute("effect.setParams", &json!({"ids": [id.0], "index": 0, "item": null, "threeDType": "plane"})).unwrap();
assert_eq!(graphics(&s, id), moved);
s.execute("effect.setParams", &json!({"ids": [id.0], "index": 0, "item": null, "threeDType": "inflate"})).unwrap();
assert_eq!(graphics(&s, id), Value::Null);
assert_eq!(graphics(&s, id), moved);
}
#[test]
fn map_graphic_puts_a_graphic_on_an_inflate_and_its_back_only_with_both_sides() {
let (mut s, id) = setup("threeD.inflate");
let plain = {
let d = &s.doc().unwrap().doc;
vectorcraft_render::effects::solid_art_in(Some(d), d.node(id).unwrap())
};
let history = undo_len(&s);
s.execute("threeD.mapGraphic", &json!({"symbol": "Mark", "ids": [id.0]})).unwrap();
assert_eq!(graphics(&s, id), json!([{"symbol": "Mark", "face": "front", "x": 0.0, "y": 0.0, "scale": 100.0, "rotation": 0.0}]));
assert_eq!(undo_len(&s), history + 1);
let d = &s.doc().unwrap().doc;
assert_ne!(vectorcraft_render::effects::solid_art_in(Some(d), d.node(id).unwrap()), plain, "the graphic is drawn");
// The back is flat until Both sides puffs it.
let history = undo_len(&s);
let e = s.execute("threeD.mapGraphic", &json!({"symbol": "Mark", "face": "back", "ids": [id.0]})).unwrap_err().to_string();
assert!(e.contains("Both sides and Cap"), "{e}");
assert_eq!(undo_len(&s), history);
s.execute("effect.setParams", &json!({"ids": [id.0], "index": 0, "item": null, "params": {"bothSides": true, "cap": false}})).unwrap();
assert!(s.execute("threeD.mapGraphic", &json!({"symbol": "Mark", "face": "back", "ids": [id.0]})).is_err());
s.execute("effect.setParams", &json!({"ids": [id.0], "index": 0, "item": null, "params": {"cap": true}})).unwrap();
s.execute("threeD.mapGraphic", &json!({"symbol": "Mark", "face": "back", "ids": [id.0]})).unwrap();
assert_eq!(graphics(&s, id)[1]["face"], "back");
}
#[test]
+39 -6
View File
@@ -262,6 +262,12 @@ fn spend(work: &mut usize, steps: usize) -> Result<(), String> {
/// The triangles covering one face: `contours` (outlines one way round, holes the other) on the
/// plane across `normal` (its Newell normal).
pub(crate) fn triangulate(contours: &[Vec<V3>], normal: V3, work: &mut usize) -> Result<Vec<[V3; 3]>, String> {
triangulate_keeping(contours, normal, work, false)
}
/// [`triangulate`], keeping the corners that lie straight between their neighbors as triangle
/// corners when `keep_straight` is set.
fn triangulate_keeping(contours: &[Vec<V3>], normal: V3, work: &mut usize, keep_straight: bool) -> Result<Vec<[V3; 3]>, String> {
// Cut the face on the coordinate plane it is least slanted to, turned so outlines run
// counterclockwise.
let (ax, ay, az) = (normal.0.abs(), normal.1.abs(), normal.2.abs());
@@ -332,11 +338,30 @@ pub(crate) fn triangulate(contours: &[Vec<V3>], normal: V3, work: &mut usize) ->
let (hole, rest) = holes[k..].split_first().ok_or_else(too_complex)?;
ring = bridge(ring, hole, rest, work)?;
}
clip(&ring, &mut out, work)?;
clip(&ring, &mut out, work, keep_straight)?;
}
Ok(out)
}
/// The triangles covering `rings`, a flat face in the art's plane (outlines with a positive signed
/// area, holes negative), cut as a mesh's faces are: each hole bridged to the outline around it,
/// then ear clipped. Every corner of the rings that lies straight between its neighbors (a corner
/// a neighboring cell shares) stays a triangle corner. Each triangle runs the way its outline does,
/// and a triangle with no area that way round is left out. The steps add to `work`, and the cut
/// stops as soon as `work` passes `budget`. `None` when a hole crosses an outline or another hole,
/// or when `work` passes `budget`.
pub(crate) fn flat_triangles(rings: &[Vec<Point>], work: &mut usize, budget: usize) -> Option<Vec<[Point; 3]>> {
let contours: Vec<Vec<V3>> = rings.iter().map(|r| r.iter().map(|q| V3(q.x, q.y, 0.0)).collect()).collect();
// Counted up from MAX_WORK less the budget, the cut's own checks stop it at the budget.
let start = MAX_WORK - budget.min(MAX_WORK);
let mut spent = start.saturating_add(*work);
let triangles = triangulate_keeping(&contours, V3(0.0, 0.0, 1.0), &mut spent, true);
*work = spent.saturating_sub(start);
let triangles = triangles.ok()?;
let triangles = triangles.into_iter().map(|t| t.map(|v| Point::new(v.0, v.1)));
Some(triangles.filter(|[a, b, c]| (*b - *a).cross(*c - *a) > 0.0).collect())
}
/// Do segments `a`–`b` and `c`–`d` cross (touching at a shared end does not count)?
fn crosses(a: (f64, f64), b: (f64, f64), c: (f64, f64), d: (f64, f64)) -> bool {
let same = |p: (f64, f64), q: (f64, f64)| (p.0 - q.0).hypot(p.1 - q.1) < 1e-9;
@@ -401,9 +426,10 @@ fn bridge(ring: Vec<Corner>, hole: &[Corner], others: &[Vec<Corner>], work: &mut
}
/// Cut `ring` (counterclockwise, possibly joined to its holes by bridges) into triangles by ear
/// clipping. A corner in line with its neighbors goes without a triangle. If no ear is left (a
/// ring that crosses itself), the rest is cut as a fan.
fn clip(ring: &[Corner], out: &mut Vec<[V3; 3]>, work: &mut usize) -> Result<(), String> {
/// clipping. A corner in line with its neighbors goes without a triangle, unless `keep_straight`
/// is set and it lies straight between them: it then stays a corner of the triangles beside it. If
/// no ear is left (a ring that crosses itself), the rest is cut as a fan.
fn clip(ring: &[Corner], out: &mut Vec<[V3; 3]>, work: &mut usize, keep_straight: bool) -> Result<(), String> {
let n = ring.len();
if n < 3 {
return Ok(());
@@ -419,8 +445,10 @@ fn clip(ring: &[Corner], out: &mut Vec<[V3; 3]>, work: &mut usize) -> Result<(),
let turn = cross(pa, pb, pc);
let scale = (pb.x - pa.x).hypot(pb.y - pa.y) * (pc.x - pb.x).hypot(pc.y - pb.y);
let mut ear = false;
let drop = turn.abs() <= 1e-12 * scale.max(1e-300);
if !drop && turn > 0.0 {
let flat = turn.abs() <= 1e-12 * scale.max(1e-300);
let straight = keep_straight && flat && (pb.x - pa.x) * (pc.x - pb.x) + (pb.y - pa.y) * (pc.y - pb.y) > 0.0;
let drop = flat && !straight;
if !flat && turn > 0.0 {
spend(work, left)?;
ear = true;
let mut k = next[c];
@@ -430,6 +458,11 @@ fn clip(ring: &[Corner], out: &mut Vec<[V3; 3]>, work: &mut usize) -> Result<(),
ear = false;
break;
}
// A kept corner on the ear's new edge would be left off every triangle.
if keep_straight && touches((p.x, p.y), (pc.x, pc.y), (pa.x, pa.y)) {
ear = false;
break;
}
k = next[k];
}
}
+62
View File
@@ -173,6 +173,68 @@ fn a_bridge_through_another_corner_touches_it() {
assert!(!super::touches((5.0, 1.0), (0.0, 0.0), (10.0, 0.0)));
}
#[test]
fn flat_triangles_keep_corners_that_lie_along_an_edge() {
// A square with a hole, its edges carrying corners midway, as a cell shares with its finer
// neighbors: every corner is a corner of some triangle, and the triangles cover the face.
let p = |x: f64, y: f64| Point::new(x, y);
let outline = vec![p(5.0, 0.0), p(10.0, 0.0), p(10.0, 5.0), p(10.0, 10.0), p(5.0, 10.0), p(0.0, 10.0), p(0.0, 5.0), p(0.0, 0.0)];
let hole = vec![p(1.0, 4.0), p(1.0, 6.0), p(2.0, 6.0), p(2.0, 4.0)];
let mut work = 0;
let triangles = flat_triangles(&[outline.clone(), hole], &mut work, usize::MAX).unwrap();
let area = |t: &[Point; 3]| ((t[1].x - t[0].x) * (t[2].y - t[0].y) - (t[1].y - t[0].y) * (t[2].x - t[0].x)) / 2.0;
assert!(triangles.iter().all(|t| area(t) > 0.0));
assert!((triangles.iter().map(area).sum::<f64>() - 98.0).abs() < 1e-9);
for q in &outline {
assert!(triangles.iter().any(|t| t.contains(q)), "{q:?} is no triangle's corner");
}
assert!(work > 0);
}
#[test]
fn flat_triangles_keep_corners_on_the_edge_an_ear_would_cut() {
// The first ear's new edge runs along the bottom, through its two middle corners.
let p = |x: f64, y: f64| Point::new(x, y);
let outline = vec![p(0.0, 3.0), p(0.0, 0.0), p(1.0, 0.0), p(2.0, 0.0), p(3.0, 0.0)];
let mut work = 0;
let triangles = flat_triangles(std::slice::from_ref(&outline), &mut work, usize::MAX).unwrap();
let area = |t: &[Point; 3]| ((t[1].x - t[0].x) * (t[2].y - t[0].y) - (t[1].y - t[0].y) * (t[2].x - t[0].x)) / 2.0;
assert!((triangles.iter().map(area).sum::<f64>() - 4.5).abs() < 1e-9);
for q in &outline {
assert!(triangles.iter().any(|t| t.contains(q)), "{q:?} is no triangle's corner");
}
}
#[test]
fn flat_triangles_pass_over_an_ear_whose_new_edge_runs_through_a_dent() {
// The first ear's new edge, from (0, 4) to (4, 0), runs through the dent's corner at (2, 2).
let p = |x: f64, y: f64| Point::new(x, y);
let outline = vec![p(0.0, 0.0), p(4.0, 0.0), p(4.0, 4.0), p(2.0, 2.0), p(0.0, 4.0)];
let mut work = 0;
let triangles = flat_triangles(std::slice::from_ref(&outline), &mut work, usize::MAX).unwrap();
let area = |t: &[Point; 3]| ((t[1].x - t[0].x) * (t[2].y - t[0].y) - (t[1].y - t[0].y) * (t[2].x - t[0].x)) / 2.0;
assert!((triangles.iter().map(area).sum::<f64>() - 12.0).abs() < 1e-9);
for t in &triangles {
for (a, b) in [(t[0], t[1]), (t[1], t[2]), (t[2], t[0])] {
for q in &outline {
assert!(!super::touches((q.x, q.y), (a.x, a.y), (b.x, b.y)), "{q:?} lies inside the edge {a:?} to {b:?}");
}
}
}
}
#[test]
fn flat_triangles_stop_at_their_budget() {
let p = |x: f64, y: f64| Point::new(x, y);
let outline = vec![p(0.0, 0.0), p(10.0, 0.0), p(10.0, 10.0), p(0.0, 10.0)];
let hole = vec![p(1.0, 4.0), p(1.0, 6.0), p(2.0, 6.0), p(2.0, 4.0)];
let mut all = 0;
assert!(flat_triangles(&[outline.clone(), hole.clone()], &mut all, usize::MAX).is_some());
let mut work = 0;
assert!(flat_triangles(&[outline, hole], &mut work, all - 1).is_none());
assert!(work >= all, "{work} of {all}");
}
#[test]
fn a_beveled_extrusion_stays_closed() {
let mut b = BezPath::new();
+16 -4
View File
@@ -30,10 +30,10 @@ use build::{Camera, cuts, edge_distance, newell, section};
pub(crate) use build::{Face3, Keep, extrude_faces, plane_faces};
pub use build::{extrude, extrude_side_size, extrude_surfaces, plane};
pub use face_map::{FaceMap, MeshFace, extrude_face_map, extrude_mesh_face, plane_face_map, plane_mesh_face};
#[cfg(test)]
use inflate::GRID_WORK;
pub(crate) use inflate::inflate_faces;
#[cfg(test)]
use inflate::{FLAT_BUDGET, FLAT_WORK, GRID_WORK, MAX_FLAT_CORNERS, MAX_FLAT_WORK};
#[cfg(test)]
pub(crate) use inflate::{INFLATED, PUFFED, SOLVE_FIRST};
pub use inflate::{inflate, inflate_each, inflate_together};
#[cfg(test)]
@@ -354,11 +354,15 @@ pub struct Inflate {
pub taper: f64,
/// A closed back (a solid) or none, so the inflated front is a shell open behind.
pub cap: bool,
/// Graphics are mapped onto the front or the puffed back: the pieces of those faces are drawn
/// as triangles, each carrying where its corners lie in the art's plane ([`Facet::surface`]).
/// Off by default, which leaves the facets without one.
pub map_surface: bool,
}
impl Default for Inflate {
fn default() -> Self {
Self { depth: 0.0, volume: 50.0, both_sides: false, twist: 0.0, taper: 1.0, cap: true }
Self { depth: 0.0, volume: 50.0, both_sides: false, twist: 0.0, taper: 1.0, cap: true, map_surface: false }
}
}
@@ -414,8 +418,15 @@ pub struct Facet {
pub end: Option<PlanarFace>,
/// For a piece of Extrude & Bevel's side built for graphics ([`Extrude::map_surface`]): where
/// its corners lie on the side unrolled flat, for a graphic mapped onto it. x runs along the
/// outline and y from the front toward the back ([`crate::SurfaceCell`]).
/// outline and y from the front toward the back ([`crate::SurfaceCell`]). For a piece of
/// Inflate's front or puffed back built for graphics ([`Inflate::map_surface`]): where its
/// corners lie in the art's plane, as offsets from the center of the bounds the solid was built
/// with. The back's corners are where they were in the art before the twist and taper turned
/// and scaled it.
pub surface: Option<crate::SurfaceCell>,
/// The face of Inflate's solid that a facet with a [`Facet::surface`] is a piece of: its front
/// or its puffed back. `None` for every other facet, Extrude & Bevel's side included.
pub membrane: Option<PlanarFace>,
/// The face's plane in view space and the projection it was drawn with, for its depth at a
/// point of the drawing ([`Facet::depth_at`]). `None` for a face whose corners lie more than
/// 0.001 pt off one plane (a piece of a twisted wall) or reach the eye.
@@ -514,6 +525,7 @@ impl Facet {
away: false,
// Revolve's graphics are drawn from its faces, before they become facets.
surface: None,
membrane: None,
plane: face.plane,
#[cfg(test)]
view: vec![],
+1
View File
@@ -232,6 +232,7 @@ impl<'a> Builder<'a> {
away: behind,
end: None,
surface: None,
membrane: None,
plane,
cell: None,
#[cfg(test)]
+98 -13
View File
@@ -1,7 +1,7 @@
use super::build::{Builder, Built, Camera, Keep, Order, Turn, check_bounds, cuts, fit, newell, outward};
use super::membrane::{Edges, MAX_MATERIAL_SEGMENTS, Membrane, cell_triangles, clip, crossings, filled, material};
use super::rings::{MAX_SOLID_POINTS, TOO_COMPLEX_SURFACE, curve_pieces, signed_area, solid_rings};
use super::{Facet, FillRule, Inflate, MAX_FACES, MAX_SOLID_FACES, PathData, Point, Rect, V3, Vec2, View};
use super::{Facet, FillRule, Inflate, MAX_FACES, MAX_SOLID_FACES, PathData, PlanarFace, Point, Rect, V3, Vec2, View};
/// The slices the sides are cut into: more to follow a twist or taper.
fn slices(o: &Inflate) -> usize {
@@ -196,6 +196,44 @@ thread_local! {
pub(crate) static INFLATED: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
/// The grid work of the last solid this thread inflated in full, for the tests.
pub(super) static GRID_WORK: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
/// The work of cutting cells with holes for graphics in the last solid this thread inflated
/// in full, for the tests.
pub(super) static FLAT_WORK: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
/// The work the next solids of this thread may take cutting cells with holes for graphics,
/// for the tests.
pub(super) static FLAT_BUDGET: std::cell::Cell<usize> = const { std::cell::Cell::new(MAX_FLAT_WORK) };
}
/// Most work one inflated surface may take cutting the cells graphics are mapped onto that
/// [`cell_triangles`] can't take (a hole inside the cell, or a ring of more corners), all its
/// cells together ([`crate::mesh::flat_triangles`]).
pub(super) const MAX_FLAT_WORK: usize = 1 << 26;
/// Most corners the pieces of one such cell may have.
pub(super) const MAX_FLAT_CORNERS: usize = 4096;
/// The work cutting cells with holes for graphics may take.
fn flat_budget() -> usize {
#[cfg(test)]
return FLAT_BUDGET.with(std::cell::Cell::get);
#[cfg(not(test))]
MAX_FLAT_WORK
}
/// Marks the facet the builder `b` added after it held `before` facets, if it added one, as a piece
/// of `face` (Inflate's front or puffed back) whose corners lie at the art points `points`, as
/// offsets from `center` ([`Facet::surface`]). `outward` is the triangle's normal pointing out of
/// the solid: the piece shows the outside of the surface when it was neither turned around to show
/// its inside (on a shell open behind) nor kept turned away.
fn mark_surface(b: &mut Builder<'_>, before: usize, points: [Point; 3], center: Point, outward: V3, face: PlanarFace) {
if b.facets.len() <= before {
return;
}
let Some(f) = b.facets.last_mut() else { return };
let Some(page) = f.contours.first().filter(|c| c.len() == 3).cloned() else { return };
let shows = !f.away && f.normal[0] * outward.0 + f.normal[1] * outward.1 + f.normal[2] * outward.2 > 0.0;
f.surface = Some(crate::SurfaceCell { page, uv: points.iter().map(|q| Point::new(q.x - center.x, q.y - center.y)).collect(), outward: shows });
f.membrane = Some(face);
}
/// The facets of one inflated shape, for a camera that allows for a puff `reach` high (or the
@@ -241,6 +279,8 @@ fn inflated(p: Puff, bounds: Rect, o: Inflate, view: View, reach: f64, keep: Kee
};
let smooth = view.shade && view.has_colored_lights();
let camera = Camera::new(view, bounds, o.depth + 2.0 * height.max(reach));
// A graphic's offsets are from the center of the bounds the solid is built with.
let center = bounds.center();
// Without its back cap the object is a shell open behind, its inside showing.
let mut b = Builder::new(&camera, o.cap, false, keep);
let half = o.depth / 2.0;
@@ -260,6 +300,8 @@ fn inflated(p: Puff, bounds: Rect, o: Inflate, view: View, reach: f64, keep: Kee
// builds the topology of every outline ring near its cell, so a self-crossing outline cost its
// crossings again in every cell it spans. Past it, cells take their clipped pieces.
let material_left = std::cell::Cell::new(MAX_MATERIAL_SEGMENTS);
// The work of cutting cells with holes for graphics, all the cells together ([`MAX_FLAT_WORK`]).
let mut flat_work = 0usize;
// Every ring's bounds, and the crossings of the last few rows the cells' centres lie on (a
// row of cells has at most seven, at its three levels).
let ring_bounds: Vec<Option<Rect>> =
@@ -410,22 +452,63 @@ fn inflated(p: Puff, bounds: Rect, o: Inflate, view: View, reach: f64, keep: Kee
out
})
.collect();
if height > 0.0
&& smooth
&& let Some(triangles) = cell_triangles(&pieces)
{
// Smooth shading draws the pieces as triangles, and so do graphics mapped onto
// the front or back: each triangle then carries where its corners lie in the
// art's plane.
let smoothed = height > 0.0 && smooth;
let triangles = match (smoothed || o.map_surface).then(|| cell_triangles(&pieces)) {
// A cell graphics are mapped onto that the quick cut can't take (a hole
// inside it, or a ring of more corners) is cut with its holes, against one
// budget for the whole surface. Drawn whole instead, its piece would show
// no graphics.
Some(None) if o.map_surface => {
if pieces.iter().map(Vec::len).fold(0usize, usize::saturating_add) > MAX_FLAT_CORNERS {
return Err(TOO_COMPLEX_SURFACE.into());
}
let budget = flat_budget();
let holed = crate::mesh::flat_triangles(&pieces, &mut flat_work, budget);
if flat_work > budget {
return Err(TOO_COMPLEX_SURFACE.into());
}
Some(holed.ok_or_else(|| TOO_COMPLEX_SURFACE.to_string())?)
}
quick => quick.flatten(),
};
if let Some(triangles) = triangles {
let order = if flat { Order::Last } else { Order::Depth };
for points in triangles {
let front = points.map(|q| camera.place(q, half + lift(q)));
b.smooth_triangle(front, points.map(|q| camera.rotate(normal(q))), false)?;
let before = b.facets.len();
let outward = newell(&[front.to_vec()]);
if smoothed {
b.smooth_triangle(front, points.map(|q| camera.rotate(normal(q))), false)?;
} else {
b.face(vec![front.to_vec()], outward, order)?;
}
if o.map_surface {
mark_surface(&mut b, before, points, center, outward, PlanarFace::Front);
}
if o.both_sides && o.cap {
let back = points.map(|q| camera.place(back_turn.apply(q), -half - lift(q) * back_turn.scale));
let normals = points.map(|q| {
let n = normal(q);
// A uniform taper scales all three coordinates equally;
// twist turns the back normal about the shape's z-axis.
camera.rotate(V3(back_turn.cos * n.0 - back_turn.sin * n.1, back_turn.sin * n.0 + back_turn.cos * n.1, -n.2))
});
b.smooth_triangle(back, normals, true)?;
let before = b.facets.len();
let n = newell(&[back.to_vec()]);
// The back winds the same way round as the front, so its outward
// normal is reversed.
let outward = V3(-n.0, -n.1, -n.2);
if smoothed {
let normals = points.map(|q| {
let n = normal(q);
// A uniform taper scales all three coordinates equally;
// twist turns the back normal about the shape's z-axis.
camera.rotate(V3(back_turn.cos * n.0 - back_turn.sin * n.1, back_turn.sin * n.0 + back_turn.cos * n.1, -n.2))
});
b.smooth_triangle(back, normals, true)?;
} else {
b.face(vec![back.to_vec()], outward, order)?;
}
if o.map_surface {
mark_surface(&mut b, before, points, center, outward, PlanarFace::Back);
}
}
}
continue;
@@ -507,6 +590,8 @@ fn inflated(p: Puff, bounds: Rect, o: Inflate, view: View, reach: f64, keep: Kee
}
#[cfg(test)]
GRID_WORK.with(|w| w.set(edges.work()));
#[cfg(test)]
FLAT_WORK.with(|w| w.set(flat_work));
if edges.spent() {
return Err(TOO_COMPLEX_SURFACE.into());
}
+117 -1
View File
@@ -457,6 +457,122 @@ fn inflate_leaves_holes_open() {
assert!(close(area(&f), 100.0 * 100.0 - 40.0 * 40.0, 1e-3), "{}", area(&f));
}
#[test]
fn inflate_marks_where_each_piece_lies_in_the_art_for_graphics() {
let (p, r) = shape(&square(0.0, 0.0, 100.0));
let on = |o: Inflate, view: View| inflate(&p, FillRule::EvenOdd, r, Inflate { map_surface: true, ..o }, view).unwrap();
// Without the request no piece carries a surface point.
assert!(inflate(&p, FillRule::EvenOdd, r, Inflate::default(), front()).unwrap().iter().all(|f| f.surface.is_none() && f.membrane.is_none()));
// Straight on, every piece is a front triangle whose corners lie where the art does, as
// offsets from the center of the bounds, and together they cover the shape.
let f = on(Inflate::default(), front());
let marked: Vec<&Facet> = f.iter().filter(|f| f.surface.is_some()).collect();
assert!(marked.len() > 20, "{}", marked.len());
assert!(close(marked.iter().map(|f| signed_area(&f.contours[0]).abs()).sum::<f64>(), 100.0 * 100.0, 1e-3));
for f in &marked {
let s = f.surface.as_ref().unwrap();
assert_eq!(f.membrane, Some(PlanarFace::Front));
assert!(s.outward);
for (page, uv) in s.page.iter().zip(&s.uv) {
assert!(close(page.x, uv.x + 50.0, 1e-6) && close(page.y, uv.y + 50.0, 1e-6), "{page:?} {uv:?}");
}
}
// Both sides puffs a back: seen from behind its pieces show their outside, and under Twist
// they keep the untwisted art points while the pieces turn on the page.
let behind = View { rotation_y: 180.0, ..front() };
let back = |o: Inflate| {
on(o, behind)
.into_iter()
.filter(|f| f.membrane == Some(PlanarFace::Back) && f.surface.as_ref().is_some_and(|s| s.outward))
.collect::<Vec<_>>()
};
let plain = back(Inflate { both_sides: true, ..Inflate::default() });
assert!(!plain.is_empty());
let twisted = back(Inflate { both_sides: true, twist: 30.0, ..Inflate::default() });
assert!(!twisted.is_empty());
let uv_extent =
|f: &[Facet]| f.iter().flat_map(|f| f.surface.as_ref().unwrap().uv.clone()).fold(Rect::new(0.0, 0.0, 0.0, 0.0), |r, q| r.union_pt(q));
assert!(close(uv_extent(&twisted).width(), 100.0, 1e-6) && close(uv_extent(&twisted).height(), 100.0, 1e-6));
assert!(extent(&twisted).width() > extent(&plain).width() + 10.0, "{:?} {:?}", extent(&twisted), extent(&plain));
// Without Both sides there is no back to mark.
assert!(on(Inflate::default(), behind).iter().all(|f| f.membrane != Some(PlanarFace::Back)));
}
/// A square 0.3 pt across with its corner at the lattice point `(qx, qy)` of the grid of a
/// 100 pt shape, offset 0.1 pt: it lies inside one quarter cell of that grid.
fn speck(qx: f64, qy: f64) -> BezPath {
let unit = 100.0 / 48.0 / 4.0;
square(qx * unit + 0.1, qy * unit + 0.1, 0.3)
}
/// The area of the pieces marked for graphics on `face`.
fn mapped_area(f: &[Facet], face: PlanarFace) -> f64 {
f.iter().filter(|f| f.membrane == Some(face)).map(|f| signed_area(&f.contours[0]).abs()).sum()
}
/// A hole inside one cell of the surface's grid leaves that cell's piece with a hole in it:
/// graphics still map onto the rest of the cell, front and back, and the hole stays open.
#[test]
fn inflate_maps_graphics_around_a_hole_inside_one_cell() {
let mut b = square(0.0, 0.0, 100.0);
b.extend(speck(96.0, 96.0));
let (p, r) = shape(&b);
let o = Inflate { map_surface: true, both_sides: true, ..Inflate::default() };
let f = inflate(&p, FillRule::EvenOdd, r, o, front()).unwrap();
let mapped = mapped_area(&f, PlanarFace::Front);
assert!(close(mapped, 100.0 * 100.0 - 0.3 * 0.3, 1e-3), "{mapped}");
let f = inflate(&p, FillRule::EvenOdd, r, o, View { rotation_y: 180.0, ..front() }).unwrap();
let mapped = mapped_area(&f, PlanarFace::Back);
assert!(close(mapped, 100.0 * 100.0 - 0.3 * 0.3, 1e-3), "{mapped}");
}
/// The cells graphics are mapped onto that need their holes cut out share one budget for the
/// whole surface: past it the surface is refused, however little each cell takes.
#[test]
fn inflate_cuts_holed_cells_for_graphics_within_one_budget() {
let mut b = square(0.0, 0.0, 100.0);
for i in 0..8 {
for j in 0..8 {
b.extend(speck(20.0 + 20.0 * i as f64, 20.0 + 20.0 * j as f64));
}
}
let (p, r) = shape(&b);
let o = Inflate { map_surface: true, ..Inflate::default() };
let f = inflate(&p, FillRule::EvenOdd, r, o, front()).unwrap();
assert!(close(mapped_area(&f, PlanarFace::Front), 100.0 * 100.0 - 64.0 * 0.3 * 0.3, 1e-3));
let all = FLAT_WORK.with(std::cell::Cell::get);
assert!(all > 0);
// Half the work all 64 cells took is far more than any one of them takes.
FLAT_BUDGET.with(|w| w.set(all / 2));
let half = inflate(&p, FillRule::EvenOdd, r, o, front());
FLAT_BUDGET.with(|w| w.set(MAX_FLAT_WORK));
assert_eq!(half.err().as_deref(), Some(TOO_COMPLEX_SOLID));
// The art draws without graphics as before.
assert!(inflate(&p, FillRule::EvenOdd, r, Inflate::default(), front()).is_ok());
}
/// A cell graphics are mapped onto whose pieces have more corners than one cut may take refuses
/// the surface rather than drawing that cell without its graphics.
#[test]
fn inflate_refuses_graphics_on_a_cell_with_too_many_corners() {
let mut b = square(0.0, 0.0, 100.0);
let unit = 100.0 / 48.0 / 4.0;
let c = Point::new(96.5 * unit, 96.5 * unit);
let n = MAX_FLAT_CORNERS + 10;
let mut ring = BezPath::new();
for k in 0..n {
let a = -std::f64::consts::TAU * k as f64 / n as f64;
let q = (c.x + 0.2 * a.cos(), c.y + 0.2 * a.sin());
if k == 0 { ring.move_to(q) } else { ring.line_to(q) }
}
ring.close_path();
b.extend(ring);
let (p, r) = shape(&b);
let mapped = inflate(&p, FillRule::EvenOdd, r, Inflate { map_surface: true, ..Inflate::default() }, front());
assert_eq!(mapped.err().as_deref(), Some(TOO_COMPLEX_SOLID));
assert!(inflate(&p, FillRule::EvenOdd, r, Inflate::default(), front()).is_ok());
}
#[test]
fn malformed_and_degenerate_input_is_bounded() {
let (p, b) = shape(&square(0.0, 0.0, 100.0));
@@ -483,7 +599,7 @@ fn malformed_and_degenerate_input_is_bounded() {
&p,
FillRule::EvenOdd,
b,
Inflate { depth: -5.0, volume: f64::NAN, both_sides: true, twist: f64::INFINITY, taper: f64::NAN, cap: true },
Inflate { depth: -5.0, volume: f64::NAN, both_sides: true, twist: f64::INFINITY, taper: f64::NAN, cap: true, map_surface: false },
front()
)
.is_ok()
@@ -1,13 +1,14 @@
//! The 3D and Materials panel's Materials tab: the document's Graphics (its symbols) as thumbnails,
//! Add as Single Graphic, and the graphics mapped onto the selected 3D object (its planar faces,
//! Extrude & Bevel's side, or Revolve's side) with their face, position, size and turn. Picking a thumbnail maps that graphic
//! Extrude & Bevel's side, Revolve's side, or Inflate's puffed faces) with their face, position, size and turn. Picking a
//! thumbnail maps that graphic
//! onto the selected objects (`threeD.mapGraphic`); art dropped on the thumbnails becomes a graphic
//! (`threeD.addGraphic`). Editing a mapped graphic changes the effect's `graphics` parameter, which
//! the panel sends as it sends every other setting.
use egui::{Sense, Stroke, StrokeKind, vec2};
use serde_json::{Value, json};
use vectorcraft_effects::{GRAPHICS, MappedGraphic, PlanarFace, REVOLVE, ROTATE};
use vectorcraft_effects::{GRAPHICS, INFLATE, MappedGraphic, PlanarFace, REVOLVE, ROTATE};
use super::revolve::{heading, label, number};
use crate::VectorcraftApp;
@@ -105,7 +106,7 @@ pub(crate) fn controls(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog)
}
ui.add_space(10.0);
if !takes {
dim_label(ui, tl!("Graphics map onto the Plane, Extrude and Revolve object types."));
dim_label(ui, tl!("Graphics map onto the Plane, Extrude, Revolve and Inflate object types."));
return;
}
let raw = d.fields.get(GRAPHICS).cloned().unwrap_or(Value::Null);
@@ -131,15 +132,18 @@ pub(crate) fn controls(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog)
let Some(g) = list.get(index).cloned() else { return };
let mut edited = g.clone();
// A plane has one face, and Revolve's graphics go on its side. Extrude & Bevel's graphics go on
// its front or back cap, or on its side (its walls and bevels).
// its front or back cap, or on its side (its walls and bevels). Inflate's go on its puffed front
// or back.
if effect != ROTATE && effect != REVOLVE {
let faces: &[PlanarFace] = if effect == INFLATE { &[PlanarFace::Front, PlanarFace::Back] } else { &PlanarFace::ALL };
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 6.0;
label(ui, tl!("Face"));
let labels = PlanarFace::ALL.map(face_label);
let at = PlanarFace::ALL.iter().position(|f| *f == g.face).unwrap_or(0);
if let Some(k) = widgets::dropdown(ui, "three-d-graphic-face", labels[at], &labels, 120.0)
&& let Some(face) = PlanarFace::ALL.get(k)
let labels: Vec<&str> = faces.iter().map(|f| face_label(*f)).collect();
let at = faces.iter().position(|f| *f == g.face).unwrap_or(0);
let current = labels.get(at).copied().unwrap_or_default();
if let Some(k) = widgets::dropdown(ui, "three-d-graphic-face", current, &labels, 120.0)
&& let Some(face) = faces.get(k)
{
edited.face = *face;
}
+3 -1
View File
@@ -7317,8 +7317,10 @@ liquify-list-end {0}, {1} {0} i {1}
@msg `{GRAPHICS}` face must be front, back or side face de `{GRAPHICS}` ha de ser front, back o side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} de `{GRAPHICS}` ha de ser un nombre de {lo} a {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` ha de ser una matriu
@msg Graphics map onto the Plane, Extrude and Revolve object types Els gràfics s’apliquen als tipus d’objecte Pla, Extrusió i Revolució
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Els gràfics s’apliquen als tipus d’objecte Pla, Extrusió, Revolució i Infla
@msg Revolve maps graphics onto its side: map them onto the front Revoluciona aplica els gràfics al seu lateral: aplica’ls a la cara davantera
@msg Inflate maps graphics onto its front and back, not onto a side Infla aplica els gràfics a la cara davantera i a la posterior, no a un lateral
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on l’objecte {_1}: la cara posterior d’Infla només admet gràfics amb Tots dos costats i Tapa activats
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Els gràfics són massa complexos per a aquesta superfície: simplifica la il·lustració dels símbols o redueix Segments
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` admet com a màxim {MAX_GRAPHICS} gràfics
@msg A plane has one face: map its graphics onto the front Un pla té una sola cara: aplica’n els gràfics a la cara davantera
Can't render this file because it is too large.
+3 -1
View File
@@ -6907,8 +6907,10 @@ mark-style Japanese Japonské
@msg `{GRAPHICS}` face must be front, back or side face v `{GRAPHICS}` musí být front, back nebo side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} v `{GRAPHICS}` musí být číslo od {lo} do {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` musí být pole
@msg Graphics map onto the Plane, Extrude and Revolve object types Grafika se mapuje na typy objektu Rovina, Vysunutí a Rotační těleso
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Grafika se mapuje na typy objektu Rovina, Vysunutí, Rotační těleso a Nafouknutí
@msg Revolve maps graphics onto its side: map them onto the front Rotační těleso mapuje grafiku na svůj bok: umístěte ji na přední stranu
@msg Inflate maps graphics onto its front and back, not onto a side Nafouknutí mapuje grafiku na přední a zadní stranu, ne na bok
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on objekt {_1}: zadní strana Nafouknutí přijímá grafiku jen se zapnutými volbami Obě strany a Uzávěr
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Grafika je pro tento povrch příliš složitá: zjednodušte kresbu symbolů nebo snižte Segmenty
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` přijímá nejvýše {MAX_GRAPHICS} grafik
@msg A plane has one face: map its graphics onto the front Rovina má jednu stranu: umístěte její grafiku na přední stranu
Can't render this file because it is too large.
+3 -1
View File
@@ -461,8 +461,10 @@ liquify-list-end {0}, {1} {0} og {1}
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}`: face skal være front, back eller side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}`: {key} skal være et tal fra {lo} til {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` skal være et array
@msg Graphics map onto the Plane, Extrude and Revolve object types Grafik kortlægges på objekttyperne Plan, Ekstrudér og Omdrej
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Grafik kortlægges på objekttyperne Plan, Ekstrudér, Omdrej og Pust op
@msg Revolve maps graphics onto its side: map them onto the front Omdrej kortlægger grafik på siden: kortlæg den på forsiden
@msg Inflate maps graphics onto its front and back, not onto a side Pust op kortlægger grafik på forsiden og bagsiden, ikke på en side
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on objektet {_1}: bagsiden af Pust op tager kun imod grafik, når Begge sider og Kappe er slået til
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Grafikken er for kompleks til denne overflade: forenkl symbolernes grafik, eller reducér Segmenter
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` tager højst {MAX_GRAPHICS} grafikelementer
@msg A plane has one face: map its graphics onto the front Et plan har én flade: kortlæg dets grafik på forsiden
Can't render this file because it is too large.
+3 -1
View File
@@ -6474,8 +6474,10 @@ lighting Light Licht
@msg `{GRAPHICS}` face must be front, back or side face in `{GRAPHICS}` muss front, back oder side sein
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} in `{GRAPHICS}` muss eine Zahl von {lo} bis {hi} sein
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` muss ein Array sein
@msg Graphics map onto the Plane, Extrude and Revolve object types Grafiken werden auf die Objekttypen Ebene, Extrudieren und Kreiseln abgebildet
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Grafiken werden auf die Objekttypen Ebene, Extrudieren, Kreiseln und Aufblasen abgebildet
@msg Revolve maps graphics onto its side: map them onto the front Kreiseln bildet Grafiken auf seiner Mantelfläche ab: Bilden Sie sie auf der Vorderseite ab
@msg Inflate maps graphics onto its front and back, not onto a side Aufblasen bildet Grafiken auf der Vorder- und Rückseite ab, nicht auf einer Seitenfläche
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on Objekt {_1}: Die Rückseite von „Aufblasen“ nimmt Grafiken nur mit aktivierten Optionen „Beidseitig“ und „Deckflächen“ auf
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Die Grafiken sind für diese Oberfläche zu komplex: Vereinfachen Sie das Bildmaterial der Symbole oder verringern Sie Segmente
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` nimmt höchstens {MAX_GRAPHICS} Grafiken auf
@msg A plane has one face: map its graphics onto the front Eine Ebene hat nur eine Seite: Bilden Sie ihre Grafiken auf der Vorderseite ab
Can't render this file because it is too large.
+3 -1
View File
@@ -6290,8 +6290,10 @@ variable-list-end {0}, {1} {0} και {1}
@msg `{GRAPHICS}` face must be front, back or side το face του `{GRAPHICS}` πρέπει να είναι front, back ή side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} το {key} του `{GRAPHICS}` πρέπει να είναι αριθμός από {lo} έως {hi}
@msg `{GRAPHICS}` must be an array το `{GRAPHICS}` πρέπει να είναι πίνακας
@msg Graphics map onto the Plane, Extrude and Revolve object types Τα γραφικά αντιστοιχίζονται στους τύπους αντικειμένου Επίπεδο, Εξώθηση και Περιστροφή γύρω από άξονα
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Τα γραφικά αντιστοιχίζονται στους τύπους αντικειμένου Επίπεδο, Εξώθηση, Περιστροφή γύρω από άξονα και Φούσκωμα
@msg Revolve maps graphics onto its side: map them onto the front Η Περιστροφή γύρω από άξονα αντιστοιχίζει τα γραφικά στην πλευρική της επιφάνεια: αντιστοιχίστε τα στην μπροστινή όψη
@msg Inflate maps graphics onto its front and back, not onto a side Το Φούσκωμα αντιστοιχίζει τα γραφικά στην μπροστινή και την πίσω όψη, όχι σε πλευρική επιφάνεια
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on το αντικείμενο {_1}: η πίσω όψη του Φουσκώματος δέχεται γραφικά μόνο με ενεργά τα Και οι δύο πλευρές και Κλείσιμο άκρου
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Τα γραφικά είναι πολύ σύνθετα για αυτή την επιφάνεια: απλοποιήστε το σχέδιο των συμβόλων ή μειώστε τα Τμήματα
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics το `{GRAPHICS}` δέχεται το πολύ {MAX_GRAPHICS} γραφικά
@msg A plane has one face: map its graphics onto the front Ένα επίπεδο έχει μία όψη: αντιστοιχίστε τα γραφικά του στην μπροστινή όψη
Can't render this file because it is too large.
+4 -2
View File
@@ -6880,9 +6880,11 @@ mark-style Japanese Japonesas
@msg `{GRAPHICS}` face must be front, back or side face de `{GRAPHICS}` debe ser front, back o side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} de `{GRAPHICS}` debe ser un número de {lo} a {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` debe ser una matriz
@msg Graphics map onto the Plane, Extrude and Revolve object types Los gráficos se asignan a los tipos de objeto Plano, Extrusión y Revolución
Graphics map onto the Plane, Extrude and Revolve object types. Los gráficos se asignan a los tipos de objeto Plano, Extrusión y Revolución.
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Los gráficos se asignan a los tipos de objeto Plano, Extrusión, Revolución e Inflar
Graphics map onto the Plane, Extrude, Revolve and Inflate object types. Los gráficos se asignan a los tipos de objeto Plano, Extrusión, Revolución e Inflar.
@msg Revolve maps graphics onto its side: map them onto the front Revolución asigna los gráficos a su lateral: asígnelos a la cara frontal
@msg Inflate maps graphics onto its front and back, not onto a side Inflar asigna los gráficos a la cara frontal y a la posterior, no a un lateral
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on el objeto {_1}: la cara posterior de Inflar admite gráficos solo con Ambos lados y Tapa activados
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Los gráficos son demasiado complejos para esta superficie: simplifique la ilustración de los símbolos o reduzca Segmentos
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` admite como máximo {MAX_GRAPHICS} gráficos
@msg A plane has one face: map its graphics onto the front Un plano tiene una sola cara: asigne sus gráficos a la cara frontal
Can't render this file because it is too large.
+3 -1
View File
@@ -6808,8 +6808,10 @@ mark-style Japanese Japanilainen
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}`-kohteen face-arvon on oltava front, back tai side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}`-kohteen {key}-arvon on oltava luku, joka on vähintään {lo} ja enintään {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` on oltava taulukko
@msg Graphics map onto the Plane, Extrude and Revolve object types Grafiikat sijoitetaan objektityypeille Taso, Pursota ja Pyöräytä
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Grafiikat sijoitetaan objektityypeille Taso, Pursota, Pyöräytä ja Täytä ilmalla
@msg Revolve maps graphics onto its side: map them onto the front Pyöräytä sijoittaa grafiikat kylkeensä: sijoita ne etupuolelle
@msg Inflate maps graphics onto its front and back, not onto a side Täytä ilmalla sijoittaa grafiikat etu- ja takapuolelle, ei kylkeen
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on objekti {_1}: Täytä ilmalla -tehosteen takapuoli ottaa grafiikoita vain, kun Molemmat puolet ja Pääty ovat käytössä
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Grafiikat ovat liian monimutkaisia tälle pinnalle: yksinkertaista symbolien kuvitusta tai pienennä Segmentit-arvoa
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` hyväksyy enintään {MAX_GRAPHICS} grafiikkaa
@msg A plane has one face: map its graphics onto the front Tasolla on yksi puoli: sijoita sen grafiikat etupuolelle
Can't render this file because it is too large.
+3 -1
View File
@@ -6473,8 +6473,10 @@ lighting Light Lumière
@msg `{GRAPHICS}` face must be front or back face de `{GRAPHICS}` doit valoir front ou back
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} de `{GRAPHICS}` doit être un nombre de {lo} à {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` doit être un tableau
@msg Graphics map onto the Plane, Extrude and Revolve object types Les graphiques s’appliquent aux types d’objet Plan, Extrusion et Révolution
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Les graphiques s’appliquent aux types d’objet Plan, Extrusion, Révolution et Gonfler
@msg Revolve maps graphics onto its side: map them onto the front Révolution applique les graphiques sur sa face latérale : appliquez-les sur la face avant
@msg Inflate maps graphics onto its front and back, not onto a side Gonfler applique les graphiques sur la face avant et l’arrière, pas sur une face latérale
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on objet {_1} : l’arrière de Gonfler n’accepte des graphiques qu’avec Deux côtés et Fermeture activés
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Les graphiques sont trop complexes pour cette surface : simplifiez l’illustration des symboles ou réduisez Segments
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` accepte au plus {MAX_GRAPHICS} graphiques
@msg A plane has one face: map its graphics onto the front Un plan n’a qu’une face : appliquez ses graphiques sur la face avant
Can't render this file because it is too large.
+1 -1
View File
@@ -5234,7 +5234,7 @@ antiAlias Sharp શાર્પ
Align On: આના પર સંરેખિત કરો:
Delete Tab ટૅબ કાઢી નાખો
Face સપાટી
Graphics map onto the Plane, Extrude and Revolve object types. ગ્રાફિક્સને Plane, Extrude અને Revolve પ્રકારના ઑબ્જેક્ટ્સ પર મેપ કરી શકાય છે.
Graphics map onto the Plane, Extrude, Revolve and Inflate object types. ગ્રાફિક્સને Plane, Extrude, Revolve અને Inflate પ્રકારના ઑબ્જેક્ટ્સ પર મેપ કરી શકાય છે.
Justify with last line aligned center છેલ્લી લાઇન મધ્યમાં રાખીને જસ્ટિફાઇ કરો
Justify with last line aligned right છેલ્લી લાઇન જમણે રાખીને જસ્ટિફાઇ કરો
Leader: લીડર:
Can't render this file because it contains an unexpected character in line 72 and column 5.
+3 -1
View File
@@ -9222,8 +9222,10 @@ liquify-list-end {0}, {1} {0} और {1}
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}` का face, front, back या side होना चाहिए
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}` का {key}, {lo} से {hi} तक की संख्या होना चाहिए
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` एक ऐरे होना चाहिए
@msg Graphics map onto the Plane, Extrude and Revolve object types ग्राफ़िक्स समतल, एक्सट्रूड और रिवॉल्व ऑब्जेक्ट प्रकारों पर लगते हैं
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types ग्राफ़िक्स समतल, एक्सट्रूड, रिवॉल्व और फुलाएँ ऑब्जेक्ट प्रकारों पर लगते हैं
@msg Revolve maps graphics onto its side: map them onto the front रिवॉल्व ग्राफ़िक्स को अपनी बगल वाली सतह पर लगाता है: उन्हें सामने वाले फ़ेस पर लगाएँ
@msg Inflate maps graphics onto its front and back, not onto a side फुलाएँ ग्राफ़िक्स को सामने और पिछले फ़ेस पर लगाता है, बगल वाली सतह पर नहीं
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on ऑब्जेक्ट {_1}: फुलाएँ का पिछला फ़ेस ग्राफ़िक्स तभी लेता है जब दोनों तरफ़ और कैप चालू हों
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments ग्राफ़िक्स इस सतह के लिए बहुत जटिल हैं: सिंबल्स के आर्ट को सरल बनाएँ या सेगमेंट कम करें
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` अधिकतम {MAX_GRAPHICS} ग्राफ़िक्स लेता है
@msg A plane has one face: map its graphics onto the front समतल का एक ही फ़ेस होता है: उसके ग्राफ़िक्स को सामने वाले फ़ेस पर लगाएँ
Can't render this file because it is too large.
+3 -1
View File
@@ -6892,8 +6892,10 @@ variable-list-end {0}, {1} {0} és {1}
@msg `{GRAPHICS}` face must be front, back or side a `{GRAPHICS}` face értéke front, back vagy side lehet
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} a `{GRAPHICS}` {key} értéke {lo} és {hi} közötti szám lehet
@msg `{GRAPHICS}` must be an array a `{GRAPHICS}` értéke tömb kell legyen
@msg Graphics map onto the Plane, Extrude and Revolve object types A grafikák a Sík, a Kihúzás és a Forgatás tengely körül objektumtípusra kerülnek
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types A grafikák a Sík, a Kihúzás, a Forgatás tengely körül és a Felfújás objektumtípusra kerülnek
@msg Revolve maps graphics onto its side: map them onto the front A Forgatás tengely körül a grafikákat a palástjára helyezi: az elülső oldalra helyezze őket
@msg Inflate maps graphics onto its front and back, not onto a side A Felfújás a grafikákat az elülső és a hátoldalra helyezi, nem az oldalára
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on {_1} objektum: a Felfújás hátoldala csak a Mindkét oldal és a Zárólap bekapcsolásával fogad grafikát
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments A grafikák túl összetettek ehhez a felülethez: egyszerűsítse a szimbólumok rajzát, vagy csökkentse a Szakaszok értékét
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics a `{GRAPHICS}` legfeljebb {MAX_GRAPHICS} grafikát fogad
@msg A plane has one face: map its graphics onto the front A síknak egy oldala van: a grafikáit az elülső oldalra helyezze
Can't render this file because it is too large.
+3 -1
View File
@@ -344,8 +344,10 @@
@msg `{GRAPHICS}` face must be front, back or side face `{GRAPHICS}` harus front, back, atau side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} `{GRAPHICS}` harus berupa angka dari {lo} sampai {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` harus berupa larik
@msg Graphics map onto the Plane, Extrude and Revolve object types Grafis dipetakan ke jenis objek Plane, Extrude, dan Revolve
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Grafis dipetakan ke jenis objek Bidang, Ekstrusi, Revolusi, dan Gelembungkan
@msg Revolve maps graphics onto its side: map them onto the front Revolusi memetakan grafis ke sisinya: petakan ke bagian depan
@msg Inflate maps graphics onto its front and back, not onto a side Gelembungkan memetakan grafis ke bagian depan dan belakangnya, bukan ke sisi
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on objek {_1}: bagian belakang Gelembungkan hanya menerima grafis saat Kedua sisi dan Ujung diaktifkan
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Grafis terlalu rumit untuk permukaan ini: sederhanakan karya simbol atau kurangi Segmen
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` menerima paling banyak {MAX_GRAPHICS} grafis
@msg A plane has one face: map its graphics onto the front Bidang memiliki satu sisi: petakan grafisnya ke bagian depan
Can't render this file because it is too large.
+3 -1
View File
@@ -6521,8 +6521,10 @@ lighting Light Luce
@msg `{GRAPHICS}` face must be front, back or side face di `{GRAPHICS}` deve essere front, back o side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} di `{GRAPHICS}` deve essere un numero da {lo} a {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` deve essere un array
@msg Graphics map onto the Plane, Extrude and Revolve object types Le grafiche si applicano ai tipi di oggetto Piano, Estrusione e Rivoluzione
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Le grafiche si applicano ai tipi di oggetto Piano, Estrusione, Rivoluzione e Gonfia
@msg Revolve maps graphics onto its side: map them onto the front Rivoluzione applica le grafiche sul suo lato: applicatele sulla faccia anteriore
@msg Inflate maps graphics onto its front and back, not onto a side Gonfia applica le grafiche sulla faccia anteriore e sul retro, non su un lato
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on oggetto {_1}: il retro di Gonfia accetta grafiche solo con Entrambi i lati e Chiusura attivi
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Le grafiche sono troppo complesse per questa superficie: semplificate il disegno dei simboli o riducete Segmenti
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` accetta al massimo {MAX_GRAPHICS} grafiche
@msg A plane has one face: map its graphics onto the front Un piano ha una sola faccia: applicate le sue grafiche sulla faccia anteriore
Can't render this file because it is too large.
+4 -2
View File
@@ -6570,9 +6570,11 @@ lighting Light ライト
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}` の face には front、back、side のいずれかを指定してください
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}` の {key} は {lo} から {hi} までの数値にしてください
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` は配列にしてください
@msg Graphics map onto the Plane, Extrude and Revolve object types グラフィックはオブジェクトの種類が平面、押し出し、回転体のときにマッピングされます
Graphics map onto the Plane, Extrude and Revolve object types. グラフィックはオブジェクトの種類が平面、押し出し、回転体のときにマッピングされます。
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types グラフィックはオブジェクトの種類が平面、押し出し、回転体、膨張のときにマッピングされます
Graphics map onto the Plane, Extrude, Revolve and Inflate object types. グラフィックはオブジェクトの種類が平面、押し出し、回転体、膨張のときにマッピングされます。
@msg Revolve maps graphics onto its side: map them onto the front 回転体はグラフィックを側面にマッピングします。前面にマッピングしてください
@msg Inflate maps graphics onto its front and back, not onto a side 膨張はグラフィックを前面と背面にマッピングします。側面にはマッピングできません
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on オブジェクト {_1}: 「膨張」の背面にグラフィックをマッピングするには「両面」と「キャップ」をオンにしてください
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments グラフィックがこのサーフェスには複雑すぎます。シンボルのアートを単純化するか、分割数を減らしてください
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` に指定できるグラフィックは {MAX_GRAPHICS} 個までです
@msg A plane has one face: map its graphics onto the front 平面には面が 1 つしかありません。グラフィックは前面にマッピングしてください
Can't render this file because it is too large.
+3 -1
View File
@@ -8230,8 +8230,10 @@ arrowhead Feather ბუმბული
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}`-ის face უნდა იყოს front, back ან side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}`-ის {key} უნდა იყოს რიცხვი {lo}-დან {hi}-მდე
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` უნდა იყოს მასივი
@msg Graphics map onto the Plane, Extrude and Revolve object types გრაფიკა თავსდება ობიექტის ტიპებზე „სიბრტყე“, „ამოწევა“ და „ბრუნვა“
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types გრაფიკა თავსდება ობიექტის ტიპებზე „სიბრტყე“, „ამოწევა“, „ბრუნვა“ და „გაბერვა“
@msg Revolve maps graphics onto its side: map them onto the front ბრუნვა გრაფიკას თავის გვერდით ზედაპირზე ათავსებს: განათავსეთ ისინი წინა მხარეზე
@msg Inflate maps graphics onto its front and back, not onto a side გაბერვა გრაფიკას წინა და უკანა მხარეზე ათავსებს და არა გვერდით ზედაპირზე
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on ობიექტი {_1}: გაბერვის უკანა მხარე გრაფიკას იღებს მხოლოდ ჩართული „ორივე მხარე“ და „თავსახური“ პარამეტრებით
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments გრაფიკა ზედმეტად რთულია ამ ზედაპირისთვის: გაამარტივეთ სიმბოლოების ნახატი ან შეამცირეთ სეგმენტები
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` იღებს მაქსიმუმ {MAX_GRAPHICS} გრაფიკას
@msg A plane has one face: map its graphics onto the front სიბრტყეს ერთი მხარე აქვს: მისი გრაფიკა წინა მხარეზე განათავსეთ
Can't render this file because it is too large.
+3 -1
View File
@@ -6491,8 +6491,10 @@ lighting Light 광원
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}`의 face는 front, back 또는 side여야 합니다
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}`의 {key}은(는) {lo}에서 {hi} 사이의 숫자여야 합니다
@msg `{GRAPHICS}` must be an array `{GRAPHICS}`은(는) 배열이어야 합니다
@msg Graphics map onto the Plane, Extrude and Revolve object types 그래픽은 평면, 돌출, 회전체 개체 유형에 매핑됩니다
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types 그래픽은 평면, 돌출, 회전체, 부풀리기 개체 유형에 매핑됩니다
@msg Revolve maps graphics onto its side: map them onto the front 회전체는 그래픽을 옆면에 매핑합니다. 앞면에 매핑하십시오
@msg Inflate maps graphics onto its front and back, not onto a side 부풀리기는 그래픽을 앞면과 뒷면에 매핑하며 옆면에는 매핑하지 않습니다
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on 개체 {_1}: 부풀리기의 뒷면에 그래픽을 매핑하려면 양면과 캡을 켜세요
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments 그래픽이 이 표면에 비해 너무 복잡합니다. 심볼의 아트를 단순화하거나 세그먼트를 줄이십시오
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}`에는 그래픽을 최대 {MAX_GRAPHICS}개까지 넣을 수 있습니다
@msg A plane has one face: map its graphics onto the front 평면에는 면이 하나뿐입니다. 그래픽을 앞면에 매핑하십시오
Can't render this file because it is too large.
+3 -1
View File
@@ -8656,8 +8656,10 @@ mark-style Japanese Japans
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} in `{GRAPHICS}` moet een getal van {lo} tot {hi} zijn
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` moet een array zijn
@msg Graphics map onto planar faces: use the Extrude or Plane object type Illustraties worden op platte vlakken geplaatst: gebruik het objecttype Extruderen of Vlak
@msg Graphics map onto the Plane, Extrude and Revolve object types Illustraties worden op de objecttypen Vlak, Extruderen en Draaien geplaatst
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Illustraties worden op de objecttypen Vlak, Extruderen, Draaien en Opblazen geplaatst
@msg Revolve maps graphics onto its side: map them onto the front Draaien plaatst illustraties op de zijkant: plaats ze op de voorkant
@msg Inflate maps graphics onto its front and back, not onto a side Opblazen plaatst illustraties op de voorkant en de achterkant, niet op een zijkant
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on object {_1}: de achterkant van Opblazen neemt alleen afbeeldingen aan met Beide zijden en Dop ingeschakeld
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments De illustraties zijn te complex voor dit oppervlak: vereenvoudig de illustraties van de symbolen of verlaag Segmenten
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` neemt maximaal {MAX_GRAPHICS} illustraties op
@msg A plane has one face: map its graphics onto the front Een vlak heeft één zijde: plaats de illustraties ervan op de voorkant
Can't render this file because it is too large.
+3 -1
View File
@@ -6733,8 +6733,10 @@ mark-style Japanese Japońskie
@msg `{GRAPHICS}` face must be front, back or side face w `{GRAPHICS}` musi mieć wartość front, back lub side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} w `{GRAPHICS}` musi być liczbą od {lo} do {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` musi być tablicą
@msg Graphics map onto the Plane, Extrude and Revolve object types Grafiki są nakładane na obiekty typu Płaszczyzna, Wyciągnięcie i Obrót
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Grafiki są nakładane na obiekty typu Płaszczyzna, Wyciągnięcie, Obrót i Nadmuchanie
@msg Revolve maps graphics onto its side: map them onto the front Obrót nakłada grafiki na swoją powierzchnię boczną: umieść je na przedniej stronie
@msg Inflate maps graphics onto its front and back, not onto a side Nadmuchanie nakłada grafiki na przednią i tylną stronę, a nie na powierzchnię boczną
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on obiekt {_1}: tył Nadmuchania przyjmuje grafiki tylko przy włączonych opcjach Obie strony i Zakończenie
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Grafiki są zbyt złożone dla tej powierzchni: uprość kompozycje symboli lub zmniejsz Segmenty
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` przyjmuje najwyżej {MAX_GRAPHICS} grafik
@msg A plane has one face: map its graphics onto the front Płaszczyzna ma jedną stronę: umieść jej grafiki na przedniej stronie
Can't render this file because it is too large.
+3 -1
View File
@@ -6855,8 +6855,10 @@ mark-style Japanese Japonesas
@msg `{GRAPHICS}` face must be front, back or side face de `{GRAPHICS}` deve ser front, back ou side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} de `{GRAPHICS}` deve ser um número de {lo} a {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` deve ser uma matriz
@msg Graphics map onto the Plane, Extrude and Revolve object types Os gráficos são mapeados nos tipos de objeto Plano, Extrusão e Revolver
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Os gráficos são mapeados nos tipos de objeto Plano, Extrusão, Revolver e Inflar
@msg Revolve maps graphics onto its side: map them onto the front Revolver mapeia os gráficos na sua lateral: mapeie-os na face frontal
@msg Inflate maps graphics onto its front and back, not onto a side Inflar mapeia os gráficos na face frontal e no verso, não em uma lateral
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on objeto {_1}: o verso de Inflar recebe gráficos apenas com Ambos os Lados e Tampa ativados
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Os gráficos são complexos demais para esta superfície: simplifique a arte dos símbolos ou reduza Segmentos
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` aceita no máximo {MAX_GRAPHICS} gráficos
@msg A plane has one face: map its graphics onto the front Um plano tem uma única face: mapeie seus gráficos na face frontal
Can't render this file because it is too large.
+3 -1
View File
@@ -6518,8 +6518,10 @@ lighting Light Свет
@msg `{GRAPHICS}` face must be front, back or side face в `{GRAPHICS}` должен быть front, back или side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} в `{GRAPHICS}` должен быть числом от {lo} до {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` должен быть массивом
@msg Graphics map onto the Plane, Extrude and Revolve object types Графика наносится на объекты типов «Плоскость», «Выдавливание» и «Вращение»
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Графика наносится на объекты типов «Плоскость», «Выдавливание», «Вращение» и «Надувание»
@msg Revolve maps graphics onto its side: map them onto the front «Вращение» наносит графику на свою боковую поверхность: размещайте её на передней стороне
@msg Inflate maps graphics onto its front and back, not onto a side «Надувание» наносит графику на переднюю и заднюю стороны, а не на боковую поверхность
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on объект {_1}: задняя сторона «Надувания» принимает графику только при включённых параметрах «С обеих сторон» и «Торцы»
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Графика слишком сложна для этой поверхности: упростите иллюстрации символов или уменьшите «Сегменты»
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` принимает не более {MAX_GRAPHICS} графических элементов
@msg A plane has one face: map its graphics onto the front У плоскости одна сторона: размещайте её графику на передней стороне
Can't render this file because it is too large.
+4 -2
View File
@@ -6385,9 +6385,11 @@ lighting Light Ljus
@msg `{GRAPHICS}` face must be front, back or side face i `{GRAPHICS}` måste vara front, back eller side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} i `{GRAPHICS}` måste vara ett tal från {lo} till {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` måste vara en matris
@msg Graphics map onto the Plane, Extrude and Revolve object types Grafik placeras på objekttyperna Plan, Extrudera och Rotera runt axel
Graphics map onto the Plane, Extrude and Revolve object types. Grafik placeras på objekttyperna Plan, Extrudera och Rotera runt axel.
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Grafik placeras på objekttyperna Plan, Extrudera, Rotera runt axel och Blås upp
Graphics map onto the Plane, Extrude, Revolve and Inflate object types. Grafik placeras på objekttyperna Plan, Extrudera, Rotera runt axel och Blås upp.
@msg Revolve maps graphics onto its side: map them onto the front Rotera runt axel placerar grafik på sin mantelyta: placera den på framsidan
@msg Inflate maps graphics onto its front and back, not onto a side Blås upp placerar grafik på framsidan och baksidan, inte på en sida
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on objekt {_1}: baksidan av Blås upp tar emot grafik bara när Båda sidor och Lock är på
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Grafiken är för komplex för den här ytan: förenkla symbolernas teckning eller minska Segment
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` tar högst {MAX_GRAPHICS} grafiker
@msg A plane has one face: map its graphics onto the front Ett plan har en sida: placera dess grafik på framsidan
Can't render this file because it is too large.
+26 -1
View File
@@ -438,7 +438,10 @@ fn swedish_svg_filter_spelling_and_3d_labels_are_complete() {
("Apply SVG Filter", "Använd SVG-filter"),
("Check Spelling", "Kontrollera stavning"),
("SVG Filter", "SVG-filter"),
("Graphics map onto the Plane, Extrude and Revolve object types.", "Grafik placeras på objekttyperna Plan, Extrudera och Rotera runt axel."),
(
"Graphics map onto the Plane, Extrude, Revolve and Inflate object types.",
"Grafik placeras på objekttyperna Plan, Extrudera, Rotera runt axel och Blås upp.",
),
] {
assert_eq!(sv.catalog().plain(en), Some(want), "{en}");
}
@@ -4140,6 +4143,28 @@ fn three_d_refusals_translate_with_their_values() {
assert_eq!(message(de(), &errors[1].0), "ungültige Parameter für `effect.apply`: Licht: intensity muss eine Zahl von 0 bis 100 sein");
}
/// Map Graphic's refusal of Inflate's back while Both sides or Cap is off shows in every
/// complete-message language, with the object's number as given.
#[test]
fn inflate_back_refusal_translates_in_every_complete_catalog() {
use serde_json::json;
let mut s = vectorcraft_engine::Session::new();
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
let mark = s.execute("path.create", &json!({"d": "M300 300L310 300L310 320L300 320Z"})).unwrap()["id"].clone();
s.execute("threeD.addGraphic", &json!({"name": "Mark", "ids": [mark]})).unwrap();
let id = s.execute("path.create", &json!({"d": "M100 100L200 100L200 200L100 200Z"})).unwrap()["id"].as_u64().unwrap();
s.execute("effect.apply", &json!({"effect": "threeD.inflate", "item": null, "params": {}})).unwrap();
let e = s.execute("threeD.mapGraphic", &json!({"symbol": "Mark", "face": "back", "ids": [id]})).unwrap_err().to_string();
let english = "Inflate's back takes graphics with Both sides and Cap on";
assert!(e.ends_with(&format!("object {id}: {english}")), "{e}");
assert_eq!(message(Lang::EN, &e), e);
for code in COMPLETE_MESSAGES {
let lang = Lang::from_code(code).expect("registered");
let shown = message(lang, &e);
assert!(!shown.contains(english) && shown.contains(&id.to_string()) && shown.contains("`threeD.mapGraphic`"), "{code}: {e} -> {shown}");
}
}
/// The Blob Brush's range refusals (`path.blob` `angle`, `roundness` and `fidelity`) show in every
/// complete-message language with the key and the range numbers as given; the error the command
/// returns stays English.
+3 -1
View File
@@ -6211,8 +6211,10 @@ lighting Light Işık
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}` face değeri front, back veya side olmalıdır
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}` {key} değeri {lo} ile {hi} arasında bir sayı olmalıdır
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` bir dizi olmalıdır
@msg Graphics map onto the Plane, Extrude and Revolve object types Grafikler Düzlem, Ekstrüzyon ve Eksen Etrafında Döndür nesne türlerine eşlenir
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Grafikler Düzlem, Ekstrüzyon, Eksen Etrafında Döndür ve Şişir nesne türlerine eşlenir
@msg Revolve maps graphics onto its side: map them onto the front Eksen Etrafında Döndür grafikleri yan yüzeyine eşler: onları ön yüze eşle
@msg Inflate maps graphics onto its front and back, not onto a side Şişir grafikleri ön ve arka yüze eşler, yan yüze eşlemez
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on nesne {_1}: Şişir efektinin arka yüzü yalnızca Her iki taraf ve Kapak açıkken grafik alır
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Grafikler bu yüzey için çok karmaşık: sembollerin resmini basitleştir veya Segmentler değerini azalt
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` en fazla {MAX_GRAPHICS} grafik alır
@msg A plane has one face: map its graphics onto the front Bir düzlemin tek yüzü vardır: grafiklerini ön yüze eşle
Can't render this file because it is too large.
+3 -1
View File
@@ -6501,8 +6501,10 @@ lighting Light Світло
@msg `{GRAPHICS}` face must be front, back or side face у `{GRAPHICS}` має бути front, back або side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} у `{GRAPHICS}` має бути числом від {lo} до {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` має бути масивом
@msg Graphics map onto the Plane, Extrude and Revolve object types Графіка наноситься на об’єкти типів «Площина», «Видавлювання» та «Обертання»
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Графіка наноситься на об’єкти типів «Площина», «Видавлювання», «Обертання» та «Надування»
@msg Revolve maps graphics onto its side: map them onto the front «Обертання» наносить графіку на свою бічну поверхню: розміщуйте її на передній стороні
@msg Inflate maps graphics onto its front and back, not onto a side «Надування» наносить графіку на передній і задній боки, а не на бічну поверхню
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on об’єкт {_1}: задній бік «Надування» приймає графіку лише з увімкненими параметрами «З обох боків» і «Торці»
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Графіка надто складна для цієї поверхні: спростіть ілюстрації символів або зменште «Сегменти»
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` приймає не більше {MAX_GRAPHICS} графічних елементів
@msg A plane has one face: map its graphics onto the front Площина має одну сторону: розміщуйте її графіку на передній стороні
Can't render this file because it is too large.
+3 -1
View File
@@ -6253,8 +6253,10 @@ liquify-list-end {0}, {1} {0} và {1}
@msg `{GRAPHICS}` face must be front, back or side face của `{GRAPHICS}` phải là front, back hoặc side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} {key} của `{GRAPHICS}` phải là số từ {lo} đến {hi}
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` phải là một mảng
@msg Graphics map onto the Plane, Extrude and Revolve object types Đồ họa được đặt lên các loại đối tượng Mặt phẳng, Kéo dài và Xoay tròn
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types Đồ họa được đặt lên các loại đối tượng Mặt phẳng, Kéo dài, Xoay tròn và Phình
@msg Revolve maps graphics onto its side: map them onto the front Xoay tròn đặt đồ họa lên mặt bên của nó: hãy đặt chúng lên mặt trước
@msg Inflate maps graphics onto its front and back, not onto a side Phình đặt đồ họa lên mặt trước và mặt sau, không đặt lên mặt bên
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on đối tượng {_1}: mặt sau của Phình chỉ nhận đồ họa khi bật Cả hai mặt và Nắp
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments Đồ họa quá phức tạp cho bề mặt này: hãy đơn giản hóa hình vẽ của các ký hiệu hoặc giảm Đoạn
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` nhận tối đa {MAX_GRAPHICS} đồ họa
@msg A plane has one face: map its graphics onto the front Mặt phẳng chỉ có một mặt: hãy đặt đồ họa của nó lên mặt trước
Can't render this file because it is too large.
+4 -2
View File
@@ -6770,9 +6770,11 @@ lighting Light 光源
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}` 的 face 必须是 front、back 或 side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}` 的 {key} 必须是 {lo} 到 {hi} 之间的数字
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` 必须是数组
@msg Graphics map onto the Plane, Extrude and Revolve object types 图形映射到平面、突出和回转对象类型上
Graphics map onto the Plane, Extrude and Revolve object types. 图形映射到平面、突出和回转对象类型上。
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types 图形映射到平面、突出、回转和膨胀对象类型上
Graphics map onto the Plane, Extrude, Revolve and Inflate object types. 图形映射到平面、突出、回转和膨胀对象类型上。
@msg Revolve maps graphics onto its side: map them onto the front 回转将图形映射到其侧面:请将图形映射到正面
@msg Inflate maps graphics onto its front and back, not onto a side 膨胀将图形映射到正面和背面,不映射到侧面
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on 对象 {_1}:只有打开“双面”和“封口”后,膨胀的背面才能贴图
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments 图形对此表面过于复杂:请简化符号的图稿或减少分段数
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` 最多接受 {MAX_GRAPHICS} 个图形
@msg A plane has one face: map its graphics onto the front 平面只有一个面:请将其图形映射到正面
Can't render this file because it is too large.
+4 -2
View File
@@ -6619,9 +6619,11 @@ lighting Light 光源
@msg `{GRAPHICS}` face must be front, back or side `{GRAPHICS}` 的 face 必須是 front、back 或 side
@msg `{GRAPHICS}` {key} must be a number from {lo} to {hi} `{GRAPHICS}` 的 {key} 必須是介於 {lo} 到 {hi} 之間的數字
@msg `{GRAPHICS}` must be an array `{GRAPHICS}` 必須是陣列
@msg Graphics map onto the Plane, Extrude and Revolve object types 圖形會對應到「平面」、「突出」與「迴轉」物件類型
Graphics map onto the Plane, Extrude and Revolve object types. 圖形會對應到「平面」、「突出」與「迴轉」物件類型。
@msg Graphics map onto the Plane, Extrude, Revolve and Inflate object types 圖形會對應到「平面」、「突出」、「迴轉」與「膨脹」物件類型
Graphics map onto the Plane, Extrude, Revolve and Inflate object types. 圖形會對應到「平面」、「突出」、「迴轉」與「膨脹」物件類型。
@msg Revolve maps graphics onto its side: map them onto the front 迴轉會將圖形對應到其側面:請將圖形對應到正面
@msg Inflate maps graphics onto its front and back, not onto a side 膨脹會將圖形對應到正面和背面,不會對應到側面
@msg object {_1}: Inflate's back takes graphics with Both sides and Cap on 物件 {_1}:只有開啟「雙面」和「封口」後,膨脹的背面才能對應圖形
@msg The graphics are too complex for this surface: simplify the symbols' art or reduce Segments 圖形對此表面過於複雜:請簡化符號的圖稿或減少分段數
@msg `{GRAPHICS}` takes at most {MAX_GRAPHICS} graphics `{GRAPHICS}` 最多接受 {MAX_GRAPHICS} 個圖形
@msg A plane has one face: map its graphics onto the front 平面只有一個面:請將其圖形對應到正面
Can't render this file because it is too large.
+37 -2
View File
@@ -645,12 +645,16 @@ fn the_materials_tab_lists_the_graphics_and_maps_one_in_one_undo_step() {
let nodes = controls(&mut app, &ctx);
named(&nodes, "Remove Graphic");
named(&nodes, "Scale");
// Inflate takes no graphics.
// Inflate keeps the graphic and lists it with its face and settings.
set_type(&mut app, "inflate").unwrap();
assert_eq!(graphics(&app).as_array().map(Vec::len), Some(1));
let nodes = controls(&mut app, &ctx);
named(&nodes, "Remove Graphic");
named(&nodes, "Scale");
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| show(&mut app, ui));
out.textures_delta.clear();
let text = crate::tests_labels::shapes_text(&out);
assert!(text.contains("Graphics map onto the Plane, Extrude and Revolve object types"), "{text}");
assert!(text.contains("Face") && !text.contains("Graphics map onto"), "{text}");
}
#[test]
@@ -742,6 +746,8 @@ fn a_graphics_handle_drags_it_over_its_face_in_one_undo_step() {
let n = std::sync::Arc::make_mut(&mut st.doc).node_mut(id).unwrap();
n.appearance.effects[0].visible = false;
n.appearance.effects.push(vectorcraft_effects::new_effect("threeD.extrude", &json!({})).unwrap());
// An edit moves the revision, as a command's does.
st.revision += 1;
}
let mut shown = true;
ctx.run_ui(egui::RawInput::default(), |ui| {
@@ -757,6 +763,35 @@ fn a_graphics_handle_drags_it_over_its_face_in_one_undo_step() {
assert!(!frame(&mut app, vec![button(target, true)]));
}
/// The frame the graphics' handles are placed on is built once for each revision of the document,
/// and not at all for an object without graphics.
#[test]
fn the_graphics_frame_is_built_once_for_each_revision() {
type Cached = (super::FrameKey, Option<std::sync::Arc<vectorcraft_effects::GraphicFrame>>);
let (mut app, ctx) = materials_app();
let cached = |ctx: &egui::Context| ctx.data(|m| m.get_temp::<Cached>(super::frame_cache_id())).and_then(|(_, frame)| frame);
let handles = |app: &VectorcraftApp| {
let mut shown = false;
ctx.run_ui(egui::RawInput::default(), |ui| {
crate::panels::set_pstate(ui.ctx(), super::DRAWN, Some(super::root_pass(ui.ctx())));
shown = super::graphic_handles(app, ui.ctx()).is_some();
})
.textures_delta
.clear();
shown
};
assert!(!handles(&app));
assert!(cached(&ctx).is_none(), "no graphics, no frame");
app.run("threeD.mapGraphic", json!({"symbol": "Graphic"})).unwrap();
assert!(handles(&app));
let first = cached(&ctx).unwrap();
assert!(handles(&app));
assert!(std::sync::Arc::ptr_eq(&first, &cached(&ctx).unwrap()), "the same revision reuses the frame");
app.run("threeD.mapGraphic", json!({"symbol": "Graphic"})).unwrap();
assert!(handles(&app));
assert!(!std::sync::Arc::ptr_eq(&first, &cached(&ctx).unwrap()), "an edit builds it again");
}
/// One frame of the artboard's graphic handles over an 800 × 600 canvas with `events`: whether the
/// handles took the pointer.
fn handles_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> bool {
+28 -3
View File
@@ -8,6 +8,8 @@
//! adds the selected objects that have a 3D effect to Asset Export as 3D assets (`assets.add3D`)
//! and shows that panel with their assets selected.
use std::sync::Arc;
use egui::Ui;
use serde_json::{Map, Value, json};
use vectorcraft_doc::{Effect, Node, NodeId, NodeKind};
@@ -425,7 +427,7 @@ fn materials_open(ctx: &egui::Context) -> bool {
/// What [`graphic_handles`] gives: the object's frame, its graphics, and each seen graphic's index
/// and page point.
type Handles = (vectorcraft_effects::GraphicFrame, Vec<vectorcraft_effects::MappedGraphic>, Vec<(usize, vectorcraft_geom::Point)>);
type Handles = (Arc<vectorcraft_effects::GraphicFrame>, Vec<vectorcraft_effects::MappedGraphic>, Vec<(usize, vectorcraft_geom::Point)>);
/// The handles of the graphics mapped onto the first selected object, while the Materials tab is
/// open: each graphic's index, its face and where its center lands on the page, for the graphics
@@ -443,8 +445,6 @@ fn graphic_handles(app: &VectorcraftApp, ctx: &egui::Context) -> Option<Handles>
if t.item.is_some_and(|k| n.appearance.items.get(k).is_none_or(|it| !it.visible())) {
return None;
}
// The frame of the effect whose graphics are listed: none while that effect is hidden.
let frame = vectorcraft_effects::graphic_frame_at(Some(&st.doc), n, t.item, t.index)?;
// A geometry effect after the 3D effect of any selected object moves or bends its drawn
// graphics away from their places in the frame: no handles, so a drag does not put a graphic
// away from the pointer.
@@ -453,15 +453,40 @@ fn graphic_handles(app: &VectorcraftApp, ctx: &egui::Context) -> Option<Handles>
return None;
}
let list = vectorcraft_effects::mapped_graphics(&vectorcraft_effects::merged_params(&t.effect, &t.params));
// Without graphics there are no handles, and no frame is built.
if list.is_empty() {
return None;
}
// Selected objects with different graphics show no handles: a drag sends the whole list.
let graphics_of = |t: Target| vectorcraft_effects::mapped_graphics(&vectorcraft_effects::merged_params(&t.effect, &t.params));
if st.selection.objects.iter().skip(1).filter_map(|id| find(st.doc.node(*id)?)).any(|o| graphics_of(o) != list) {
return None;
}
// The frame of the effect whose graphics are listed: none while that effect is hidden. It is
// built once for each revision of the document, not on every frame the panel draws.
let key: FrameKey = (st.uid, st.revision, n.id.0, t.item, t.index);
let cached = ctx.data(|m| m.get_temp::<(FrameKey, Option<Arc<vectorcraft_effects::GraphicFrame>>)>(frame_cache_id()));
let frame = match cached {
Some((k, frame)) if k == key => frame,
_ => {
let frame = vectorcraft_effects::graphic_frame_at(Some(&st.doc), n, t.item, t.index).map(Arc::new);
ctx.data_mut(|m| m.insert_temp(frame_cache_id(), (key, frame.clone())));
frame
}
}?;
let handles = list.iter().enumerate().filter_map(|(i, g)| frame.handle(g).filter(|(_, seen)| *seen).map(|(p, _)| (i, p))).collect();
Some((frame, list, handles))
}
/// What the cached frame of [`graphic_handles`] was built for: the document's uid and revision, the
/// object's id, and the fill or stroke and index of its 3D effect.
type FrameKey = (u64, u64, u64, Option<usize>, usize);
/// Temp-memory key of the frame [`graphic_handles`] last built.
fn frame_cache_id() -> egui::Id {
egui::Id::unique("three-d-graphic-frame")
}
/// Temp-memory key of a drag of a graphic's handle on the artboard.
fn handle_drag_id() -> egui::Id {
egui::Id::unique("three-d-graphic-handle-drag")
+10 -6
View File
@@ -5167,7 +5167,8 @@ joins the edges, so with such an effect its paths can differ from the drawn ones
draw the edges, and `effect.expandAppearance` keeps them as paths. Past 1,000,000 edges the source path is drawn, as
it is for a solid past its limits. A `render` that is not an object, a key other than `mode`, another mode, and
`render` on Extrude & Bevel (Classic), Revolve (Classic) or Rotate (Classic) are refused before the document
changes. See [three-d.md](three-d.md#3d-and-materials-panel).
changes. In wireframe mode the graphics' art is not checked against the graphics limits, so art too complex for the
shaded surface does not refuse the wireframe. See [three-d.md](three-d.md#3d-and-materials-panel).
```json
{"name":"run_command","arguments":{"command":"effect.setParams","params":{"index":0,"item":null,"params":{"render":{"mode":"wireframe"}}}}}
@@ -5200,19 +5201,22 @@ offset in points of the graphic's center from the center of the object's bounds
percentage of the symbol's size (1..10000; omitted, 100 or less so the graphic fits inside the object) and
`rotation` is in degrees counterclockwise (-360..360). Without `index` each object's first 3D effect takes it, and `item` is refused.
Every object's 3D effect must be Extrude & Bevel (front only at a depth of 0; `front` and `back` need Cap on, and
`side`, its walls and bevels, does not), Rotate (the Plane type, front only) or Revolve (front only: its swept
side), and `symbol` must name a document symbol; otherwise the command is refused and nothing changes. It returns `{ids, graphic}`.
`side`, its walls and bevels, does not), Rotate (the Plane type, front only), Revolve (front only: its swept
side) or Inflate (`front` or `back`, and `back` only with Both sides and Cap on), and `symbol` must name a document symbol; otherwise the command is refused and nothing changes. It returns `{ids, graphic}`.
On Revolve and on Extrude & Bevel's side, `x` and `y` are measured on the side unrolled flat from its middle (on
Extrude & Bevel, `x` along the outline, clockwise from its top, and `y` from the front toward the back), and a
graphic that does not fit starts scaled to fit the part of Extrude & Bevel's side unrolled about `x` = 0 that does
not reach its cut, or the half of Revolve's side seen from the front ([three-d.md](three-d.md#graphics)).
On Inflate, `x` and `y` are measured in the art's plane, and the graphic is carried straight out onto the puffed
face, Twist and Taper turning and shrinking the back's with it.
The graphics are the `graphics` parameter of `threeD.extrude`, `threeD.rotate` and `threeD.revolve`, which `effect.setParams` also
The graphics are the `graphics` parameter of `threeD.extrude`, `threeD.rotate`, `threeD.revolve` and `threeD.inflate`, which `effect.setParams` also
edits: an array of up to 64 `{symbol, face, x, y, scale, rotation}` objects, drawn on the face turned,
foreshortened and shaded with it and clipped to it ([Map artworks on 3D object](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/map-artwork-on-3d-objects.html)).
Revolve takes graphics on its swept side and shades them with the object's light ([the archived reference, page 185](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=185));
how a graphic wraps around the side is VectorCraft's own rule. Extrude & Bevel takes graphics on its side, its
walls and bevels unrolled as one surface; how they are unrolled is VectorCraft's own rule.
how a graphic wraps around the side, and how one follows Inflate's puff, are VectorCraft's own rules. Extrude &
Bevel takes graphics on its side, its walls and bevels unrolled as one surface; how they are unrolled is
VectorCraft's own rule.
A graphic naming a symbol the document does not have is refused, unless the effect already holds a graphic of it.
The drawing rules are VectorCraft's own; see [three-d.md](three-d.md#graphics).
+24 -10
View File
@@ -491,8 +491,9 @@ The public [Map artworks on 3D object](https://helpx.adobe.com/illustrator/deskt
page describes graphics: art kept with the document and placed on single surfaces of a 3D object, and the
[3D and Materials panel options](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/3d-materials-panel-options.html)
page lists Graphics and Add Materials and Graphics on the Materials tab. VectorCraft maps graphics onto
Extrude & Bevel's front and back caps and its side (its walls and bevels), the plane of the Plane type (Rotate), and
the swept side of Revolve, which the public page's example of a label on a bottle describes.
Extrude & Bevel's front and back caps and its side (its walls and bevels), the plane of the Plane type (Rotate),
the swept side of Revolve, which the public page's example of a label on a bottle describes, and Inflate's puffed
front and back.
- The panel's **Materials** tab shows the document's graphics as thumbnails. A graphic is a document symbol, as
the public page allows existing symbols to be used. **Add as Single Graphic** keeps the selected art as a new
@@ -501,9 +502,9 @@ the swept side of Revolve, which the public page's example of a label on a bottl
- Clicking a thumbnail maps that graphic onto the front of the 3D effect of each selected object
(`threeD.mapGraphic`), in one undo step. A graphic larger than the object starts scaled down to fit inside it.
- Below the thumbnails the tab lists the graphics mapped onto the first selected object. The selected one shows
its Face (Front, Back or Side; Plane and Revolve show no Face, as a plane has only a front and Revolve's graphics
go on its side), X and Y (the offset of its center from the center of the
object's bounds, in the face's plane, or on a side from its middle unrolled flat), Scale (a percentage of the symbol's size) and Rotation
its Face (Front, Back or Side, on Inflate Front or Back for its puffed front or back; Plane and Revolve show no
Face, as a plane has only a front and Revolve's graphics go on its side), X and Y (the offset of its center from
the center of the object's bounds, in the face's plane, or on a side from its middle unrolled flat), Scale (a percentage of the symbol's size) and Rotation
(counterclockwise), and **Remove Graphic** takes it off. Each change is one undo step.
- While the tab is open, a blue handle sits on the center of each mapped graphic whose face is turned toward the
viewer. Dragging a handle moves that graphic over its face, previewed while the pointer is down and recorded as
@@ -524,6 +525,18 @@ These rules are VectorCraft's own:
their own. A graphic on a face turned away from the viewer is not drawn.
- On the back cap, X runs to the right as the back is seen from behind, so the graphic reads the right way round
there.
- On Inflate a graphic is placed in the art's plane, X and Y measured from the center of the object's bounds as on
a cap, and carried straight out onto the puffed face above each point, so it follows the puff. The back takes
graphics only with Both sides and Cap on (`threeD.mapGraphic` refuses one otherwise, and one already there is
not drawn); it reads the right way round from behind, and Twist and Taper turn and shrink its graphics with it.
The membrane is cut into triangles, and each one draws the part of the graphic that falls on it, shaded as
that triangle is shaded and drawn only where the surface's outside faces the viewer; nearer triangles drawn
after it cover it. When a cell of the membrane cannot be cut into triangles, the object draws without its
graphics and commands refuse them, as when the triangles take more faces than a 3D effect draws. Every solid of
the object (a fill's, and a stroke's outline) carries the graphics. The handle sits on the point of the puffed
face above the graphic's center, and only where the viewer sees that face. The cutting into straight pieces,
the seam strokes and the limits below are those of Revolve; when the triangles take more faces than a 3D
effect draws, the object draws without its graphics and commands refuse them.
- On Revolve a graphic lies on the swept side, which has one face (Front), unrolled flat. X runs around the axis:
the angle from the middle of the side times the profile's distance from the axis at that point, so a graphic
keeps its size at every distance and wraps farther around the axis where the profile comes nearer to it. Y runs
@@ -573,9 +586,10 @@ These rules are VectorCraft's own:
draws the object without a graphic past the first limit, and without all of its graphics past the second.
- A hollow Extrude & Bevel has no caps, so the graphics on its caps are not drawn until Cap is turned on again,
and `threeD.mapGraphic` refuses to map a new one onto a cap; its side takes graphics. With a depth of 0 the object
is a plane, and `threeD.mapGraphic` maps graphics onto its front only. Changing the type to Inflate drops the
graphics, and changing between Extrude, Plane and Revolve keeps them, except that Plane and Revolve drop the
graphics on the back cap and on Extrude & Bevel's side; on Revolve the front's graphics go on its side.
is a plane, and `threeD.mapGraphic` maps graphics onto its front only. Changing between Extrude, Plane, Revolve
and Inflate keeps the graphics, except that Plane and Revolve drop the graphics on the back cap, and Plane, Revolve
and Inflate drop the graphics on Extrude & Bevel's side; on Revolve the front's graphics go on its side, and on
Inflate the front's and back's go on the puffed faces.
- `effect.apply` and `effect.setParams` refuse a graphic that names a symbol the document does not have, unless
the effect already holds a graphic of that symbol. A graphic whose symbol is deleted is no longer drawn. Renaming a symbol renames it in the graphics that use it,
in the layers, in the art of symbols, patterns, graph designs, brushes and opacity masks, and in graphic
@@ -632,9 +646,9 @@ is VectorCraft's own.
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).
Commands validate the shape and the parameters before the document changes. All four also take `lights`: null (the default, use the earlier single-light fields), or an array of one to ten objects. Each object takes `color` (opaque `#rrggbb`, white), `intensity` (0..100%, 80), `rotation` (-180..180 degrees, 125.26), `height` (0..90 degrees, 30), `softness` (0..100%, 0), and `behind` (boolean, false). Omitted settings use those defaults. An explicit list replaces the earlier single light; `ambient` and `shade` remain shared. Set `lights` to null to return to the single-light fields. Invalid lists, counts, keys and values are rejected before editing; malformed loaded lists fall back to the earlier light safely. All four take `shadow` (boolean, false), `shadowPosition` (`behind` or `below`), `shadowDistance` (0..100%, 0) and `shadowBounds` (10..400%, 100) ([Shadows](#shadows)); values out of range are rejected before editing.
`threeD.extrude`, `threeD.rotate` and `threeD.revolve` take `graphics` ([Graphics](#graphics)): an array of up to 64 objects, each
`threeD.extrude`, `threeD.rotate`, `threeD.revolve` and `threeD.inflate` take `graphics` ([Graphics](#graphics)): an array of up to 64 objects, each
with `symbol` (the name of a document symbol), `face` (`front`, `back` or `side`, default `front`; `threeD.rotate` and
`threeD.revolve` take `front` only), `x` and `y` (points, default 0), `scale` (1..10000%, default 100) and `rotation` (-360..360 degrees,
`threeD.revolve` take `front` only, and `threeD.inflate` `front` or `back`), `x` and `y` (points, default 0), `scale` (1..10000%, default 100) and `rotation` (-360..360 degrees,
default 0). Other keys, values out of range and graphics on the other 3D effects are rejected before editing.
All four take `render` ([3D and Materials panel](#3d-and-materials-panel)): an object whose `mode` is `shaded` (the
default) or `wireframe`. A `render` that is not an object, a key other than `mode`, another mode, and `render` on