# `DalaDev.IconGenerator`
[🔗](https://github.com/manhvu/dala_dev/blob/main/lib/dala_dev/icon_generator.ex#L1)

Generates app icons for Android and iOS from either a random robot avatar
(using Avatarz) or a provided source image (using Image).

When the `image` dep is not available, falls back to the bundled Dala logo
(pre-built PNGs shipped with dala_dev, no system tools required).

## Android sizes (mipmap buckets)

  | Bucket      | px  |
  |-------------|-----|
  | mdpi        |  48 |
  | hdpi        |  72 |
  | xhdpi       |  96 |
  | xxhdpi      | 144 |
  | xxxhdpi     | 192 |

## iOS sizes (AppIcon.appiconset subset)

  | Usage                     | px   |
  |---------------------------|------|
  | iPhone Notification 2x    |  40  |
  | iPhone Notification 3x    |  60  |
  | iPhone Settings 2x        |  58  |
  | iPhone Settings 3x        |  87  |
  | iPhone Spotlight 2x       |  80  |
  | iPhone Spotlight 3x       | 120  |
  | iPhone App 2x             | 120  |
  | iPhone App 3x             | 180  |
  | iPad Notification 1x      |  20  |
  | iPad Notification 2x      |  40  |
  | iPad Settings 1x          |  29  |
  | iPad Settings 2x          |  58  |
  | iPad Spotlight 1x         |  40  |
  | iPad Spotlight 2x         |  80  |
  | iPad App 1x               |  76  |
  | iPad App 2x               | 152  |
  | iPad Pro App 2x           | 167  |
  | App Store                 |1024  |

# `adaptive_icon_xml`

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

Returns the XML body for `mipmap-anydpi-v26/ic_launcher.xml`.

Uses `@mipmap/ic_launcher_foreground` for the foreground and
`@color/ic_launcher_background` for the background.

# `adaptive_sizes`

```elixir
@spec adaptive_sizes() :: %{required(String.t()) =&gt; pos_integer()}
```

Returns the map of Android mipmap bucket names to pixel dimensions
for adaptive-icon foreground layers (108×108 dp scaled per density).

# `android_sizes`

```elixir
@spec android_sizes() :: %{required(String.t()) =&gt; pos_integer()}
```

Returns the map of Android mipmap bucket names to pixel dimensions
for legacy (single-layer) icons.

# `background_color_xml`

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

Returns the XML body for `values/ic_launcher_background.xml` defining
the adaptive icon background colour.

Accepts hex strings with or without a leading `#` (case-insensitive).
Raises `ArgumentError` for non-hex input.

# `generate_adaptive`

```elixir
@spec generate_adaptive(
  source_path :: String.t(),
  output_dir :: String.t(),
  keyword()
) :: :ok
```

Generates adaptive Android icons from a source image.

Writes:
  - `mipmap-anydpi-v26/ic_launcher.xml` + `ic_launcher_round.xml`
    referencing `@mipmap/ic_launcher_foreground` and
    `@color/ic_launcher_background`
  - `mipmap-<bucket>/ic_launcher_foreground.png` at the adaptive icon
    canvas size for each density bucket
  - `values/ic_launcher_background.xml` defining the background color

## Options
  * `:background_color` — hex string like `"#E8B53C"`. If absent, sampled
    from the source image at top-centre (10% from the top).

Legacy `ic_launcher.png`/`ic_launcher_round.png` are written separately
by `generate_from_source/2` for older Android versions.

# `generate_from_source`

```elixir
@spec generate_from_source(source_path :: String.t(), output_dir :: String.t()) :: :ok
```

Resizes an existing image at `source_path` to all platform icon sizes,
writing them into `output_dir`.

Returns `:ok`.

# `generate_random`

```elixir
@spec generate_random(output_dir :: String.t()) :: :ok
```

Generates a random robot avatar and writes platform icons into `output_dir`.

Creates:
  - `output_dir/android/app/src/main/res/<bucket>/ic_launcher.png` for each Android bucket
  - `output_dir/ios/Assets.xcassets/AppIcon.appiconset/icon_<px>.png` for each iOS size
  - `output_dir/icon_source.png` — the 1024×1024 master

Returns `:ok` on success.

# `ios_sizes`

```elixir
@spec ios_sizes() :: [pos_integer()]
```

Returns the list of iOS icon pixel dimensions.

# `use_dala_logo`

```elixir
@spec use_dala_logo(output_dir :: String.t()) :: :ok
```

Copies the bundled Dala logo (pre-built PNGs) to all platform icon directories
in `output_dir`. Used as the default placeholder icon by `mix dala.install`.
No extra dependencies or system tools required.

Returns `:ok`.

---

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