{- |
Uniform management of layers and depths on which pictures are drawn. -}
module Dodge.Picture.Layer
    ( onLayer
    , onLayerL
    , levLayer
    , Layer (..)
    ) where
import Dodge.Picture.Layer.Data
import Picture
{- | Uses a layer to set the depth.  -}
onLayer :: Layer -> Picture -> Picture
onLayer l = setDepth $ (1 - fromIntegral (levLayer l) / 100) / 1000
{- | Set a depth according to a list of numbers.
Lists are lexicographically ordered if input values are always less than 100.
Higher numbers will get placed on top of lower numbers.  -}
onLayerL :: [Int] -> Picture -> Picture
onLayerL is = setDepth $ (1 - sum (zipWith (/) (map fromIntegral is) $ map (100 **) [1..])) / 1000
{- | For depth testing, set layer values.  -}
levLayer :: Layer -> Int
levLayer BgLayer            = 20
levLayer PressPlateLayer    = 45
levLayer CorpseLayer        = 50
levLayer FlItLayer          = 55
levLayer CrLayer            = 60
levLayer WlLayer            = 74
levLayer GloomLayer         = 67
levLayer UPtLayer           = 70
levLayer PtLayer            = 72
levLayer HPtLayer           = 73
levLayer ShadowLayer        = 75   
levLayer LabelLayer         = 80
levLayer InvLayer           = 85
levLayer MenuDepth          = 90
levLayer DebugLayer         = 99
