mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 05:58:06 +00:00
Transform: butt-capped lines measure to their end points with Use Preview Bounds
With Use Preview Bounds on, the visual box of a butt-capped stroke on an open path grew by half the stroke weight past each end of the path, where a butt cap paints nothing. A 2 pt vertical line set to H: 10 mm in the Transform panel drew about 9.3 mm long. The box of an open subpath with butt caps no longer reaches past its ends. A straight segment's box comes from the four corners of its stroked rectangle, and a curve's box comes from the stroke at its ends and where its tangent is square to an axis. Bevel joins, and miter joins the limit bevels, are measured by the stroked corners, and round joins by the arc they paint outside the turn, instead of half the weight all round. Round and projecting caps, arrowheads, closed paths and miter tips measure as before. Two cases can still measure larger than the stroke paints: a curve that bends more tightly than half the weight, and a butt-dashed path whose first or last dash is a gap, which is measured to the path's ends. A horizontal or vertical butt line now measures one stroke weight less along its length in W or H, and Align places it by its end points. A slanted line's box shrinks by less: the stroke's corners still reach past the end points across the line. object.setBounds measures as drawn, after each scale it tries, a butt-capped open path with a segment at a slant, symbol instances' art included.
This commit is contained in:
@@ -125,15 +125,20 @@ fn bounds_transform(s: &Session, p: &Value, ids: Vec<NodeId>, least: f64, anchor
|
||||
// The scales and the point above can miss the size or the reference point when the margins of
|
||||
// the objects differ, the members of groups and the objects in symbols' art included, and with
|
||||
// strokes that scale, when the sizes are out of proportion. The objects are then measured one
|
||||
// by one ([`Spans::measure`]), and the scales solved for. Objects with geometry effects are
|
||||
// measured as drawn after each scale tried instead ([`refit_drawn`]).
|
||||
// by one ([`Spans::measure`]), and the scales solved for. Objects with geometry effects, and
|
||||
// objects with a butt-capped stroke along a segment at a slant, whose margins change with the
|
||||
// segment's direction, are measured as drawn after each scale tried instead ([`refit_drawn`]).
|
||||
let symbols = d.symbol_boxes();
|
||||
let drawn = || ids.iter().filter_map(|id| d.node(*id)).any(|n| effects::preview::draws_geometry(&symbols, n));
|
||||
let to_local = frame.to_doc().inverse();
|
||||
let drawn = || {
|
||||
ids.iter()
|
||||
.filter_map(|id| d.node(*id))
|
||||
.any(|n| effects::preview::draws_geometry(&symbols, n) || n.has_slanted_butt_stroke(&symbols, to_local))
|
||||
};
|
||||
let solved = if !(s.prefs.use_preview_bounds && w >= 0.0 && h >= 0.0) {
|
||||
None
|
||||
} else if transforms_objects(p) && !bool_or(p, "typeAreas", false) && drawn() {
|
||||
let options = scaling_options(s, p);
|
||||
let to_local = frame.to_doc().inverse();
|
||||
let measure = |sx: f64, sy: f64| {
|
||||
let xf = frame.conjugate(about(rp, Affine::scale_non_uniform(sx, sy)));
|
||||
let sc = if Scaling::factor(xf).is_some() { options } else { Scaling::default() };
|
||||
|
||||
Reference in New Issue
Block a user