LivePanels.Canvas.Layout.Bounds (livepanels v0.1.0)

Copy Markdown View Source

Integer viewport bounds used by layout strategy planning contexts.

Layout strategies receive %LivePanels.Canvas.Layout.Context{} values with viewport_bounds and usable_bounds fields normalized through this module. Bounds use inclusive :left/:top origins and exclusive :right/:bottom edges so strategy code can derive rectangle width and height by subtraction.

Summary

Types

t()

@type t() :: %{left: integer(), top: integer(), right: integer(), bottom: integer()}

Functions

axis_start(bounds_start, bounds_end, inset, required_extent)

@spec axis_start(integer(), integer(), integer(), integer()) :: integer()

fit(bounds, width, height)

@spec fit(map(), pos_integer(), pos_integer()) :: {:ok, t()} | :error

from_viewport(viewport)

@spec from_viewport(map() | term()) :: t()

to_rect(map)

@spec to_rect(t()) :: %{
  x: integer(),
  y: integer(),
  w: non_neg_integer(),
  h: non_neg_integer()
}