mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 12:38:18 +00:00
Map Art: symbol null with placement values is refused, and Invisible Geometry hides every revolved member
threeD.mapArt refuses `symbol: null` given with x, y, scaleX, scaleY, rotation or fit true instead of ignoring those values. With Invisible Geometry, every member of a revolved group leaves its faces out once the mapped art on the longest member's side does; Wireframe still draws them. A new test pastes a mapped object into another document, one of them holding other art under the same symbol name. The catalog gives the x and y range for both classic effects, the help links point at the Map Art page, and docs/gaps.md and docs/effects-parity.md no longer list Map Art as missing.
This commit is contained in:
@@ -210,14 +210,14 @@ pub fn effect_catalog() -> Vec<EffectInfo> {
|
||||
CLASSIC_EXTRUDE,
|
||||
"Extrude & Bevel (Classic)…",
|
||||
&["Effect", "3D and Materials", "3D (Classic)"],
|
||||
"{depth: pt (0..2000, 50), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none), bevelHeight: pt (1..100, 4; the bevel is as wide as it is tall), bevelInside: bool (false: added around the shape; true: carved into it), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face, hidden ones included, and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, lighter where the highlight is, with black multiplied and overprinting where the faces darken, so a spot color keeps its plate; it does nothing while shadingColor is custom), drawHiddenFaces: bool (false; also draws the faces turned away, behind the others), mapArt: array of 0..64 objects ([]; Map Art, see threeD.mapArt: surface: integer (1..100000; the numbered surface, one map for a surface), symbol: name of a document symbol, x: pt (0; the offset of the art's center from the center of the surface laid out flat), y: pt (0), scaleX: % (1..10000, 100; of the symbol's own width), scaleY: % (1..10000, 100), rotation: degrees (-360..360, 0; counterclockwise); the surfaces are numbered through the object's solids in the order they are built: each solid's front cap and back cap, then each side wall from corner to corner of the outline, then the bevel above each wall; a map past the object's surfaces draws nothing; wireframe draws no mapped art), mapShade: bool (false; Shade Artwork: the mapped art takes the tone and highlight of its face), mapInvisible: bool (false; Invisible Geometry: with at least one map, only the mapped art is drawn)}. The front face is the art, extruded backwards about the center of its bounds; a solid is built for the top fill and for each stroke, each in its own paint. The defaults, the surface numbering and the limits are VectorCraft's own.",
|
||||
"{depth: pt (0..2000, 50), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none), bevelHeight: pt (1..100, 4; the bevel is as wide as it is tall), bevelInside: bool (false: added around the shape; true: carved into it), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face, hidden ones included, and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, lighter where the highlight is, with black multiplied and overprinting where the faces darken, so a spot color keeps its plate; it does nothing while shadingColor is custom), drawHiddenFaces: bool (false; also draws the faces turned away, behind the others), mapArt: array of 0..64 objects ([]; Map Art, see threeD.mapArt: surface: integer (1..100000; the numbered surface, one map for a surface), symbol: name of a document symbol, x: pt (-1000000..1000000, 0; the offset of the art's center from the center of the surface laid out flat), y: pt (-1000000..1000000, 0), scaleX: % (1..10000, 100; of the symbol's own width), scaleY: % (1..10000, 100), rotation: degrees (-360..360, 0; counterclockwise); the surfaces are numbered through the object's solids in the order they are built: each solid's front cap and back cap, then each side wall from corner to corner of the outline, then the bevel above each wall; a map past the object's surfaces draws nothing; wireframe draws no mapped art), mapShade: bool (false; Shade Artwork: the mapped art takes the tone and highlight of its face), mapInvisible: bool (false; Invisible Geometry: with at least one map, only the mapped art is drawn)}. The front face is the art, extruded backwards about the center of its bounds; a solid is built for the top fill and for each stroke, each in its own paint. The defaults, the surface numbering and the limits are VectorCraft's own.",
|
||||
json!({"depth":50.0,"cap":true,"bevel":"none","bevelHeight":4.0,"bevelInside":false,"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"surface":"plastic","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":100.0,"ambient":50.0,"highlightIntensity":60.0,"highlightSize":90.0,"blendSteps":25,"shadingColor":"black","shadingCustom":"#000000","preserveSpotColors":false,"drawHiddenFaces":false,"mapArt":[],"mapShade":false,"mapInvisible":false}),
|
||||
),
|
||||
g(
|
||||
CLASSIC_REVOLVE,
|
||||
"Revolve (Classic)…",
|
||||
&["Effect", "3D and Materials", "3D (Classic)"],
|
||||
"{angle: degrees (0..360, 360; how far the profile sweeps round the axis), cap: bool (true: solid, the open ends closed; false: hollow), offset: pt (0..1000, 0; the axis's distance from the profile, a ring past 0), edge: left|right (left; the axis is at the left or the right edge of the profile's bounds), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, lighter where the highlight is, with black multiplied and overprinting where the faces darken, so a spot color keeps its plate; it does nothing while shadingColor is custom), mapArt: array of 0..64 objects ([]; Map Art, see threeD.mapArt: surface: integer (the swept side is surface 1, the only one; in a group, the side of the member with the longest profile; a map of another surface draws nothing), symbol: name of a document symbol, x: pt (0; the offset of the art's center from the middle of the side unrolled flat, around the axis), y: pt (0; along the profile), scaleX: % (1..10000, 100; of the symbol's own width), scaleY: % (1..10000, 100), rotation: degrees (-360..360, 0; counterclockwise); the art wraps around the side and is drawn where its outside faces the viewer; wireframe draws no mapped art), mapShade: bool (false; Shade Artwork: the mapped art takes the tone and highlight of its face), mapInvisible: bool (false; Invisible Geometry: with at least one map, only the mapped art is drawn)}. The profile sweeps round a vertical axis, as Revolve's does, painted with the top fill (else the top stroke); every face is drawn, back to front. The defaults, the surface numbering and the limits are VectorCraft's own.",
|
||||
"{angle: degrees (0..360, 360; how far the profile sweeps round the axis), cap: bool (true: solid, the open ends closed; false: hollow), offset: pt (0..1000, 0; the axis's distance from the profile, a ring past 0), edge: left|right (left; the axis is at the left or the right edge of the profile's bounds), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, lighter where the highlight is, with black multiplied and overprinting where the faces darken, so a spot color keeps its plate; it does nothing while shadingColor is custom), mapArt: array of 0..64 objects ([]; Map Art, see threeD.mapArt: surface: integer (the swept side is surface 1, the only one; in a group, the side of the member with the longest profile; a map of another surface draws nothing), symbol: name of a document symbol, x: pt (-1000000..1000000, 0; the offset of the art's center from the middle of the side unrolled flat, around the axis), y: pt (-1000000..1000000, 0; along the profile), scaleX: % (1..10000, 100; of the symbol's own width), scaleY: % (1..10000, 100), rotation: degrees (-360..360, 0; counterclockwise); the art wraps around the side and is drawn where its outside faces the viewer; wireframe draws no mapped art), mapShade: bool (false; Shade Artwork: the mapped art takes the tone and highlight of its face), mapInvisible: bool (false; Invisible Geometry: with at least one map, only the mapped art is drawn)}. The profile sweeps round a vertical axis, as Revolve's does, painted with the top fill (else the top stroke); every face is drawn, back to front. The defaults, the surface numbering and the limits are VectorCraft's own.",
|
||||
json!({"angle":360.0,"cap":true,"offset":0.0,"edge":"left","rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"surface":"plastic","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":100.0,"ambient":50.0,"highlightIntensity":60.0,"highlightSize":90.0,"blendSteps":25,"shadingColor":"black","shadingCustom":"#000000","preserveSpotColors":false,"mapArt":[],"mapShade":false,"mapInvisible":false}),
|
||||
),
|
||||
g(
|
||||
|
||||
@@ -438,7 +438,10 @@ fn group_shadow(
|
||||
/// with its classic surface, as Extrude & Bevel (Classic) does. Revolve's graphics, with the
|
||||
/// symbols of `doc`, are drawn on the faces of the side ([`crate::solids::graphics::surface_parts`]):
|
||||
/// a face with a part of a graphic is a group of the face and that part. With `cast`, the sweep
|
||||
/// that draws the surface also keeps the faces its shadow is cast from ([`SolidFaces`]).
|
||||
/// that draws the surface also keeps the faces its shadow is cast from ([`SolidFaces`]). With
|
||||
/// `hide`, a Revolve (Classic) surface without mapped art leaves its faces out, as Invisible
|
||||
/// Geometry does ([`crate::solids::classic::surface`]). The last value is whether the faces were
|
||||
/// left out.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn surface(
|
||||
doc: Option<&Document>,
|
||||
@@ -453,7 +456,8 @@ fn surface(
|
||||
expand: bool,
|
||||
copies: &mut Copies,
|
||||
cast: bool,
|
||||
) -> Option<(Vec<Drawn>, Node, Option<SolidFaces>)> {
|
||||
hide: bool,
|
||||
) -> Option<(Vec<Drawn>, Node, Option<SolidFaces>, bool)> {
|
||||
#[cfg(test)]
|
||||
crate::solids::SOLIDS_BUILT.with(|n| n.set(n.get() + 1));
|
||||
// A loaded file or a profile edited past the limits keeps drawing its source path instead
|
||||
@@ -488,7 +492,8 @@ fn surface(
|
||||
budget: &mut budget,
|
||||
copies: &mut copies.graphics,
|
||||
});
|
||||
return Some((drawn, crate::solids::classic::surface(n, facets, &paint, (opacity, blend), &p, mapped), kept));
|
||||
let (art, hidden) = crate::solids::classic::surface(n, facets, &paint, (opacity, blend), &p, mapped, hide);
|
||||
return Some((drawn, art, kept, hidden));
|
||||
}
|
||||
let colored = options.light_color != [1.0; 3] || options.lights.is_some();
|
||||
let (faces, kept) = if cast {
|
||||
@@ -619,7 +624,7 @@ fn surface(
|
||||
let mut group = Node::group(n.id, children);
|
||||
group.opacity = opacity;
|
||||
group.blend = blend;
|
||||
Some((keys, group, kept))
|
||||
Some((keys, group, kept, false))
|
||||
}
|
||||
|
||||
/// A face [`surface`] draws: its depth and, for [`crate::solids::surface_order`], its polygon on the
|
||||
@@ -651,7 +656,7 @@ fn object_surface(
|
||||
let b = path.bounds()?;
|
||||
let (paint, opacity, blend) = paint_of(item);
|
||||
let cast = casts(fx, opacity);
|
||||
surface(doc, n, path, b, fx_options(fx), fx, paint, opacity, blend, expand, copies, cast).map(|(_, art, kept)| (art, kept))
|
||||
surface(doc, n, path, b, fx_options(fx), fx, paint, opacity, blend, expand, copies, cast, false).map(|(_, art, kept, _)| (art, kept))
|
||||
}
|
||||
|
||||
/// The paint of a graphic's solid color `c` on `face`, shaded as the face shades a solid fill of
|
||||
@@ -1078,19 +1083,36 @@ fn group_art(doc: Option<&Document>, n: &Node, expand: bool) -> Option<Node> {
|
||||
let mapped = (fx.id == REVOLVE && !crate::solids::mapped_graphics(&p).is_empty())
|
||||
|| (fx.id == CLASSIC_REVOLVE && !crate::solids::surface_maps(&p).is_empty());
|
||||
let longest = if mapped { graphics_member(&shapes, b, options) } else { None };
|
||||
for (k, s) in shapes.iter().enumerate() {
|
||||
let Some(item) = surface_item(&s.items) else {
|
||||
kept.push(None);
|
||||
continue;
|
||||
};
|
||||
// Member `k`'s surface, its faces left out with `hide`, with its opacity and blending mode;
|
||||
// `None` for a member with no fill or stroke.
|
||||
let member = |k: usize, s: &Profile, hide: bool, copies: &mut Copies| {
|
||||
let item = surface_item(&s.items)?;
|
||||
// The opacity and blending of the member and the groups it is in apply through its scopes.
|
||||
let (paint, opacity, blend) = paint_of(item);
|
||||
opaque &= opacity >= 1.0 && blend == Default::default() && s.scopes.is_empty();
|
||||
// A member with transparency of its own keeps every face, as a transparent object does.
|
||||
let expand = expand && s.scopes.is_empty();
|
||||
let doc = doc.filter(|_| longest == Some(k));
|
||||
let cast = casts(fx, opacity * s.opacity);
|
||||
let (depths, art, faces) = surface(doc, n, &s.path, b, options, fx, paint, opacity, blend, expand, &mut copies, cast)?;
|
||||
Some((opacity, blend, surface(doc, n, &s.path, b, options, fx, paint, opacity, blend, expand, copies, cast, hide)))
|
||||
};
|
||||
// With Invisible Geometry the other members leave their faces out too, once the mapped art on
|
||||
// the longest member's side has left that member's faces out, so it is built first.
|
||||
let invisible = fx.id == CLASSIC_REVOLVE && doc.is_some() && p.get(crate::solids::MAP_INVISIBLE).and_then(Value::as_bool).unwrap_or(false);
|
||||
let mut first = None;
|
||||
if let Some(l) = longest.filter(|_| invisible)
|
||||
&& let Some(s) = shapes.get(l)
|
||||
{
|
||||
first = member(l, s, false, &mut copies);
|
||||
}
|
||||
let hide = matches!(first, Some((_, _, Some((_, _, _, true)))));
|
||||
for (k, s) in shapes.iter().enumerate() {
|
||||
let built = if longest == Some(k) && first.is_some() { first.take() } else { member(k, s, hide, &mut copies) };
|
||||
let Some((opacity, blend, built)) = built else {
|
||||
kept.push(None);
|
||||
continue;
|
||||
};
|
||||
opaque &= opacity >= 1.0 && blend == Default::default() && s.scopes.is_empty();
|
||||
let (depths, art, faces, _) = built?;
|
||||
surfaces.push((depths, art, s.scopes.as_slice()));
|
||||
kept.push(faces);
|
||||
}
|
||||
@@ -1868,7 +1890,7 @@ mod tests {
|
||||
.map(|s| {
|
||||
let (paint, opacity, blend) = paint_of(surface_item(&s.items).unwrap());
|
||||
let cast = casts(&fx, opacity * s.opacity);
|
||||
surface(None, &g, &s.path, b, options, &fx, paint, opacity, blend, false, &mut Copies::default(), cast).unwrap().2
|
||||
surface(None, &g, &s.path, b, options, &fx, paint, opacity, blend, false, &mut Copies::default(), cast, false).unwrap().2
|
||||
})
|
||||
.collect();
|
||||
assert!(kept.iter().all(Option::is_some), "{id} {params}");
|
||||
@@ -1904,7 +1926,7 @@ mod tests {
|
||||
.map(|s| {
|
||||
let (paint, opacity, blend) = paint_of(surface_item(&s.items).unwrap());
|
||||
let cast = casts(&fx, opacity * s.opacity);
|
||||
surface(None, g, &s.path, b, options, &fx, paint, opacity, blend, false, &mut Copies::default(), cast).unwrap().2
|
||||
surface(None, g, &s.path, b, options, &fx, paint, opacity, blend, false, &mut Copies::default(), cast, false).unwrap().2
|
||||
})
|
||||
.collect();
|
||||
[group_shadow(g.id, &fx, &shapes, b, options, kept).unwrap(), group_shadow(g.id, &fx, &shapes, b, options, vec![]).unwrap()]
|
||||
|
||||
@@ -1778,7 +1778,7 @@ fn surfaces_for(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profile
|
||||
}
|
||||
}
|
||||
let art = if classic {
|
||||
classic::surface(n, f, &paint, (opacity, blend), &p, None)
|
||||
classic::surface(n, f, &paint, (opacity, blend), &p, None, false).0
|
||||
} else {
|
||||
surface(n, f, &paint, opacity, blend, colored, false)
|
||||
};
|
||||
@@ -1916,7 +1916,7 @@ fn surfaces_for(doc: Option<&Document>, n: &Node, fx: &Effect, shapes: &[Profile
|
||||
budget: &mut map_budget,
|
||||
copies: &mut paint_bytes,
|
||||
});
|
||||
classic::surface(n, f, &paint, (opacity, blend), &p, mapped)
|
||||
classic::surface(n, f, &paint, (opacity, blend), &p, mapped, false).0
|
||||
} else {
|
||||
surface(n, f, &paint, opacity, blend, colored, split && shared.get(shape).copied().unwrap_or(false))
|
||||
};
|
||||
|
||||
@@ -250,7 +250,10 @@ pub(crate) fn stroke_width(face: &Facet, p: &Value) -> f64 {
|
||||
/// With `mapped`, a face that carries mapped art is a group of the face and that art, which the
|
||||
/// surface's opacity mask covers too. Shade Artwork gives the art its face's tone and highlight,
|
||||
/// and Invisible Geometry leaves the faces out: a face is then a group of its art alone. Wireframe
|
||||
/// draws no mapped art.
|
||||
/// draws no mapped art. Without `mapped`, `hide` leaves the faces out the same way, for a solid
|
||||
/// that shares Invisible Geometry with another solid's mapped art; Wireframe still draws.
|
||||
///
|
||||
/// Returns the group and whether its faces were left out.
|
||||
pub(crate) fn surface(
|
||||
n: &Node,
|
||||
facets: Vec<Facet>,
|
||||
@@ -258,7 +261,8 @@ pub(crate) fn surface(
|
||||
(opacity, blend): (f32, BlendMode),
|
||||
p: &Value,
|
||||
mapped: Option<Mapped<'_, '_>>,
|
||||
) -> Node {
|
||||
hide: bool,
|
||||
) -> (Node, bool) {
|
||||
let shading = classic_shading(p);
|
||||
let lights = lights(p);
|
||||
let shade = shading_color(p);
|
||||
@@ -279,7 +283,7 @@ pub(crate) fn surface(
|
||||
None => (vec![], false),
|
||||
}
|
||||
}
|
||||
None => (vec![], false),
|
||||
None => (vec![], hide && !wire),
|
||||
};
|
||||
let children = facets
|
||||
.into_iter()
|
||||
@@ -306,7 +310,7 @@ pub(crate) fn surface(
|
||||
let coverage = Node::path(n.id, vectorcraft_geom::shapes::rectangle(bounds), Appearance::basic(mask, Paint::None, 0.0));
|
||||
group.extras_mut().mask = Some(Box::new(vectorcraft_doc::OpacityMask::new(coverage, true)));
|
||||
}
|
||||
group
|
||||
(group, invisible)
|
||||
}
|
||||
|
||||
/// One face of a solid in paint `paint` (opaque: [`surface`] masks a gradient's transparency),
|
||||
|
||||
@@ -260,6 +260,37 @@ fn revolve_classic_wraps_its_map_around_the_side() {
|
||||
assert!(filled(&crate::revolve_art_in(Some(&d), &n).unwrap(), RED).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invisible_geometry_leaves_out_every_member_of_a_revolved_group() {
|
||||
let d = document();
|
||||
let gray = Color::rgb(0.5, 0.5, 0.5);
|
||||
let line = |id: u64, x: f64, height: f64| {
|
||||
let mut b = BezPath::new();
|
||||
b.move_to((x, 0.0));
|
||||
b.line_to((x, height));
|
||||
Arc::new(Node::path(NodeId(id), PathData::from_bezpath(&b), Appearance::basic(Paint::None, Paint::solid(gray), 1.0)))
|
||||
};
|
||||
// The map goes on the side of the longer member; the shorter one has none.
|
||||
let art = |extra: Value| {
|
||||
let mut p =
|
||||
json!({"rotationX": 0, "rotationY": 0, "rotationZ": 0, "surface": "none", "offset": 40, "mapArt": [{"surface": 1, "symbol": "Mark"}]});
|
||||
p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone());
|
||||
let mut g = Node::group(NodeId(7), vec![line(8, 100.0, 100.0), line(9, 140.0, 30.0)]);
|
||||
g.appearance.effects.push(crate::new_effect(CLASSIC_REVOLVE, &p).unwrap());
|
||||
crate::revolve_art_in(Some(&d), &g).unwrap()
|
||||
};
|
||||
let shown = art(json!({}));
|
||||
assert!(!filled(&shown, RED).is_empty() && !filled(&shown, gray).is_empty());
|
||||
let hidden = art(json!({"mapInvisible": true}));
|
||||
assert!(!filled(&hidden, RED).is_empty());
|
||||
assert!(filled(&hidden, gray).is_empty(), "no member's faces are drawn");
|
||||
// On Wireframe the members are drawn as they are without a map.
|
||||
let wire = art(json!({"mapInvisible": true, "surface": "wireframe"}));
|
||||
let mut strokes = 0;
|
||||
wire.walk(&mut |n| strokes += usize::from(n.appearance.items.iter().any(|i| matches!(i, AppearanceItem::Stroke(_)))));
|
||||
assert!(strokes > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_maps_are_refused() {
|
||||
let d = document();
|
||||
|
||||
@@ -37,7 +37,7 @@ pub(super) fn specs() -> Vec<CommandSpec> {
|
||||
"Map Art",
|
||||
[],
|
||||
None,
|
||||
"{surface?: integer (1..the object's surface count: Extrude & Bevel (Classic) numbers each solid's front cap and back cap, then each side wall from corner to corner of the outline, then the bevel above each wall; Revolve (Classic)'s swept side is surface 1), symbol?: name of a document symbol|null (with surface: the symbol mapped onto it; null removes the surface's map; omitted: the surface's map keeps its symbol, and a surface with no map is refused), x?: pt, y?: pt (-1000000..1000000; the offset of the art's center from the center of the surface laid out flat; a new map starts at 0, 0; not used with symbol null), scaleX?: %, scaleY?: % (1..10000; of the symbol's own width and height; a new map starts at 100), rotation?: degrees (-360..360; counterclockwise; a new map starts at 0), fit?: bool (false; true is Scale to Fit: the art is centered and scaled to fill the surface, each side on its own when the art is square to the surface, else in proportion; art with no area keeps its scales), clearAll?: bool (false; true removes every map first, so with surface only that surface's map is left), shade?: bool (Shade Artwork: the mapped art takes the tone and highlight of its face), invisible?: bool (Invisible Geometry: with at least one map, only the mapped art is drawn), index?: int (the 3D effect's position; default: each object's first Extrude & Bevel (Classic) or Revolve (Classic), its own before its fills' and strokes'), item?: appearance item index|null (refused without index; as effect.setParams), ids?|id?} set, edit or remove the art mapped onto the numbered surfaces of each selected object's 3D effect, which must be Extrude & Bevel (Classic) or Revolve (Classic) (Rotate (Classic) takes no map); one of surface, clearAll, shade or invisible is required; the maps are the effect's mapArt, mapShade and mapInvisible parameters; one undo step, and none when nothing changes → {ids: [the objects changed], maps: [the first object's maps]}",
|
||||
"{surface?: integer (1..the object's surface count: Extrude & Bevel (Classic) numbers each solid's front cap and back cap, then each side wall from corner to corner of the outline, then the bevel above each wall; Revolve (Classic)'s swept side is surface 1), symbol?: name of a document symbol|null (with surface: the symbol mapped onto it; null removes the surface's map and is refused with x, y, scaleX, scaleY, rotation or fit true; omitted: the surface's map keeps its symbol, and a surface with no map is refused), x?: pt, y?: pt (-1000000..1000000; the offset of the art's center from the center of the surface laid out flat; a new map starts at 0, 0), scaleX?: %, scaleY?: % (1..10000; of the symbol's own width and height; a new map starts at 100), rotation?: degrees (-360..360; counterclockwise; a new map starts at 0), fit?: bool (false; true is Scale to Fit: the art is centered and scaled to fill the surface, each side on its own when the art is square to the surface, else in proportion; art with no area keeps its scales), clearAll?: bool (false; true removes every map first, so with surface only that surface's map is left), shade?: bool (Shade Artwork: the mapped art takes the tone and highlight of its face), invisible?: bool (Invisible Geometry: with at least one map, only the mapped art is drawn), index?: int (the 3D effect's position; default: each object's first Extrude & Bevel (Classic) or Revolve (Classic), its own before its fills' and strokes'), item?: appearance item index|null (refused without index; as effect.setParams), ids?|id?} set, edit or remove the art mapped onto the numbered surfaces of each selected object's 3D effect, which must be Extrude & Bevel (Classic) or Revolve (Classic) (Rotate (Classic) takes no map); one of surface, clearAll, shade or invisible is required; the maps are the effect's mapArt, mapShade and mapInvisible parameters; one undo step, and none when nothing changes → {ids: [the objects changed], maps: [the first object's maps]}",
|
||||
has_doc,
|
||||
map_art
|
||||
),
|
||||
@@ -207,6 +207,9 @@ fn map_art(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
_ => {}
|
||||
}
|
||||
let removes = p.get("symbol").is_some_and(Value::is_null);
|
||||
if removes && (fit || PLACING[1..].iter().any(|k| p.get(*k).is_some())) {
|
||||
return Err(bad(C, "`symbol: null` removes the map: leave out `x`, `y`, `scaleX`, `scaleY`, `rotation` and `fit`"));
|
||||
}
|
||||
let d = &s.doc()?.doc;
|
||||
let targets: Vec<(NodeId, Option<usize>, usize)> = if p.get("index").is_some() {
|
||||
let index = index_param(p, "index", C)?;
|
||||
|
||||
@@ -132,6 +132,9 @@ fn bad_surfaces_symbols_and_values_are_refused() {
|
||||
(json!({"surface": 1, "symbol": "Mark", "x": 1e7}), "x must be a number"),
|
||||
(json!({"surface": 1, "symbol": "Mark", "y": "up"}), "y must be a number"),
|
||||
(json!({"surface": 1, "symbol": "Mark", "fit": 1}), "fit"),
|
||||
(json!({"surface": 1, "symbol": null, "x": 4.0}), "`symbol: null` removes the map"),
|
||||
(json!({"surface": 1, "symbol": null, "rotation": 30.0}), "`symbol: null` removes the map"),
|
||||
(json!({"surface": 1, "symbol": null, "fit": true}), "`symbol: null` removes the map"),
|
||||
(json!({"symbol": "Mark"}), "need `surface`"),
|
||||
(json!({"fit": true}), "need `surface`"),
|
||||
(json!({"shade": "on"}), "shade"),
|
||||
@@ -192,3 +195,31 @@ fn a_mapped_symbol_is_drawn_expanded_renamed_and_kept_in_use() {
|
||||
}
|
||||
assert!(red > 0, "the expanded art holds the mapped symbol's red fill");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pasted_into_another_document_a_map_brings_its_symbol() {
|
||||
let (mut s, id) = setup("threeD.classicExtrude");
|
||||
s.execute("threeD.mapArt", &json!({"surface": 1, "symbol": "Mark"})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [id.0]})).unwrap();
|
||||
s.execute("edit.copy", &json!({})).unwrap();
|
||||
// The symbol the pasted object's map names, and the size of that symbol's art.
|
||||
let pasted = |s: &mut Session| {
|
||||
s.execute("edit.paste", &json!({})).unwrap();
|
||||
let st = s.doc().unwrap();
|
||||
let n = st.doc.node(st.selection.objects[0]).unwrap();
|
||||
let name = n.appearance.effects[0].params["mapArt"][0]["symbol"].as_str().unwrap().to_string();
|
||||
let size = vectorcraft_render::effects::graphic_bounds(&st.doc, &name).map(|r| (r.width(), r.height()));
|
||||
(name, size)
|
||||
};
|
||||
// A document without the symbol gets it.
|
||||
s.execute("file.new", &json!({"width":400,"height":400})).unwrap();
|
||||
assert_eq!(pasted(&mut s), ("Mark".to_string(), Some((11.0, 21.0))));
|
||||
// A document whose symbol "Mark" is other art gets the copied symbol under a free name, and
|
||||
// the map names it.
|
||||
s.execute("file.new", &json!({"width":400,"height":400})).unwrap();
|
||||
let other = s.execute("path.create", &json!({"d":"M0 0L50 0L50 50L0 50Z"})).unwrap()["id"].clone();
|
||||
s.execute("threeD.addGraphic", &json!({"name": "Mark", "ids": [other]})).unwrap();
|
||||
let (name, size) = pasted(&mut s);
|
||||
assert_ne!(name, "Mark");
|
||||
assert_eq!(size, Some((11.0, 21.0)));
|
||||
}
|
||||
|
||||
@@ -181,13 +181,13 @@ VectorCraft choices; an original approximation, never compared with another appl
|
||||
| Revolve | initial: live, editable profile, rotation and light gizmos, default-on Cap with continuous curved rims, smooth vector shading and round seam joins, overlapping faces drawn in the order of their depths where they overlap, SVG/PDF output, Expand Appearance ([revolve.md](revolve.md), #846) |
|
||||
| Extrude & Bevel, Inflate, Rotate | initial: live, round seam joins, depth, twist, taper, solid or hollow caps, five original bevel shapes, Inflate volume, both sides, twist, taper and cap, Rotate of every fill and stroke, groups and layers turned about one shared axis (#4506), contours that cross, touch or overlap merged first ([three-d.md](three-d.md)), Position presets, rotation and light gizmos, SVG/PDF output, Expand Appearance ([three-d.md](three-d.md)) |
|
||||
| Materials panel, lighting, ray-traced render | Window › 3D and Materials panel with the object types (Plane, Extrude, Revolve, Inflate) and the Object, Rotation and Lighting settings of the applied effect, Render Settings › Wireframe, which draws the live effect as the edges of its faces, and Quick Actions › Expand as Wireframes ([three-d.md](three-d.md#3d-and-materials-panel)); one to ten directional lights with per-light Color (opaque RGB, white by default), Intensity, Rotation, Height, Softness and neutral Ambient Light, Revolve and colored Inflate use smooth vector shading; Extrude & Bevel and Rotate retain planar shading; original Standard, Diffuse, Top Left and Right lighting rigs; hard-edged shadows behind or below the object from the first light ([three-d.md](three-d.md#shadows)); the Materials tab's Graphics, document symbols mapped onto Extrude & Bevel's caps and onto a plane, moved with an artboard handle, and wrapped around Revolve's side ([three-d.md](three-d.md#graphics)); no base materials, graphics on Inflate or on Extrude & Bevel's walls and bevels, soft shadows or ray tracing |
|
||||
| 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, round seam joins, Extrude Depth, Cap, five original bevel shapes with Height and Bevel Extent In or Out, Position presets and rotation gizmo, Perspective, Wireframe, No Shading, Diffuse and Plastic surfaces with one to ten lights, Light Intensity, Ambient Light, Highlight Intensity and Size, Blend Steps, Black, Custom or no Shading Color, Draw Hidden Faces ([create 3D objects](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html)); Revolve (Classic) initial: live, round seam joins, Angle, Cap, Offset from the left or right edge, Position presets and rotation gizmo, Perspective, the same four surfaces, lights, highlight, Blend Steps and Shading Color, groups and layers revolved about one shared axis (same page); Rotate (Classic) initial: live, round seam joins, every fill and stroke turned as one plane, Position presets and rotation gizmo, Perspective, No Shading and Diffuse surfaces with lights, Ambient Light, Blend Steps and Shading Color ([rotate objects in 3D](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/rotate-objects-in-3d.html)); Preserve Spot Colors in all three, unavailable with a Custom Shading Color ([Preserve Spot Color](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)); Map Art for Extrude & Bevel (Classic) and Revolve (Classic): one document symbol on each numbered surface, surface navigation with visible and hidden marks and a red outline on the artboard, move, scale and rotate on the surface laid out flat, Scale to Fit, Clear, Clear All, Shade Artwork, Invisible Geometry, kept by Expand Appearance and exports, `threeD.mapArt` ([map artwork to a 3D object](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=185)) |
|
||||
| 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, round seam joins, Extrude Depth, Cap, five original bevel shapes with Height and Bevel Extent In or Out, Position presets and rotation gizmo, Perspective, Wireframe, No Shading, Diffuse and Plastic surfaces with one to ten lights, Light Intensity, Ambient Light, Highlight Intensity and Size, Blend Steps, Black, Custom or no Shading Color, Draw Hidden Faces ([create 3D objects](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html)); Revolve (Classic) initial: live, round seam joins, Angle, Cap, Offset from the left or right edge, Position presets and rotation gizmo, Perspective, the same four surfaces, lights, highlight, Blend Steps and Shading Color, groups and layers revolved about one shared axis (same page); Rotate (Classic) initial: live, round seam joins, every fill and stroke turned as one plane, Position presets and rotation gizmo, Perspective, No Shading and Diffuse surfaces with lights, Ambient Light, Blend Steps and Shading Color ([rotate objects in 3D](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/rotate-objects-in-3d.html)); Preserve Spot Colors in all three, unavailable with a Custom Shading Color ([Preserve Spot Color](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)); Map Art for Extrude & Bevel (Classic) and Revolve (Classic): one document symbol on each numbered surface, surface navigation with visible and hidden marks and a red outline on the artboard, move, scale and rotate on the surface laid out flat, Scale to Fit, Clear, Clear All, Shade Artwork, Invisible Geometry, kept by Expand Appearance and exports, `threeD.mapArt` ([map artwork to a 3D object](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=189)) |
|
||||
| Turntable (30.0 beta) | none |
|
||||
| Export 3D objects (OBJ, USDA, glTF) | initial: Asset Export's Export 3D Object collects an object with Extrude & Bevel, Revolve, Inflate or Rotate as a 3D asset, and Export writes its solids as a USDA (the default), USDZ, glTF or OBJ mesh with a material in each solid's paint color (`assets.add3D`, `assets.set3DFormat`, `assets.export3D`); no textures, map art or shading ([3D export help](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/export-3d-vector-artwork.html)) |
|
||||
|
||||
The `three-d` crate (depends on `geom` and `pathops`, with no UI or GPU dependencies) builds, rotates, projects, shades and depth-sorts the surfaces;
|
||||
the effects crate turns them into art. What's left (materials and shadows, ray-traced rendering,
|
||||
angular cut caps, exact visibility, the rest of 3D Classic (Map Art), Turntable) is 25–45 h.
|
||||
angular cut caps, exact visibility, Turntable) is 25–45 h.
|
||||
|
||||
## Revision history
|
||||
|
||||
|
||||
+2
-2
@@ -694,8 +694,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi
|
||||
- **Done:** an initial live Revolve in the `three-d` crate (#846, from the contributor who offered in #605), with automatic smooth vector shading, default-on circular caps and spike-free continuous rims;
|
||||
Extrude & Bevel, Inflate and Rotate with Position presets ([three-d.md](three-d.md), #1407). Colored Inflate has automatic smooth vector lighting from shared membrane normals. White-light Inflate keeps its polygon shading. Every 3D facet's seam has round joins ([three-d.md](three-d.md#seams)). All four take one to ten colored directional lights, with neutral ambient applied once, a light list and independent previewing controls. Standard, Diffuse, Top Left and Right select original rigs, shared with commands; manual settings show Custom.
|
||||
- **Missing:** materials (base, Substance, graphics), shadows,
|
||||
ray-traced rendering, angular cut caps, exact visibility for intersecting and concave surfaces, the rest of 3D
|
||||
Classic (Map Art), Turntable, textures, map art and shading in 3D export.
|
||||
ray-traced rendering, angular cut caps, exact visibility for intersecting and concave surfaces, Turntable,
|
||||
textures, map art and shading in 3D export.
|
||||
- **Impact:** specialist; Materials is the one menu stub left.
|
||||
- **Estimate:** 25–45 h; plan in `plan/` before coding.
|
||||
|
||||
|
||||
+4
-3
@@ -4427,15 +4427,16 @@ another shading color is refused with an error and the document is not changed.
|
||||
`threeD.mapArt {surface?, symbol?, x?, y?, scaleX?, scaleY?, rotation?, fit?, clearAll?, shade?, invisible?, index?, item?, ids?|id?}`
|
||||
is the Map Art… button of the Extrude & Bevel (Classic) and Revolve (Classic) dialogs. It maps a document symbol onto
|
||||
one numbered surface of each selected object's classic 3D effect, edits that map or removes it, in one undo step
|
||||
([Map artwork to a 3D object](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=185)).
|
||||
([Map artwork to a 3D object](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=189)).
|
||||
Rotate (Classic) and the other 3D effects take no map.
|
||||
|
||||
- `surface` is a whole number from 1 to the object's surface count. Extrude & Bevel (Classic) numbers the surfaces
|
||||
through the object's solids in the order they are built: each solid's front cap and back cap, then each side wall
|
||||
from corner to corner of the outline, then the bevel above each wall. Revolve (Classic) has one surface, its swept
|
||||
side. The numbering is VectorCraft's own.
|
||||
- `symbol` names the symbol mapped onto the surface, and `null` removes the surface's map. Omitted, the surface keeps
|
||||
its map's symbol; a surface with no map then is refused.
|
||||
- `symbol` names the symbol mapped onto the surface, and `null` removes the surface's map; `null` with `x`, `y`,
|
||||
`scaleX`, `scaleY`, `rotation` or `fit: true` is refused. Omitted, the surface keeps its map's symbol; a surface with
|
||||
no map then is refused.
|
||||
- `x` and `y` (points, -1000000..1000000) place the center of the art from the center of the surface laid out flat,
|
||||
`scaleX` and `scaleY` (1..10000%) scale it from the symbol's own size, and `rotation` (-360..360 degrees) turns it
|
||||
counterclockwise. A new map starts at 0, 0, 100%, 100% and 0°.
|
||||
|
||||
+4
-3
@@ -486,8 +486,8 @@ These rules are VectorCraft's own:
|
||||
|
||||
The Extrude & Bevel (Classic) and Revolve (Classic) dialogs have a **Map Art…** button on their Object tab. It
|
||||
shows Map Art in place of the tabs until **Done**, and the dialog's Preview, OK and Cancel apply to the maps with the
|
||||
other settings ([Map artwork to a 3D object](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=185),
|
||||
[Using Illustrator CS5](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)).
|
||||
other settings ([Map artwork to a 3D object](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=189),
|
||||
[the same section in the 2010 help](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=274)).
|
||||
Rotate (Classic) and the other 3D effects take no map. The command is `threeD.mapArt` ([mcp.md](mcp.md#map-art)).
|
||||
|
||||
- **Surface**: the first, previous, next and last buttons and a number field pick the surface, with the count beside
|
||||
@@ -506,7 +506,8 @@ Extrude & Bevel (Classic) numbers its surfaces through the object's solids in th
|
||||
solid, then each stroke's): each solid's front cap and back cap, then each side wall from corner to corner of the
|
||||
outline, then the bevel above each wall. An extruded square has six surfaces. A hollow solid has no caps to number.
|
||||
Revolve (Classic) has one surface, its swept side, unrolled around the axis as Revolve's graphics are; on a group it is
|
||||
the side of the member with the longest profile. The numbering is VectorCraft's own.
|
||||
the side of the member with the longest profile, and Invisible Geometry leaves out every member's faces. The numbering
|
||||
is VectorCraft's own.
|
||||
|
||||
- A map's X and Y place the center of the art from the center of the surface laid out flat, so a map follows the
|
||||
center when the surface changes size. A map past the object's surface count draws nothing and stays in the effect.
|
||||
|
||||
Reference in New Issue
Block a user