Curves.Types (curves v1.0.1)

Copy Markdown View Source

A collection of typespecs to be used in other modules. There are no meaningful functions to be found here.

Summary

Types

define_opts/0, plus the :tension of Curves.define_cardinal/2.

define_opts/0, plus the :alpha of Curves.define_centripetal_catmull_rom/2.

A single number, represented as either x or y in 2D space

All 'define_*' functions can receive the following options

define_opts/0, plus the tilt and angles (in degrees) of Curves.define_ellipse/3.

define_opts/0, plus the three dials of Curves.define_kochanek_bartels/2.

A keyword list of options. See the Options section of Curves for the keys.

The order of a curve is (the number of control points) - 1. Although a more accurate definition might be "the depth of recursion when interpolating".

A list of {x, y} number coordinates

An {x, y} pair representing a coordinate in 2D space

t()

Float between 0.0 and 1.0, representing a percentage of progress from the first to last point.

Types

cardinal_opts()

@type cardinal_opts() :: [origin: point_tuple(), tension: number()]

define_opts/0, plus the :tension of Curves.define_cardinal/2.

centripetal_opts()

@type centripetal_opts() :: [origin: point_tuple(), alpha: number()]

define_opts/0, plus the :alpha of Curves.define_centripetal_catmull_rom/2.

coord()

@type coord() :: number()

A single number, represented as either x or y in 2D space

curve_struct()

Any curve: a Curves.Bezier.Curve, Curves.Spline.Curve or Curves.Polyline.Curve.

define_opts()

@type define_opts() :: [{:origin, point_tuple()}]

All 'define_*' functions can receive the following options:

keydefaultdescription
:origin{0, 0}Provides an offset. every point in the curve will automatically be increased by this {x, y} coordinate

ellipse_opts()

@type ellipse_opts() :: [
  origin: point_tuple(),
  rotation: number(),
  from: number(),
  to: number()
]

define_opts/0, plus the tilt and angles (in degrees) of Curves.define_ellipse/3.

kochanek_bartels_opts()

@type kochanek_bartels_opts() :: [
  origin: point_tuple(),
  tension: number(),
  continuity: number(),
  bias: number()
]

define_opts/0, plus the three dials of Curves.define_kochanek_bartels/2.

opts()

@type opts() :: keyword()

A keyword list of options. See the Options section of Curves for the keys.

order()

@type order() :: 1 | 2 | 3

The order of a curve is (the number of control points) - 1. Although a more accurate definition might be "the depth of recursion when interpolating".

Linear == 1
Quadratic == 2
Cubic == 3

So for example, if you have a straight line (formed from only 2 points) and want to find a new point at 50%, you are interpolating exactly 1 time to do so.

If you have a quadratic, with 3 points, you first interpolate between p0->p1 and p1->p2, thus creating two new dots. Then you recurse, creating a new line from those new dots, and interpolate again.

Cubic curves would recursively interpolate once more.

point_list()

@type point_list() :: [point_tuple()]

A list of {x, y} number coordinates

point_tuple()

@type point_tuple() :: {x :: coord(), y :: coord()}

An {x, y} pair representing a coordinate in 2D space

t()

@type t() :: float()

Float between 0.0 and 1.0, representing a percentage of progress from the first to last point.