splines
splines - popular parametric splines for Gleam.
Splines are often used in graphics, simulations and games. They can be used to approximate curved figures, define paths for objects to move along, or shape the behavior of kinematics.
splines defines several popular spline kinds:
- B-splines, often used for smooth paths that require strong continuity
- Beziér splines, often used for curved figures
- Catmull-Rom splines, often used for smooth paths that pass through the knots
Other splines may be added in the future.
Types
Values
pub fn basis_2d(
points: List(vec2.Vec2(Float)),
) -> Result(
Spline(b.BSpline(vec2.Vec2(Float)), vec2.Vec2(Float)),
Nil,
)
Constructs a sequence of cubic B-spline curves in 2d.
The list of points must be at least of length 4.
pub fn basis_3d(
points: List(vec3.Vec3(Float)),
) -> Result(
Spline(b.BSpline(vec3.Vec3(Float)), vec3.Vec3(Float)),
Nil,
)
Constructs a sequence of cubic B-spline curves in 3d.
The list of points must be at least of length 4.
pub fn bezier_2d(
points: List(vec2.Vec2(Float)),
) -> Result(
Spline(bezier.Bezier(vec2.Vec2(Float)), vec2.Vec2(Float)),
Nil,
)
Constructs a sequence of cubic Beziér curves in 3d, where every segment has two control points and the curves are C0 continuous (share knots).
The list of points must be at least of length 4, and have multiples of 3 beyond the first 4.
pub fn bezier_3d(
points: List(vec3.Vec3(Float)),
) -> Result(
Spline(bezier.Bezier(vec3.Vec3(Float)), vec3.Vec3(Float)),
Nil,
)
Constructs a sequence of cubic Beziér curves in 3d, where every segment has two control points and the curves are C0 continuous (share knots).
The list of points must be at least of length 4, and have multiples of 3 beyond the first 4.
pub fn catmull_rom_2d(
points: List(vec2.Vec2(Float)),
) -> Result(
Spline(
catmull_rom.CatmullRom(vec2.Vec2(Float)),
vec2.Vec2(Float),
),
Nil,
)
Constructs a sequence of Catmull-Rom curves in 2d, where the curve passes through all but the first and last points in the sequence.
The list of points must be at least of length 4.
pub fn catmull_rom_3d(
points: List(vec3.Vec3(Float)),
) -> Result(
Spline(
catmull_rom.CatmullRom(vec3.Vec3(Float)),
vec3.Vec3(Float),
),
Nil,
)
Constructs a sequence of Catmull-Rom curves in 3d, where the curve passes through all but the first and last points in the sequence.
The list of points must be at least of length 4.