Search documentation of Plushie

# Plushie.Type.Shadow (Plushie v0.7.2)

Copy Markdown View Source

Shadow type for widget styling.

Used in `container` and other widgets via the `shadow` prop. The renderer parses shadow into `iced::Shadow`.

## Wire format

    %{color: "#00000080", offset: [4, 4], blur_radius: 8.0}

The `offset` is an `[x, y]` list. `color` is a hex string (see `Plushie.Type.Color`).

## Example

    shadow = Plushie.Type.Shadow.new()
             |> Plushie.Type.Shadow.color("#00000040")
             |> Plushie.Type.Shadow.offset(2, 2)
             |> Plushie.Type.Shadow.blur_radius(6)

## Summary

### Types

t()

### Functions

blur_radius(shadow, r)

Sets the shadow blur radius in pixels.

cast(shadow)

Validates a shadow value.

color(shadow, color)

Sets the shadow color. Accepts a hex string or named color atom.

from_opts(opts)

Constructs a `Shadow` from a keyword list.

new()

Creates a new shadow with default values.

offset(shadow, x, y)

Sets the shadow offset in pixels.

## Types

# t()

    @type t() :: %Plushie.Type.Shadow{
      blur_radius: number(),
      color: Plushie.Type.Color.t(),
      offset_x: number(),
      offset_y: number()
    }

## Functions

# blur_radius(shadow, r)

    @spec blur_radius(shadow :: t(), r :: number()) :: t()

Sets the shadow blur radius in pixels.

# cast(shadow)

    @spec cast(term()) :: {:ok, t()} | :error

Validates a shadow value.

Accepts a `%Shadow{}` struct or a map with shadow fields.

## Examples

    iex> Plushie.Type.Shadow.cast(%Plushie.Type.Shadow{blur_radius: 4})
    {:ok, %Plushie.Type.Shadow{blur_radius: 4}}

# color(shadow, color)

    @spec color(shadow :: t(), color :: Plushie.Type.Color.input()) :: t()

Sets the shadow color. Accepts a hex string or named color atom.

# from_opts(opts)

    @spec from_opts(opts :: keyword()) :: t()

Constructs a `Shadow` from a keyword list.

# new()

    @spec new() :: t()

Creates a new shadow with default values.

# offset(shadow, x, y)

    @spec offset(shadow :: t(), x :: number(), y :: number()) :: t()

Sets the shadow offset in pixels.