Search documentation of Plushie

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

Copy Markdown View Source

Canvas SVG element with position and size.

## Summary

### Types

option()
t()

### Functions

build(widget)

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

h(widget, descriptor)

Height in pixels.

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

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

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

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

source(widget, descriptor)

Path to the SVG file.

type_name()

Returns the element type string for the wire protocol.

w(widget, descriptor)

Width in pixels.

with_options(widget, opts)

Applies keyword options to an existing widget struct.

x(widget, descriptor)

X position in pixels.

y(widget, descriptor)

Y position in pixels.

## Types

# option()

    @type option() ::
      ((({:source, String.t() | atom()} | {:x, number()}) | {:y, number()})
       | {:w, number()})
      | {:h, number()}

# t()

    @type t() :: %Plushie.Canvas.Svg{
      h:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      id: String.t() | nil,
      source:
        (String.t() | atom())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      w:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      x:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      y:
        number()
        | 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.

# h(widget, descriptor)

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

Height in pixels.

Accepts `number()`.

# new(source, x, y, w, h)

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

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

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

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

# source(widget, descriptor)

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

Path to the SVG file.

Accepts `String.t() | atom()`.

# 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()`.