Search documentation of Plushie

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

Copy Markdown View Source

Canvas text element with position, content, and optional font styling.

## Summary

### Types

option()
t()

### Functions

align_x(widget, descriptor)

Horizontal alignment: "left", "center", "right".

align_y(widget, descriptor)

Vertical alignment: "top", "center", "bottom".

build(widget)

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

content(widget, descriptor)

Text string to draw.

fill(widget, descriptor)

Text fill color.

font(widget, descriptor)

Font specification.

new(x, y, content)
new(id, x, y, content)

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

new(id, x, y, content, opts)

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

opacity(widget, descriptor)

Opacity from 0.0 to 1.0.

size(widget, descriptor)

Font size in pixels.

type_name()

Returns the element type string for the wire protocol.

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() ::
      ((((((({:x, number()} | {:y, number()}) | {:content, String.t() | atom()})
           | {:fill, term()})
          | {:size, number()})
         | {:font, String.t() | atom()})
        | {:align_x, String.t() | atom()})
       | {:align_y, String.t() | atom()})
      | {:opacity, number()}

# t()

    @type t() :: %Plushie.Canvas.Text{
      align_x:
        (String.t() | atom())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      align_y:
        (String.t() | atom())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      content:
        (String.t() | atom())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      fill:
        term()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      font:
        (String.t() | atom())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      id: String.t() | nil,
      opacity:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      size:
        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

# align_x(widget, descriptor)

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

Horizontal alignment: "left", "center", "right".

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

# align_y(widget, descriptor)

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

Vertical alignment: "top", "center", "bottom".

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

# build(widget)

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

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

# content(widget, descriptor)

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

Text string to draw.

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

# fill(widget, descriptor)

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

Text fill color.

Accepts `term()`.

# font(widget, descriptor)

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

Font specification.

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

# new(x, y, content)

# new(id, x, y, content)

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

# new(id, x, y, content, 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 to 1.0.

Accepts `number()`.

# size(widget, descriptor)

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

Font size in pixels.

Accepts `number()`.

# 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.

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