Direction
Primary flow direction of the layered layout. Default
The output is in screen coordinates either way (
which axis the layers advance along. Options named in flow terms (
do not.
``
the order axis, port sides and routing repairs assume.
Direction::LeftRight.The output is in screen coordinates either way (
x right, y down). The direction decideswhich axis the layers advance along. Options named in flow terms (
crate::Margins,LoopSide, PortSides) turn with it. Port hints (crate::PortHint) and the outputdo not.
``
use graphlay::{layout, Direction, GraphBuilder, LayoutOptions, Size};
let mut b = GraphBuilder::new();
let a = b.add_box(Size::new(100.0, 40.0));
let c = b.add_box(Size::new(100.0, 40.0));
b.connect(a, c);
let g = b.build();
let mut o = LayoutOptions::layered_default();
o.direction = Direction::LeftRight; // the default
let across = layout(&g, &o)?;
let gap = across.nodes[1].center.x - across.nodes[0].center.x - 100.0;
assert!((gap - o.spacing.layer_gap).abs() < 0.5);
o.direction = Direction::TopBottom;
let down = layout(&g, &o)?;
// The same layer gap, now between a 40px-tall box and the one below it.
let gap = down.nodes[1].center.y - down.nodes[0].center.y - 40.0;
assert!((gap - o.spacing.layer_gap).abs() < 0.5);
# Ok::<(), graphlay::LayoutError>(())
`
There is no BottomTop or RightLeft`. Mirroring the layer axis would reverse the handednessthe order axis, port sides and routing repairs assume.
Used as Input
0
functions accept this type(+40 nested)
Used as Output
0
functions return this type
Type Definition
2 nested items
"leftright" | "topbottom"— Primary flow direction of the layered layout. Default
Direction::LeftRight.variant 1:"leftright"— Layers advance left to right.
variant 2:"topbottom"— Layers advance top to bottom.
Example JSON Value
"leftright"