mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-12 08:51:11 +00:00
layout: leave out a grid that would pass the snap budget
This commit is contained in:
1 parent
1935c3eac2
commit
9d48625995
2 files changed
+6
-4
No files matched your search
@@ -102,6 +102,6 @@ fn snap_lines_are_bounded_across_a_frames_grids() {
|
||||
let f = d.create(p, NodeKind::Frame, "F", 0.0, 0.0, 4000.0, 4000.0).unwrap();
|
||||
d.get_mut(f).unwrap().grids = vec![LayoutGrid { kind: GridKind::Grid, size: 1.0, visible: true, ..LayoutGrid::default() }; 1000];
|
||||
let (xs, ys) = crate::grid_snap_lines(&d, f);
|
||||
assert!(xs.len() + ys.len() < 250_000, "{}", xs.len() + ys.len());
|
||||
assert!(xs.len() + ys.len() <= 200_000, "{}", xs.len() + ys.len());
|
||||
assert!(xs.len() > 4000 && ys.len() > 4000, "the first grids still give their lines");
|
||||
}
|
||||
@@ -1169,11 +1169,13 @@ pub fn grid_snap_lines_in(doc: &Document, frame: NodeId, xf: Affine) -> (Vec<f64
|
||||
let mut xs = Vec::new();
|
||||
let mut ys = Vec::new();
|
||||
for g in f.grids.iter().filter(|g| g.visible) {
|
||||
// A frame-wide budget: each grid adds up to ~17,000 lines, and a file can hold any number of grids.
|
||||
if xs.len() + ys.len() >= MAX_SNAP_LINES {
|
||||
// A frame-wide budget: each grid adds up to ~17,000 lines, and a file can hold any number of grids;
|
||||
// a grid that would pass it is left out whole.
|
||||
let lines = grid_lines(g, f.width, f.height);
|
||||
if xs.len() + ys.len() + 2 * lines.len() > MAX_SNAP_LINES {
|
||||
break;
|
||||
}
|
||||
for r in grid_lines(g, f.width, f.height) {
|
||||
for r in lines {
|
||||
let a = xf * Point::new(r.x0, r.y0);
|
||||
let b = xf * Point::new(r.x1, r.y1);
|
||||
match g.kind {
|
||||
|
||||
Reference in new issue
Block a user