Public placement frame companion for the canvas API.
A placement frame is the canonical {space, x, y, w, h, anchor} shape used
by the canvas model. :world frames are transformed by the camera;
:viewport frames are fixed to the browser viewport layer and interpret
x/y as offsets from their placement anchor.
Application-facing APIs such as LivePanels.Canvas.Item.place/3 and
LivePanels.Canvas.Item.copy_to/3 accept app_frame/0: :x,
:y, :w, and :h are required, while :space and :anchor default to
:world and :top_left when omitted. Browser and persistence codecs use
the full frame/0 at their boundaries.
Summary
Functions
Returns the supported viewport anchoring positions.
Returns the placement anchor used when callers omit one.
Returns the placement space used when callers omit one.
Projects an item into a placement frame.
Normalizes a placement anchor from atom or string input.
Normalizes a placement anchor or returns the supplied fallback.
Normalizes an app-facing placement frame.
Normalizes a placement space from atom or string input.
Normalizes a placement space or returns the supplied fallback.
Serializes a placement anchor for browser and persistence payloads.
Serializes a placement space for browser and persistence payloads.
Returns the placement spaces supported by canvas items.
Types
@type anchor() ::
:top_left
| :top
| :top_right
| :right
| :bottom_right
| :bottom
| :bottom_left
| :left
| :center
@type app_frame() :: %{ optional(:space) => space(), optional(:anchor) => anchor(), x: integer(), y: integer(), w: pos_integer(), h: pos_integer() }
@type frame() :: %{ space: space(), x: integer(), y: integer(), w: pos_integer(), h: pos_integer(), anchor: anchor() }
@type space() :: :world | :viewport
Functions
@spec anchors() :: [anchor()]
Returns the supported viewport anchoring positions.
@spec default_anchor() :: anchor()
Returns the placement anchor used when callers omit one.
@spec default_space() :: space()
Returns the placement space used when callers omit one.
Projects an item into a placement frame.
Normalizes a placement anchor from atom or string input.
Normalizes a placement anchor or returns the supplied fallback.
Normalizes an app-facing placement frame.
Applications may omit :space and :anchor; they default to :world and
:top_left. Explicit malformed values still fail clearly.
Normalizes a placement space from atom or string input.
Normalizes a placement space or returns the supplied fallback.
Serializes a placement anchor for browser and persistence payloads.
Serializes a placement space for browser and persistence payloads.
@spec spaces() :: [space()]
Returns the placement spaces supported by canvas items.