module Graphics.PS.Transform (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

class Transformable a where
    transform :: Matrix -> a -> a

translate :: (Transformable a) => Double -> Double -> a -> a
translate x = transform . translation x

scale :: (Transformable a) => Double -> Double -> a -> a
scale x = transform . scaling x

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)

--}