hps-0.11: Graphics/PS/Transform.hs
-- | Class and associated functions for 'Matrix' transformations.
module Graphics.PS.Transform (Transformable
,translate, scale, rotate) where
import Graphics.PS.Matrix
import Graphics.PS.Pt
import qualified Graphics.PS.Path as P
import qualified Graphics.PS.Image as I
-- | Values that can be transformed in relation to a 'Matrix'.
class Transformable a where
transform :: Matrix -> a -> a
-- | Translation in /x/ and /y/.
translate :: (Transformable a) => Double -> Double -> a -> a
translate x = transform . translation x
-- | Scaling in /x/ and /y/.
scale :: (Transformable a) => Double -> Double -> a -> a
scale x = transform . scaling x
-- | Rotation, in radians.
rotate :: (Transformable a) => Double -> a -> a
rotate = transform . rotation
instance Transformable I.Image where
transform = I.ITransform
instance Transformable P.Path where
transform = P.PTransform
instance Transformable Pt where
transform = ptTransform
{--
import Graphics.PS.Pt
-- | Polar variant.
pTranslate :: (Transform a) => Double -> Double -> a -> a
pTranslate r t = translate x y
where (Pt x y) = polarToRectangular (Pt r t)
--}