smoothie-0.4.2: Smooth curves via several interpolation modes

Copyright(C) 2015 Dimitri Sabadie
MaintainerDimitri Sabadie <>
Safe HaskellNone




This module defines Splines and related functions. Because a Spline requires Keys, the Data.Spline.Key module is also exported.



data Spline a s Source

A Spline a s is a collection of Keys with associated interpolation modes.

Given two Keys which indices are i and i+1, the interpolation mode on the resulting curve is performed using the interpolation mode of the key i. Thus, the interpolation mode of the latest key might be ignored. There’s an exception, though, when using the Bezier interpolation mode. Feel free to dig in the Key documentation.


Functor a => Functor (Spline a) Source 
Eq (a s) => Eq (Spline a s) Source 
Show (a s) => Show (Spline a s) Source 
Generic (Spline a s) Source 
ToJSON (a s) => ToJSON (Spline a s) Source 
(FromJSON (a s), Ord s) => FromJSON ((a s -> s) -> Spline a s) Source 
type Rep (Spline a s) Source 

splineKeys :: Spline a s -> Vector (Key (a s)) Source

Extract the Keys.

Building splines

spline :: Ord s => (a s -> s) -> [Key (a s)] -> Spline a s Source

Build a Spline a s.

a s is the type held by Keys. For instance, V2 Float.

The first argument of the function, which has type a s -> s, is a function used to extract the sampling value of each Keys. In most cases, that value represents the time or the frame of a simulation. That value is used to perform sampling comparison.

Sampling splines

sample :: (Additive a, Floating s, Ord s) => (a s -> s) -> Spline a s -> s -> Maybe (a s) Source

Sample a Spline at a given s sampling value. If no sample exists, yields Nothing.

The first parameter is a sampler function used to extract a comparison value. For most curves, the reflected value should be the time or the frame.