hasmin-1.0.2: CSS Minifier

Copyright(c) 2017 Cristian Adrián Ontivero
LicenseBSD3
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Hasmin.Types.TransformFunction

Description

 

Synopsis

Documentation

combine :: [TransformFunction] -> Reader Config [TransformFunction] Source #

Combines consecutive <transform-functions> whenever possible, leaving translate functions that can't be converted to a matrix (because they use percentages or relative units) as they are, in the position they are in the list (since matrix multiplication isn't commutative) Example:

>>> import Control.Monad.Reader
>>> let t10 = Translate (Right (Length 10 PX)) Nothing
>>> let s45 = Skew (Angle 45 Deg) Nothing
>>> let sx5 = ScaleX 5
>>> let f x = runReader (combine x) defaultConfig
>>> fmap toText $ f [t10, s45, sx5]
["matrix(5,0,1,1,10,0)"]
>>> let tp  = Translate (Left (Percentage 100)) Nothing
>>> fmap toText $ f [s45,tp,sx5,sx5,sx5]
["skew(45deg)","translate(100%)","scale(125)"]

simplify :: TransformFunction -> Reader Config TransformFunction Source #

Simplifies a <transform-function> without converting it to a 4x4 matrix, by doing some simple conversions between the different functions, or minifying the dimension arguments (<length> and <angle> values)