diagram_core/src/tools/array.rs#
Source: lib/diagram_core/src/tools/array.rs
tools::array -- Array (AS-11, RA-09): copies of shapes in rows and columns
Grid rows, columns, the spacing, how it is measured, the directions
offsets(size, &grid) the offset of every cell but the first (row by row): where the copy
of that cell goes, from the shapes themselves
make(tx, eng, owner, shapes, &grid) -> Vec<ShapeRef> the copies (new top-level shapes in
the order of the cells)
The shapes copied stand in the first cell (top left with the default directions); the cell is
the box around all of them. Spacing between the shapes: from the box's edge to the next box's
edge; from middle to middle: the step itself (smaller than the box: the copies overlap, as the
user asked). Copies are made the way a paste makes them (ops::paste): masters stay masters,
connectors between copied shapes come along, glue to shapes left behind is let go.
/// the most cells an array makes (rows x columns)
MAX_CELLS: u32 = 10_000
struct Gridan array of copiesrows: u32-- rows (1 or more)cols: u32-- columns (1 or more)gap: [f64; 2]-- x: between columns, y: between rows (drawing units, 0 or more)centres: bool-- the gap is the step from middle to middle (else from edge to edge)left: bool-- the columns go to the left (else to the right)up: bool-- the rows go up (else down)
fn offsets(size: [f64; 2], g: &Grid) -> Vec<(u32, u32, [f64; 2])>(row, column, offset) of every cell but the first, row by row, for shapes whose box issizewide and highfn make(tx: &mut Transaction, eng: &mut Engine, owner: Owner, shapes: &[ShapeRef], g: &Grid) -> Result<Vec<ShapeRef>, EditError>the copies ofshapes(top-level shapes ofowner) for every cell but the first -> the new top-level shapes, cell by cell. Invalid: no rows or columns, more than MAX_CELLS