Visualize.Shape.Curve (Visualize v0.2.35)

Copy Markdown View Source

Curve interpolators for line and area generators.

Curves define how points are connected in a path.

Summary

Functions

Basis spline interpolation

The B-spline as a closed loop (spec/04 §5.3, #393): d3-shape's curveBasisClosed

Cardinal spline interpolation

The cardinal spline as a closed loop (spec/04 §5.3, #393): d3-shape's curveCardinalClosed

Catmull-Rom spline interpolation

Generates path commands for a list of points using the specified curve type.

Linear interpolation - straight lines between points

Monotone interpolation in x (preserves monotonicity)

Monotone interpolation in y (preserves monotonicity)

Natural cubic spline interpolation.

Step interpolation with configurable step position

Types

curve_type()

@type curve_type() ::
  :linear
  | :step
  | :step_before
  | :step_after
  | :basis
  | :cardinal
  | :catmull_rom
  | :monotone_x
  | :monotone_y
  | :natural
  | :cardinal_closed
  | :basis_closed

point()

@type point() :: {number(), number()}

Functions

basis(points)

@spec basis([point()]) :: Visualize.IR.Path.t()

Basis spline interpolation

basis_closed(points)

@spec basis_closed([point()]) :: Visualize.IR.Path.t()

The B-spline as a closed loop (spec/04 §5.3, #393): d3-shape's curveBasisClosed

cardinal(points, tension)

@spec cardinal([point()], number()) :: Visualize.IR.Path.t()

Cardinal spline interpolation

cardinal_closed(points, tension)

@spec cardinal_closed([point()], number()) :: Visualize.IR.Path.t()

The cardinal spline as a closed loop (spec/04 §5.3, #393): d3-shape's curveCardinalClosed

catmull_rom(points, alpha)

@spec catmull_rom([point()], number()) :: Visualize.IR.Path.t()

Catmull-Rom spline interpolation

generate(curve_type, points, opts \\ [])

@spec generate(curve_type(), [point()], keyword()) :: Visualize.IR.Path.t()

Generates path commands for a list of points using the specified curve type.

linear(list)

@spec linear([point()]) :: Visualize.IR.Path.t()

Linear interpolation - straight lines between points

monotone_x(points)

@spec monotone_x([point()]) :: Visualize.IR.Path.t()

Monotone interpolation in x (preserves monotonicity)

monotone_y(points)

@spec monotone_y([point()]) :: Visualize.IR.Path.t()

Monotone interpolation in y (preserves monotonicity)

natural(points)

@spec natural([point()]) :: Visualize.IR.Path.t()

Natural cubic spline interpolation.

The spline through every point with zero second derivative at both ends, as d3-shape's curveNatural. The Bézier control points come from the tridiagonal system solved by control_points/1, once for the x coordinates and once for the y coordinates.

step(list, t)

@spec step([point()], number()) :: Visualize.IR.Path.t()

Step interpolation with configurable step position