packages feed

diagrams-lib-1.2.0.5 / src / Diagrams / TwoD / Deform.hs

module Diagrams.TwoD.Deform whereimport Control.Lensimport Diagrams.Deformimport Diagrams.Coordinatesimport Diagrams.TwoD.Types-- | The parallel projection onto the line x=0parallelX0 :: Deformation R2parallelX0 = Deformation (& _x .~ 0)-- | The perspective division onto the line x=1 along lines going-- through the origin.perspectiveX1 :: Deformation R2perspectiveX1 = Deformation (\p -> p & _y //~ (p^._x) & _x .~ 1)-- | The parallel projection onto the line y=0parallelY0 :: Deformation R2parallelY0 = Deformation (& _y .~ 0)-- | The perspective division onto the line y=1 along lines going-- through the origin.perspectiveY1 :: Deformation R2perspectiveY1 = Deformation (\p -> p & _x //~ (p^._y) & _y .~ 1)-- | The viewing transform for a viewer facing along the positive X-- axis.  X coördinates stay fixed, while Y coördinates are compressed-- with increasing distance.  @asDeformation (translation unitX) <>-- parallelX0 <> frustrumX = perspectiveX1@facingX :: Deformation R2facingX = Deformation (\v -> v & _y //~ (v^._x))facingY :: Deformation R2facingY = Deformation (\v -> v & _x //~ (v^._y))