Remove RenderType datatype
This commit is contained in:
+8
-75
@@ -19,89 +19,22 @@ import Control.Lens
|
||||
--import Control.Monad
|
||||
|
||||
data Verx = Verx
|
||||
{ _vxPos :: Point3
|
||||
, _vxCol :: Point4
|
||||
, _vxType :: VertexType
|
||||
, _vxLayer :: Int
|
||||
{ _vxPos :: !Point3
|
||||
, _vxCol :: !Point4
|
||||
, _vxType :: !VertexType
|
||||
, _vxLayer :: !Int
|
||||
}
|
||||
data VertexType
|
||||
= PolyV
|
||||
| PolyzV Float
|
||||
| BezV Point4
|
||||
| TextV Point2
|
||||
| ArcV Point3
|
||||
| PolyzV !Float
|
||||
| BezV !Point4
|
||||
| TextV !Point2
|
||||
| ArcV !Point3
|
||||
| EllV
|
||||
|
||||
data RenderType
|
||||
-- -= RenderPoly [(Point3,Point4)]
|
||||
-- -| RenderPolyZ [(Point3,Point4,Float)]
|
||||
-- -| RenderBezQ [(Point3,Point4,Point4)]
|
||||
-- -| RenderText [(Point3,Point4,Point2)]
|
||||
-- -| RenderArc [(Point3,Point4,Point3)]
|
||||
-- -| RenderEllipse [(Point3,Point4)]
|
||||
= Render3 [Point3]
|
||||
| Render1111 {_unRender1111 :: (Float,Float,Float,Float)}
|
||||
| Render22 {_unRender22 :: (Point2,Point2)}
|
||||
| Render2221 {_unRender2221 :: (Point2,Point2,Point2,Float)}
|
||||
| Render22x4 {_unRender22x4 :: ((Point2,Point2),Point4)}
|
||||
| Render3x2 {_unRender3x2 :: (Point3,Point2)}
|
||||
| Render3x3 {_unRender3x3 :: (Point3,Point3)}
|
||||
deriving Generic
|
||||
instance NFData RenderType
|
||||
|
||||
type RGBA = Point4
|
||||
type Color = Point4
|
||||
|
||||
data FTree a
|
||||
= FBranch (a -> a) (FTree a)
|
||||
| FBranches [FTree a]
|
||||
| FLeaf a
|
||||
instance Foldable FTree where
|
||||
foldMap g (FBranch f t) = foldMap (g . f) t
|
||||
foldMap g (FBranches ts) = mconcat $ map (foldMap g) ts
|
||||
foldMap g (FLeaf x) = g x
|
||||
{-# INLINE foldMap #-}
|
||||
instance Functor FTree where
|
||||
fmap g (FBranch f t) = fmap (g . f) t
|
||||
fmap f (FBranches ts) = FBranches $ fmap (fmap f) ts
|
||||
fmap f (FLeaf x) = FLeaf (f x)
|
||||
{-# INLINE fmap #-}
|
||||
|
||||
{- Tree with values at and only at the leaves. -}
|
||||
data LTree a
|
||||
= LBranches [LTree a]
|
||||
| LLeaf a
|
||||
deriving (Generic)
|
||||
instance NFData a => NFData (LTree a)
|
||||
instance Foldable LTree where
|
||||
foldMap g (LBranches ts) = mconcat $ map (foldMap g) ts
|
||||
foldMap g (LLeaf a) = g a
|
||||
{-# INLINE foldMap #-}
|
||||
foldr _ x (LBranches []) = x
|
||||
--foldr g x (LBranches (t:ts)) = foldr g x t `seq` foldr g (foldr g x t) (LBranches ts)
|
||||
foldr g x (LBranches (t:ts)) = foldr g (foldr g x t) (LBranches ts)
|
||||
--foldr g x (LBranches (t:ts)) = foldr g (foldr g x (LBranches ts)) t
|
||||
foldr g x (LLeaf y) = g y x
|
||||
{-# INLINE foldr #-}
|
||||
foldl' _ x (LBranches []) = x
|
||||
foldl' g x (LBranches (t:ts)) = foldl' g x t `seq` foldl' g (foldl' g x t) (LBranches ts)
|
||||
foldl' g x (LLeaf y) = g x y
|
||||
{-# INLINE foldl' #-}
|
||||
instance Functor LTree where
|
||||
fmap f (LBranches ts) = LBranches $ fmap (fmap f) ts
|
||||
fmap f (LLeaf x) = LLeaf (f x)
|
||||
{-# INLINE fmap #-}
|
||||
|
||||
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 :: V2 a -> [a]
|
||||
flat2 (V2 x y) = [x,y]
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
module Picture.Texture
|
||||
where
|
||||
import Geometry.Data
|
||||
--import Geometry
|
||||
import Picture.Data
|
||||
--import Data.Tile
|
||||
|
||||
tileToRender :: [Point3] -> [Point3] -> [RenderType]
|
||||
tileToRender [a,b,c,d] [x,y,z,w] =
|
||||
[ Render3x3 (x,a)
|
||||
, Render3x3 (y,b)
|
||||
, Render3x3 (z,c)
|
||||
, Render3x3 (x,a)
|
||||
, Render3x3 (z,c)
|
||||
, Render3x3 (w,d)
|
||||
]
|
||||
tileToRender _ _ = undefined
|
||||
|
||||
Reference in New Issue
Block a user