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