# `Macaw.Draw.Shape.Arc`
[🔗](https://github.com/dcoai/macaw_draw/blob/v0.1.0/lib/macaw/draw/shape/arc.ex#L1)

An annular sector, d3-shape's `arc` (spec/07 §6), copied from visualize's
`Visualize.Shape.Arc`.

Every parameter is an accessor evaluated against one datum (§1.1). Radii are user units;
angles are radians clockwise from 12 o'clock. The path is about the origin; callers
translate it. `pad_angle` narrows the sector at `pad_radius` (`√(r0² + r1²)` when
`nil`), and `corner_radius` rounds its four corners with tangent arcs.

    iex> alias Macaw.Draw.Shape.Arc
    iex> Arc.new() |> Arc.inner_radius(50) |> Arc.generate(%{start_angle: 0, end_angle: :math.pi() / 2})
    "M0,-100A100,100,0,0,1,100,0L50,0A50,50,0,0,0,0,-50Z"

`new/0` reads the datum's `:start_angle` (`0` when absent) and `:end_angle` (`2π` when
absent), so a `Macaw.Draw.Shape.Pie` arc datum is consumed directly. A zero outer radius
or extent, and a radius or angle that is not a number, is the empty path: nothing to
draw.

# `accessor`

```elixir
@type accessor() :: (term() -&gt; term()) | atom() | String.t() | number()
```

# `error`

```elixir
@type error() :: {:error, [Macaw.Base.Fault.t()]}
```

A refusal: faults with their paths.

# `t`

```elixir
@type t() :: %Macaw.Draw.Shape.Arc{
  corner_radius: (term() -&gt; term()) | number(),
  end_angle: (term() -&gt; term()) | nil,
  inner_radius: (term() -&gt; term()) | number(),
  outer_radius: (term() -&gt; term()) | nil,
  pad_angle: (term() -&gt; term()) | number(),
  pad_radius: (term() -&gt; term()) | nil,
  start_angle: (term() -&gt; term()) | nil
}
```

# `angles`

```elixir
@spec angles(t(), term()) :: {number() | nil, number() | nil} | error()
```

The `{start, end}` angles the accessors give for a datum; `nil` where one is no number.

# `centroid`

```elixir
@spec centroid(t(), term()) :: {float(), float()} | nil | error()
```

`{x, y}` at mid-radius and mid-angle; padding and corners do not move it. `nil` when a
radius or angle is no number.

# `corner_radius`

```elixir
@spec corner_radius(t(), accessor()) :: t() | error()
```

Sets the `corner_radius` accessor: a function, a field, or a number.

# `end_angle`

```elixir
@spec end_angle(t(), accessor()) :: t() | error()
```

Sets the `end_angle` accessor: a function, a field, or a number.

# `generate`

```elixir
@spec generate(t(), term()) :: String.t() | error()
```

The SVG path data of a datum's arc.

# `generate_path`

```elixir
@spec generate_path(t(), term()) :: Macaw.Draw.IR.Path.t() | error()
```

The `Macaw.Draw.IR.Path` of a datum's arc (§6.2).

# `inner_radius`

```elixir
@spec inner_radius(t(), accessor()) :: t() | error()
```

Sets the `inner_radius` accessor: a function, a field, or a number.

# `new`

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

An arc of outer radius 100, its angles read from the datum.

# `outer_radius`

```elixir
@spec outer_radius(t(), accessor()) :: t() | error()
```

Sets the `outer_radius` accessor: a function, a field, or a number.

# `pad_angle`

```elixir
@spec pad_angle(t(), accessor()) :: t() | error()
```

Sets the `pad_angle` accessor: a function, a field, or a number.

# `pad_radius`

```elixir
@spec pad_radius(t(), accessor() | nil) :: t() | error()
```

Sets the radius at which the pad angle is measured: the linear gap is
`pad_radius · pad_angle` on both rings. `nil` restores `√(r0² + r1²)`.

# `radii`

```elixir
@spec radii(t(), term()) :: {number() | nil, number() | nil} | error()
```

The `{inner, outer}` radii the accessors give for a datum; `nil` where one is no number.

# `start_angle`

```elixir
@spec start_angle(t(), accessor()) :: t() | error()
```

Sets the `start_angle` accessor: a function, a field, or a number.

---

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