Crate simple_bezier_easing

Crate simple_bezier_easing 

Source
Expand description

This module provides functions and utilities for calculating cubic Bézier curves using De Casteljau’s algorithm. It includes robust error handling for invalid control points and supports binary subdivision to efficiently determine the parameter t corresponding to a given x-coordinate on the curve.

§Key Features

  • Cubic Bézier Curve Calculation: Computes the y-coordinate for any given x-coordinate based on the specified control points using De Casteljau’s algorithm.
  • Error Handling: Returns detailed errors if the control points are outside the valid range [0, 1] or if the binary subdivision fails to converge within the allowed iterations.
  • Binary Subdivision: Utilizes binary subdivision to efficiently find the parameter t for a given x-coordinate, ensuring accurate results even for complex curves.
  • Precision Control: Allows customization of the precision for the binary subdivision process and handles edge cases gracefully, such as very small slopes or extreme control point values.

Structs§

Point
A simple 2D point represented as (x, y).

Enums§

BezierError
Custom errors for handling Bézier curve computations.

Functions§

bezier
Creates a cubic Bézier curve function based on the given control points.