# `Cauldron2D.Shape`
[🔗](https://github.com/jaman/cauldron/blob/v0.2.2/cauldron_2d/lib/cauldron_2d/shape.ex#L1)

A solid shape placed in world pixels, for collision.

`form` is `{:rectangle, width, height}`, every pixel solid, or `{:mask, mask}`, the
solid pixels of a `Cauldron2D.Mask`. It is placed as a picture is drawn by
`Cauldron2D.Blend.draw/6`: its `origin` lands on `position`, scaled per axis by
`scale` (negative mirrors) and turned by `angle` degrees counter-clockwise.

    shape = Cauldron2D.Shape.new({:mask, mask}, {120, 88}, origin: {9, 28}, scale: {-1, 1})
    Cauldron2D.Shape.contains?(shape, {121.5, 80.5})

A world point is inside the shape when the shape's pixel it falls on is solid; a
pixel covers `[x, x + 1)` by `[y, y + 1)` of the shape's own pixels.

# `form`

```elixir
@type form() :: {:rectangle, number(), number()} | {:mask, Cauldron2D.Mask.t()}
```

# `t`

```elixir
@type t() :: %Cauldron2D.Shape{
  cos: number(),
  form: form(),
  origin: {number(), number()},
  position: {number(), number()},
  scale: {number(), number()},
  sin: number()
}
```

# `bounds`

```elixir
@spec bounds(t()) :: {number(), number(), number(), number()} | nil
```

The world rectangle `{left, top, right, bottom}` the shape lies within; `nil` for a
shape scaled to nothing.

# `contains?`

```elixir
@spec contains?(t(), {number(), number()}) :: boolean()
```

Whether the world point `{x, y}` is inside the shape.

# `new`

```elixir
@spec new(form(), {number(), number()}, keyword()) :: t()
```

`form` placed at `position`, with `:origin`, `:scale` and `:angle` as above.

---

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