summaryrefslogtreecommitdiff
path: root/lc
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-05 00:34:35 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-05 00:34:35 +0100
commit98cd7ed424454502d98aafe193b8cda61ef3b692 (patch)
tree72ddd252f7080f7aaf91200c2c2db821860b2352 /lc
parentde0f0691a15c1551cf315274f89584594f89481c (diff)
better Fragment data type
Diffstat (limited to 'lc')
-rw-r--r--lc/Builtins.lc34
-rw-r--r--lc/Prelude.lc6
2 files changed, 22 insertions, 18 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc
index e123b4bd..c1991a2b 100644
--- a/lc/Builtins.lc
+++ b/lc/Builtins.lc
@@ -346,10 +346,19 @@ type family RemSemantics a where
346 346
347------------------- 347-------------------
348 348
349data Maybe a
350 = Nothing
351 | Just a
352-- deriving (Eq, Ord, Show)
353
349data Vector (n :: Nat) t 354data Vector (n :: Nat) t
350 355
351data Fragment (l :: Nat) t 356type Fragment n t = Vector n (Maybe (SimpleFragment t))
352 = Fragment (Vec 3 Float) (Vector l t) 357
358data SimpleFragment t = SimpleFragment
359 { sFragmentCoords :: Vec 3 Float
360 , sFragmentValue :: t
361 }
353 362
354type FragmentStream n t = Stream (Fragment n t) 363type FragmentStream n t = Stream (Fragment n t)
355 364
@@ -358,6 +367,17 @@ customizeDepth :: (a -> Float) -> Fragment n a -> Fragment n a
358customizeDepths :: (a -> Float) -> FragmentStream n a -> FragmentStream n a 367customizeDepths :: (a -> Float) -> FragmentStream n a -> FragmentStream n a
359customizeDepths f = mapStream (customizeDepth f) 368customizeDepths f = mapStream (customizeDepth f)
360 369
370filterFragment :: (a -> Bool) -> Fragment n a -> Fragment n a
371
372filterFragments :: (a -> Bool) -> FragmentStream n a -> FragmentStream n a
373filterFragments p = mapStream (filterFragment p)
374
375mapFragment :: (a -> b) -> Fragment n a -> Fragment n b
376
377mapFragments :: (a -> b) -> FragmentStream n a -> FragmentStream n b
378mapFragments f = mapStream (mapFragment f)
379
380
361data Interpolated t where 381data Interpolated t where
362 Smooth, NoPerspective 382 Smooth, NoPerspective
363 :: (Floating t) => Interpolated t 383 :: (Floating t) => Interpolated t
@@ -380,16 +400,6 @@ rasterize
380rasterizePrimitives ctx is = concatMapStream (rasterize is ctx) 400rasterizePrimitives ctx is = concatMapStream (rasterize is ctx)
381--rasterizePrimitivesWithPointSize ctx ps is = concatMapStream (rasterize ps is ctx) 401--rasterizePrimitivesWithPointSize ctx ps is = concatMapStream (rasterize ps is ctx)
382 402
383checkFragment :: (a -> Bool) -> Fragment n a -> Bool
384
385filterFragments :: (a -> Bool) -> FragmentStream n a -> FragmentStream n a
386filterFragments p = filterStream (checkFragment p)
387
388mapFragment :: (a -> b) -> Fragment n a -> Fragment n b
389
390mapFragments :: (a -> b) -> FragmentStream n a -> FragmentStream n b
391mapFragments f = mapStream (mapFragment f)
392
393data Image :: Nat -> Type -> Type where 403data Image :: Nat -> Type -> Type where
394 ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t) 404 ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t)
395 => color -> Image a (Color color) 405 => color -> Image a (Color color)
diff --git a/lc/Prelude.lc b/lc/Prelude.lc
index bc89e137..f5d1fee6 100644
--- a/lc/Prelude.lc
+++ b/lc/Prelude.lc
@@ -86,12 +86,6 @@ infixr 5 ++
86iterate :: (a -> a) -> a -> [a] 86iterate :: (a -> a) -> a -> [a]
87iterate f x = x : iterate f (f x) 87iterate f x = x : iterate f (f x)
88 88
89data Maybe a
90 = Nothing
91 | Just a
92-- deriving (Eq, Ord, Show)
93
94
95fst (a, b) = a 89fst (a, b) = a
96snd (a, b) = b 90snd (a, b) = b
97 91