Plushie.Canvas.Rect (Plushie v0.7.1)

Copy Markdown View Source

Canvas rectangle element with position, size, and optional styling.

Summary

Functions

Converts this widget struct to a ui_node() map.

Fill color or gradient.

Fill rule: "non_zero" or "even_odd".

Height in pixels.

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

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

Opacity from 0.0 (transparent) to 1.0 (opaque).

Corner radius. Uniform number or per-corner map.

Stroke descriptor (color, width, cap, join).

Returns the element type string for the wire protocol.

Width in pixels.

Applies keyword options to an existing widget struct.

X position in pixels.

Y position in pixels.

Types

option()

@type option() ::
  ((((((({:x, number()} | {:y, number()}) | {:w, number()}) | {:h, number()})
      | {:fill, term()})
     | {:stroke,
        %Plushie.Canvas.Stroke{
          cap: term(),
          color: term(),
          dash: term(),
          join: term(),
          width: term()
        }
        | keyword()
        | map()})
    | {:opacity, number()})
   | {:fill_rule, String.t() | atom()})
  | {:radius, term()}

t()

Functions

build(widget)

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

Converts this widget struct to a ui_node() map.

fill(widget, descriptor)

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

Fill color or gradient.

Accepts term().

fill_rule(widget, descriptor)

@spec fill_rule(widget :: t(), value :: (String.t() | atom()) | nil) :: t()

Fill rule: "non_zero" or "even_odd".

Accepts String.t() | atom().

h(widget, descriptor)

@spec h(widget :: t(), value :: number() | nil) :: t()

Height in pixels.

Accepts number().

new(x, y, w, h)

new(id, x, y, w, h)

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

new(id, x, y, w, h, opts)

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

opacity(widget, descriptor)

@spec opacity(widget :: t(), value :: number() | nil) :: t()

Opacity from 0.0 (transparent) to 1.0 (opaque).

Accepts number().

radius(widget, descriptor)

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

Corner radius. Uniform number or per-corner map.

Accepts term().

stroke(widget, descriptor)

@spec stroke(
  widget :: t(),
  value ::
    (%Plushie.Canvas.Stroke{
       cap: term(),
       color: term(),
       dash: term(),
       join: term(),
       width: term()
     }
     | keyword()
     | map())
    | nil
) :: t()

Stroke descriptor (color, width, cap, join).

Accepts %Plushie.Canvas.Stroke{}.

type_name()

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

Returns the element type string for the wire protocol.

w(widget, descriptor)

@spec w(widget :: t(), value :: number() | nil) :: t()

Width in pixels.

Accepts number().

with_options(widget, opts)

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

Applies keyword options to an existing widget struct.

x(widget, descriptor)

@spec x(widget :: t(), value :: number() | nil) :: t()

X position in pixels.

Accepts number().

y(widget, descriptor)

@spec y(widget :: t(), value :: number() | nil) :: t()

Y position in pixels.

Accepts number().