mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-09 04:54:45 +00:00
Print: the page boxes of a Copies per Sheet page hold only the copies on the paper
When the placement moved some copies off the paper, each of those copies counted as the whole page, so the TrimBox and BleedBox became the paper. They now hold the copies that print, and the whole page only when no copy is on it.
This commit is contained in:
@@ -246,12 +246,14 @@ pub(crate) fn layout(doc: &Document, set: &PrintSettings, warnings: &mut Vec<Str
|
||||
let place_at = |trim: Rect| {
|
||||
Affine::translate(trim.origin().to_vec2()) * Affine::scale_non_uniform(scale.0, scale.1) * Affine::translate(-r.origin().to_vec2())
|
||||
};
|
||||
// The page's boxes: the trim box within the bleed box within the page.
|
||||
let boxes = |view: Affine, trim: Rect| {
|
||||
// The page's boxes: the trim box within the bleed box within the page; `None` when none of
|
||||
// the trim box is on the page.
|
||||
let visible = |view: Affine, trim: Rect| {
|
||||
let b = view.transform_rect_bbox(outset(trim, bleed_s)).intersect(page);
|
||||
let t = view.transform_rect_bbox(trim).intersect(b);
|
||||
if t.area() > 0.0 { (t, b) } else { (page, page) }
|
||||
(t.area() > 0.0).then_some((t, b))
|
||||
};
|
||||
let boxes = |view: Affine, trim: Rect| visible(view, trim).unwrap_or((page, page));
|
||||
let base = |view, window, place, area, trim, (page_trim, page_bleed), tile, copies| Layout {
|
||||
artboard,
|
||||
tile,
|
||||
@@ -305,8 +307,12 @@ pub(crate) fn layout(doc: &Document, set: &PrintSettings, warnings: &mut Vec<Str
|
||||
let copies: Vec<Vec2> = grid.map_or_else(Vec::new, |(cols, rows)| {
|
||||
(0..rows).flat_map(|j| (0..cols).map(move |i| Vec2::new(i as f64 * step.0, j as f64 * step.1))).collect()
|
||||
});
|
||||
let page_boxes =
|
||||
copies.iter().map(|m| boxes(turn, trim + *m)).reduce(|a, b| (a.0.union(b.0), a.1.union(b.1))).unwrap_or_else(|| boxes(turn, trim));
|
||||
// The boxes hold the copies on the page; copies off it are left out.
|
||||
let page_boxes = copies
|
||||
.iter()
|
||||
.filter_map(|m| visible(turn, trim + *m))
|
||||
.reduce(|a, b| (a.0.union(b.0), a.1.union(b.1)))
|
||||
.unwrap_or_else(|| boxes(turn, trim));
|
||||
pages.push(base(turn, None, place_at(trim), bleed_box, trim, page_boxes, None, copies));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -246,6 +246,9 @@ fn copies_per_sheet_fill_the_page_in_a_grid() {
|
||||
// The placement places the grid, inside the margin.
|
||||
let pv = preview(&d, &settings(json!({"copiesPerSheet": true, "margin": 9, "placement": {"origin": "topLeft"}}))).unwrap();
|
||||
assert_eq!(corners(&pv), grid(&[9.0, 153.0, 297.0, 441.0], &[9.0, 261.0, 513.0]));
|
||||
// Moved 400 pt right, two columns leave the paper: the TrimBox holds the copies still on it.
|
||||
let pv = preview(&d, &settings(json!({"copiesPerSheet": true, "placement": {"origin": "topLeft", "x": 400}}))).unwrap();
|
||||
assert_eq!(pv.sheets[0].trim, [400.0, 0.0, 612.0, 756.0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user