module Diagrams.TwoD.Deform where
import Control.Lens
import Diagrams.Deform
import Linear.V2
import Linear.Vector
parallelX0 :: (R1 v, Num n) => Deformation v v n
parallelX0 = Deformation (_x .~ 0)
perspectiveX1 :: (R1 v, Functor v, Fractional n) => Deformation v v n
perspectiveX1 = Deformation $ \p -> p ^/ (p ^. _x)
parallelY0 :: (R2 v, Num n) => Deformation v v n
parallelY0 = Deformation (_y .~ 0)
perspectiveY1 :: (R2 v, Functor v, Floating n) => Deformation v v n
perspectiveY1 = Deformation $ \p -> p ^/ (p ^. _y)
facingX :: (R1 v, Functor v, Fractional n) => Deformation v v n
facingX = Deformation $
\p -> let x = p ^. _x
in p ^/ x & _x .~ x
facingY :: (R2 v, Functor v, Fractional n) => Deformation v v n
facingY = Deformation $
\p -> let y = p ^. _y
in p ^/ y & _y .~ y