Do layer checking in picture tree

This commit is contained in:
2021-03-01 13:46:28 +01:00
parent f68b8be9ce
commit 1e198b551e
4 changed files with 55 additions and 37 deletions
+12
View File
@@ -36,6 +36,17 @@ instance Functor LTree where
fmap f (LBranches ts) = LBranches $ (fmap (fmap f)) ts
fmap f (LLeaf x) = LLeaf (f x)
data RTree a b
= RBranches a [RTree a b]
| RLeaf b
instance Foldable (RTree a) where
foldMap g (RBranches _ ts) = mconcat $ map (foldMap g) ts
foldMap g (RLeaf x) = g x
{-# INLINE foldMap #-}
instance Functor (RTree a) where
fmap f (RBranches i ts) = RBranches i $ (fmap (fmap f)) ts
fmap f (RLeaf x) = RLeaf (f x)
flat2 (x,y) = [x,y]
flat3 (x,y,z) = [x,y,z]
@@ -67,6 +78,7 @@ data Picture
| Color RGBA Picture
| Pictures [Picture]
| OverPic (Point3 -> Point3) (Float -> Float) (Point4 -> Point4) Picture
| OnLayer Int Picture
blank :: Picture