Copyright | (c) 2017 Cristian Adrián Ontivero |
---|---|
License | BSD3 |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
CSS <transform-function> data type.
- data TransformFunction
- = Mat (Matrix Number)
- | Mat3d (Matrix Number)
- | Perspective Distance
- | Rotate Angle
- | Rotate3d Number Number Number Angle
- | RotateX Angle
- | RotateY Angle
- | RotateZ Angle
- | Scale Number (Maybe Number)
- | Scale3d Number Number Number
- | ScaleX Number
- | ScaleY Number
- | ScaleZ Number
- | Skew Angle (Maybe Angle)
- | SkewX Angle
- | SkewY Angle
- | Translate PercentageLength (Maybe PercentageLength)
- | Translate3d PercentageLength PercentageLength Distance
- | TranslateX PercentageLength
- | TranslateY PercentageLength
- | TranslateZ Distance
- mkMat :: [Number] -> TransformFunction
- mkMat3d :: [Number] -> TransformFunction
- combine :: [TransformFunction] -> Reader Config [TransformFunction]
Documentation
data TransformFunction Source #
Mat (Matrix Number) | |
Mat3d (Matrix Number) | |
Perspective Distance | |
Rotate Angle | |
Rotate3d Number Number Number Angle | |
RotateX Angle | |
RotateY Angle | |
RotateZ Angle | |
Scale Number (Maybe Number) | |
Scale3d Number Number Number | |
ScaleX Number | |
ScaleY Number | |
ScaleZ Number | |
Skew Angle (Maybe Angle) | |
SkewX Angle | |
SkewY Angle | |
Translate PercentageLength (Maybe PercentageLength) | |
Translate3d PercentageLength PercentageLength Distance | |
TranslateX PercentageLength | |
TranslateY PercentageLength | |
TranslateZ Distance |
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. |
mkMat :: [Number] -> TransformFunction Source #
mkMat3d :: [Number] -> TransformFunction Source #
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)"]