Skip to main content

weighted_split

Function weighted_split 

Source
pub fn weighted_split(
    direction: Direction,
    area: Rect,
    weights: &[Option<f64>],
) -> Vec<Rect>
Expand description

Split a Rect into n segments based on optional weights.

  • If all weights are None, the area is split into equal parts.
  • If some weights are set and others are None, the unweighted items each receive a default size of 1.0 unit. The remaining space is then distributed proportionally among the weighted items.
  • If all items have weights, the full area is distributed proportionally.

Returns a Vec<Rect> with weights.len() entries.