Search documentation of Plushie

# Plushie.Canvas.Group (Plushie v0.7.2)

Copy Markdown View Source

Canvas group: a structural container for transforms, clips, and visual grouping.

Groups carry an ordered `transforms` list and an optional `clip` rect. The optional `id` is for tree diffing and targeting, not interactivity.

For interactive canvas elements (click, hover, drag, focus, a11y), use `Plushie.Canvas.Interactive` via the `interactive` macro.

## Summary

### Types

option()
t()

### Functions

build(widget)

Converts this widget struct to a `ui_node()` map.

clip(widget, descriptor)

Clip rectangle for the group.

extend(widget, children)

Appends multiple children to the widget.

new(id)

Creates a new element without an explicit ID (auto-assigned by parent container).

new(id, opts)

Creates a new element with the given ID and keyword options.

push(widget, child)

Appends a child to the widget.

transforms(widget, descriptor)

List of transform descriptors (translate, rotate, scale).

type_name()

Returns the element type string for the wire protocol.

with_options(widget, opts)

Applies keyword options to an existing widget struct.

## Types

# option()

    @type option() :: {:transforms, term()} | {:clip, term()}

# t()

    @type t() :: %Plushie.Canvas.Group{
      children: [Plushie.Widget.ui_node()],
      clip:
        term()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      id: String.t() | nil,
      transforms:
        term()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil
    }

## Functions

# build(widget)

    @spec build(widget :: t()) :: Plushie.Widget.ui_node()

Converts this widget struct to a `ui_node()` map.

# clip(widget, descriptor)

    @spec clip(widget :: t(), value :: term() | nil) :: t()

Clip rectangle for the group.

Accepts `term()`.

# extend(widget, children)

    @spec extend(widget :: t(), children :: [Plushie.Widget.child()]) :: t()

Appends multiple children to the widget.

# new(id)

    @spec new(opts :: [option()]) :: t()

Creates a new element without an explicit ID (auto-assigned by parent container).

# new(id, opts)

    @spec new(id :: String.t(), opts :: [option()]) :: t()

Creates a new element with the given ID and keyword options.

# push(widget, child)

    @spec push(widget :: t(), child :: Plushie.Widget.child()) :: t()

Appends a child to the widget.

# transforms(widget, descriptor)

    @spec transforms(widget :: t(), value :: term() | nil) :: t()

List of transform descriptors (translate, rotate, scale).

Accepts `term()`.

# type_name()

    @spec type_name() :: String.t()

Returns the element type string for the wire protocol.

# with_options(widget, opts)

    @spec with_options(widget :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing widget struct.