hps-0.1: Graphics/PS/Statistics.hs
module Graphics.PS.Statistics ( pathStatistics ) where
import Graphics.PS.Path
type Statistics = (Integer, Integer, Integer, Integer, Integer)
plus :: Statistics -> Statistics -> Statistics
plus (m1, l1, c1, g1, t1) (m2, l2, c2, g2, t2) =
(m1 + m2, l1 + l2, c1 + c2, g1 + g2, t1 + t2)
st :: Path -> Statistics
st (MoveTo _) = (1, 0, 0, 0, 0)
st (LineTo _) = (0, 1, 0, 0, 0)
st (CurveTo _ _ _) = (0, 0, 1, 0, 0)
st (Text _ s) = (0, 0, 0, fromIntegral (length s), 0)
st (PTransform _ p) = (0, 0, 0, 0, 1) `plus` st p
st (Join p1 p2) = st p1 `plus` st p2
pathStatistics :: Path -> Statistics
pathStatistics = st