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

A point symbol of a given area (spec/07 §9), copied from visualize's
`Visualize.Shape.Symbol`.

`type` is a symbol type, read by spelling (an atom or its string), or a 1-arity
function of the datum answering one; `size` is a number in **square user units** or a
1-arity function answering one. Every path is about the origin.

    iex> alias Macaw.Draw.Shape.Symbol
    iex> {:ok, square} = Symbol.type(Symbol.new(), "square")
    iex> square |> Symbol.size(16) |> Symbol.generate()
    "M-2,-2L2,-2L2,2L-2,2Z"

Only `:circle` and `:square` have area exactly `size`; the others are sized so their
bounding area is about it. `type/2` refuses a name none of `types/0` spells as
`{[], {:unknown, :symbol, spelling}}`; a function type answering an unknown name, and a
size that is not a non-negative number, draw the empty path for that datum.

# `error`

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

A refusal: faults with their paths.

# `symbol_type`

```elixir
@type symbol_type() ::
  :circle | :cross | :diamond | :square | :star | :triangle | :wye
```

# `t`

```elixir
@type t() :: %Macaw.Draw.Shape.Symbol{
  size: number() | (term() -&gt; term()),
  type: symbol_type() | (term() -&gt; term())
}
```

# `generate`

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

The path data with `nil` as the datum.

# `generate`

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

The SVG path data of a datum's symbol.

# `generate_path`

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

The `Macaw.Draw.IR.Path` of a datum's symbol (§9).

# `new`

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

A `:circle` of size 64.

# `size`

```elixir
@spec size(t(), number() | (term() -&gt; term())) :: t() | error()
```

Sets the size, an area in square user units, or a function of the datum.

# `type`

```elixir
@spec type(t(), term()) :: {:ok, t()} | error()
```

Sets the type: a name read by spelling, or a function: `{:ok, symbol}` or `{:error, faults}`.

# `type!`

```elixir
@spec type!(t(), term()) :: t()
```

As `type/2`, the symbol itself, raising `Macaw.Draw.Error` with its faults.

# `types`

```elixir
@spec types() :: [symbol_type()]
```

The seven symbol types.

---

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