[Spiral] misc tidying

This commit is contained in:
joe.thornber 2007-05-24 08:55:37 +00:00
parent 43c7f8f3ec
commit aa4d37d8ac

View File

@ -18,18 +18,19 @@ import XMonad
fibs :: [Integer] fibs :: [Integer]
fibs = 1 : 1 : (zipWith (+) fibs (tail fibs)) fibs = 1 : 1 : (zipWith (+) fibs (tail fibs))
fibRatios :: [Rational] mkRatios :: [Integer] -> [Rational]
fibRatios = ratios fibs mkRatios (x1:x2:xs) = (x1 % x2) : mkRatios (x2:xs)
where mkRatios _ = []
ratios (x:y:rs) = (x % y) : ratios (y:rs)
ratios _ = []
spiral :: Rational -> Layout spiral :: Rational -> Layout
spiral scale = Layout { doLayout = fibLayout, spiral scale = Layout { doLayout = fibLayout,
modifyLayout = \m -> fmap resize (fromMessage m) } modifyLayout = \m -> fmap resize (fromMessage m) }
where where
fibLayout sc ws = return $ zip ws (divideRects (map (* scale) . reverse . take len $ fibRatios) len East sc) fibLayout sc ws = return $ zip ws rects
where len = length ws where len = length ws
ratios = map (* scale) . reverse . take len . mkRatios $ fibs
rects = divideRects ratios len East sc
resize Expand = spiral $ (11 % 10) * scale resize Expand = spiral $ (11 % 10) * scale
resize Shrink = spiral $ (10 % 11) * scale resize Shrink = spiral $ (10 % 11) * scale