hasmin-0.3.2.4: CSS Minifier

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

Hasmin.Types.TransformFunction

Description

CSS <transform-function> data type.

Synopsis

Documentation

data TransformFunction Source #

Instances

Eq TransformFunction Source # 
Show TransformFunction Source # 
ToText TransformFunction Source # 
Minifiable TransformFunction Source #

There are a series of equivalences to keep in mind: translate(0), translate3d(0, 0, 0), translateX(0), translateY(0), translateZ(0), scale(1), scaleX(1), scaleY(1), scaleZ(1), rotate(0), rotate3d(1,1,1,0), rotateX(0), rotateY(0), rotateZ(0), perspective(infinity), matrix(1,0,0,1,0,0), matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), skewX(0), skewY(0), and the shortest of them all: skew(0) All of these translate to the 4x4 identity matrix.

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 conmutative) Example: >>> import Control.Monad.Reader >>> let t10 = Translate (Right (Distance 10 PX)) Nothing >>> let tp = Translate (Left (Percentage 100)) Nothing >>> let s90 = Skew (Angle 90 Deg) 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)"] >>> fmap toText $ f [s45,tp,sx5,sx5,sx5] ["skew(45deg)","translate(100%)","scale(125)"]