# `Alaja.Structures.EffectInfo`
[🔗](https://github.com/Lorenzo-SF/alaja/blob/2.1.0/lib/alaja/structures/effect_info.ex#L1)

Structure that defines text effects applicable in terminal.

Represents a collection of visual effects (bold, italic, underline, etc.)
that can be applied to text when rendering to terminal.

## Examples

    iex> EffectInfo.new(:bold)
    %EffectInfo{bold: true, dim: false, ...}

    iex> EffectInfo.new([:bold, :underline])
    %EffectInfo{bold: true, underline: true, ...}

    iex> EffectInfo.to_ansi(EffectInfo.new([:bold, :italic]))
    "\e[1;3m"

# `t`

```elixir
@type t() :: %Alaja.Structures.EffectInfo{
  blink: boolean(),
  bold: boolean(),
  dim: boolean(),
  hidden: boolean(),
  invert: boolean(),
  italic: boolean(),
  link: String.t() | nil,
  reverse: boolean(),
  strikethrough: boolean(),
  underline: boolean()
}
```

# `combine`

```elixir
@spec combine(any(), any()) :: any()
```

Combines two EffectInfo structures.

Effects are combined using OR logic - if either has an effect enabled,
the result will have it enabled.

## Examples

    iex> e1 = EffectInfo.new(:bold)
    iex> e2 = EffectInfo.new(:italic)
    iex> EffectInfo.combine(e1, e2)
    %EffectInfo{bold: true, italic: true, ...}

# `new`

```elixir
@spec new() :: t()
```

Creates a new empty EffectInfo structure.

## Examples

    iex> EffectInfo.new()
    %EffectInfo{bold: false, dim: false, ...}

# `new`

```elixir
@spec new(atom() | [atom()] | String.t() | t() | map()) :: t()
```

Creates a new EffectInfo from various inputs.

## Parameters

- `effect` - Can be:
  - An atom (`:bold`, `:italic`, etc.)
  - A list of atoms
  - A URL string (creates link effect)
  - An existing EffectInfo struct
  - A map with effect fields

## Examples

    iex> EffectInfo.new(:bold)
    %EffectInfo{bold: true, ...}

    iex> EffectInfo.new([:bold, :underline])
    %EffectInfo{bold: true, underline: true, ...}

    iex> EffectInfo.new("https://example.com")
    %EffectInfo{link: "https://example.com"}

# `optimal_fg_color`

```elixir
@spec optimal_fg_color({integer(), integer(), integer()}) ::
  {integer(), integer(), integer()}
```

Calculates the optimal foreground color for a given background color.

Uses brightness (luminance) to determine whether to use white or black
for best contrast.

## Examples

    iex> EffectInfo.optimal_fg_color({255, 255, 255})
    {0, 0, 0}

    iex> EffectInfo.optimal_fg_color({0, 0, 0})
    {255, 255, 255}

# `to_ansi`

```elixir
@spec to_ansi(t()) :: String.t()
```

Converts EffectInfo to ANSI escape codes.

## Examples

    iex> EffectInfo.to_ansi(EffectInfo.new([:bold, :underline]))
    "\e[1;4m"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
