Cauldron2D.Overlap (Cauldron2D v0.2.2)

Copy Markdown View Source

Whether placed shapes (Cauldron2D.Shape) touch each other, a point, a rectangle, a circle or a line.

Two shapes overlap when some world pixel's centre, {x + 0.5, y + 0.5}, lies inside both. A rectangle query is a shape like any other; a circle covers the pixel centres within its radius; a line is sampled every half pixel along its length, both ends included.

Cauldron2D.Overlap.shapes?(player, wall)
Cauldron2D.Overlap.line?(wall, {0, 10}, {200, 10})

Summary

Functions

Whether shape shares a pixel with the circle of radius around {x, y}.

Whether the segment from from to to passes through shape.

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

Whether shape shares a pixel with the rectangle {left, top, right, bottom}.

Whether first and second share a pixel.

Functions

circle?(shape, arg, radius)

@spec circle?(Cauldron2D.Shape.t(), {number(), number()}, number()) :: boolean()

Whether shape shares a pixel with the circle of radius around {x, y}.

line?(shape, from, arg)

@spec line?(Cauldron2D.Shape.t(), {number(), number()}, {number(), number()}) ::
  boolean()

Whether the segment from from to to passes through shape.

point?(shape, point)

@spec point?(Cauldron2D.Shape.t(), {number(), number()}) :: boolean()

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

rectangle?(shape, arg2)

@spec rectangle?(Cauldron2D.Shape.t(), {number(), number(), number(), number()}) ::
  boolean()

Whether shape shares a pixel with the rectangle {left, top, right, bottom}.

shapes?(first, second)

@spec shapes?(Cauldron2D.Shape.t(), Cauldron2D.Shape.t()) :: boolean()

Whether first and second share a pixel.