smoothie- 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 # 


fmap :: (a -> b) -> Spline a a -> Spline a b #

(<$) :: a -> Spline a b -> Spline a a #

Eq (a s) => Eq (Spline a s) Source # 


(==) :: Spline a s -> Spline a s -> Bool #

(/=) :: Spline a s -> Spline a s -> Bool #

Show (a s) => Show (Spline a s) Source # 


showsPrec :: Int -> Spline a s -> ShowS #

show :: Spline a s -> String #

showList :: [Spline a s] -> ShowS #

Generic (Spline a s) Source # 

Associated Types

type Rep (Spline a s) :: * -> * #


from :: Spline a s -> Rep (Spline a s) x #

to :: Rep (Spline a s) x -> Spline a s #

ToJSON (a s) => ToJSON (Spline a s) Source # 


toJSON :: Spline a s -> Value #

toEncoding :: Spline a s -> Encoding #

toJSONList :: [Spline a s] -> Value #

toEncodingList :: [Spline a s] -> Encoding #

(FromJSON (a s), Ord s) => FromJSON ((a s -> s) -> Spline a s) Source # 


parseJSON :: Value -> Parser ((a s -> s) -> Spline a s) #

parseJSONList :: Value -> Parser [(a s -> s) -> Spline a s] #

type Rep (Spline a s) Source # 
type Rep (Spline a s) = D1 (MetaData "Spline" "Data.Spline.Curve" "smoothie-" True) (C1 (MetaCons "Spline" PrefixI True) (S1 (MetaSel (Just Symbol "splineKeys") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vector (Key (a s))))))

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.