Search documentation of Plushie

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

Copy Markdown View Source

Canvas line element between two points with optional stroke and opacity.

## Summary

### Types

option()
t()

### Functions

build(widget)

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

new(x1, y1, x2, y2)
new(id, x1, y1, x2, y2)

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

new(id, x1, y1, x2, y2, opts)

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

opacity(widget, descriptor)

Opacity from 0.0 to 1.0.

stroke(widget, descriptor)

Stroke descriptor.

type_name()

Returns the element type string for the wire protocol.

with_options(widget, opts)

Applies keyword options to an existing widget struct.

x1(widget, descriptor)

Start X in pixels.

x2(widget, descriptor)

End X in pixels.

y1(widget, descriptor)

Start Y in pixels.

y2(widget, descriptor)

End Y in pixels.

## Types

# option()

    @type option() ::
      (((({:x1, number()} | {:y1, number()}) | {:x2, number()}) | {:y2, number()})
       | {:stroke,
          %Plushie.Canvas.Stroke{
            cap: term(),
            color: term(),
            dash: term(),
            join: term(),
            width: term()
          }
          | keyword()
          | map()})
      | {:opacity, number()}

# t()

    @type t() :: %Plushie.Canvas.Line{
      id: String.t() | nil,
      opacity:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      stroke:
        %Plushie.Canvas.Stroke{
          cap: term(),
          color: term(),
          dash: term(),
          join: term(),
          width: term()
        }
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      x1:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      x2:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      y1:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      y2:
        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.

# new(x1, y1, x2, y2)

# new(id, x1, y1, x2, y2)

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

# new(id, x1, y1, x2, y2, 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()`.

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

Accepts `%Plushie.Canvas.Stroke{}`.

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

# x1(widget, descriptor)

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

Start X in pixels.

Accepts `number()`.

# x2(widget, descriptor)

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

End X in pixels.

Accepts `number()`.

# y1(widget, descriptor)

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

Start Y in pixels.

Accepts `number()`.

# y2(widget, descriptor)

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

End Y in pixels.

Accepts `number()`.