> module Pic where > import Picture > data Pic s = EmptyPic > | Above (Pic s) (Pic s) > | Prim s > | Prop Property (Pic s) > instance HasVert s => HasVert (Pic s) where > vertMap f EmptyPic = EmptyPic > vertMap f (Prim s) = Prim (vertMap f s) > vertMap f (Prop pr p) = Prop pr (vertMap f p) > vertMap f (Above p q) = Above (vertMap f p) (vertMap f q) > bbox EmptyPic = Nothing > bbox (Prim s) = bbox s > bbox (Prop _ p) = bbox p > bbox (Above p q) = case bbox p of > Nothing -> bbox q > b1@(Just (p1,p2)) -> case bbox q of > Nothing -> b1 > Just (p3,p4) -> Just $ vertList_bb [p1,p2,p3,p4] > toOrigin p = case bbox p of > Nothing -> p > Just (ll,ru) -> vertMap (^-^ ll) p > instance Picture Pic where > emptyPic = EmptyPic > above = Above > prim = Prim > setProp = Prop