Module

Hylograph.Transition.Interpolate

Package
purescript-hylograph-transitions
Repository
afcondon/purescript-hylograph-transitions

Value Interpolation

Type-safe interpolation functions for various value types. Used with easing functions from Hylograph.Transition.Tick to create smooth transitions.

Usage:

import Hylograph.Transition.Interpolate as I
import Hylograph.Transition.Tick (easeOutQuad, withEasing)

-- Interpolate a color with easing
let color = withEasing easeOutQuad (I.lerpRGB red blue) progress

-- Interpolate a point
let pos = I.lerpPoint origin target progress

#Point Source

type Point = { x :: Number, y :: Number }

2D point

#lerpPoint Source

lerpPoint :: Point -> Point -> Progress -> Point

Linear interpolation between two points

#lerpPointXY Source

lerpPointXY :: { fromX :: Number, fromY :: Number } -> { toX :: Number, toY :: Number } -> { progressX :: Progress, progressY :: Progress } -> Point

Interpolate x and y separately (for asymmetric easing)

#RGB Source

newtype RGB

RGB color with components in 0-255 range

Constructors

Instances

#lerpRGB Source

lerpRGB :: RGB -> RGB -> Progress -> RGB

Linear interpolation in RGB space Note: For perceptually uniform transitions, consider lerpHSL

#rgbToCSS Source

rgbToCSS :: RGB -> String

Convert RGB to CSS color string

#cssToRGB Source

cssToRGB :: String -> Maybe RGB

Parse CSS rgb() or hex color to RGB Supports: rgb(r,g,b), #RRGGBB, #RGB

#HSL Source

newtype HSL

HSL color h: hue in degrees (0-360) s: saturation (0-1) l: lightness (0-1)

Constructors

Instances

#lerpHSL Source

lerpHSL :: HSL -> HSL -> Progress -> HSL

Linear interpolation in HSL space Takes the shortest path around the hue circle

#hslToCSS Source

hslToCSS :: HSL -> String

Convert HSL to CSS color string

#hslToRGB Source

hslToRGB :: HSL -> RGB

Convert HSL to RGB

#rgbToHSL Source

rgbToHSL :: RGB -> HSL

Convert RGB to HSL

#Interpolatable Source

class Interpolatable a  where

Typeclass for types that can be interpolated

Members

Instances

#Interpolator Source

type Interpolator a = a -> a -> Progress -> a

An interpolation function between two values

#makeInterpolator Source

makeInterpolator :: forall a. Interpolatable a => a -> a -> (Progress -> a)

Create an interpolator that captures the start and end values