diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-02-05 00:34:35 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-02-05 00:34:35 +0100 |
commit | 98cd7ed424454502d98aafe193b8cda61ef3b692 (patch) | |
tree | 72ddd252f7080f7aaf91200c2c2db821860b2352 /lc | |
parent | de0f0691a15c1551cf315274f89584594f89481c (diff) |
better Fragment data type
Diffstat (limited to 'lc')
-rw-r--r-- | lc/Builtins.lc | 34 | ||||
-rw-r--r-- | lc/Prelude.lc | 6 |
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 | ||
349 | data Maybe a | ||
350 | = Nothing | ||
351 | | Just a | ||
352 | -- deriving (Eq, Ord, Show) | ||
353 | |||
349 | data Vector (n :: Nat) t | 354 | data Vector (n :: Nat) t |
350 | 355 | ||
351 | data Fragment (l :: Nat) t | 356 | type Fragment n t = Vector n (Maybe (SimpleFragment t)) |
352 | = Fragment (Vec 3 Float) (Vector l t) | 357 | |
358 | data SimpleFragment t = SimpleFragment | ||
359 | { sFragmentCoords :: Vec 3 Float | ||
360 | , sFragmentValue :: t | ||
361 | } | ||
353 | 362 | ||
354 | type FragmentStream n t = Stream (Fragment n t) | 363 | type FragmentStream n t = Stream (Fragment n t) |
355 | 364 | ||
@@ -358,6 +367,17 @@ customizeDepth :: (a -> Float) -> Fragment n a -> Fragment n a | |||
358 | customizeDepths :: (a -> Float) -> FragmentStream n a -> FragmentStream n a | 367 | customizeDepths :: (a -> Float) -> FragmentStream n a -> FragmentStream n a |
359 | customizeDepths f = mapStream (customizeDepth f) | 368 | customizeDepths f = mapStream (customizeDepth f) |
360 | 369 | ||
370 | filterFragment :: (a -> Bool) -> Fragment n a -> Fragment n a | ||
371 | |||
372 | filterFragments :: (a -> Bool) -> FragmentStream n a -> FragmentStream n a | ||
373 | filterFragments p = mapStream (filterFragment p) | ||
374 | |||
375 | mapFragment :: (a -> b) -> Fragment n a -> Fragment n b | ||
376 | |||
377 | mapFragments :: (a -> b) -> FragmentStream n a -> FragmentStream n b | ||
378 | mapFragments f = mapStream (mapFragment f) | ||
379 | |||
380 | |||
361 | data Interpolated t where | 381 | data Interpolated t where |
362 | Smooth, NoPerspective | 382 | Smooth, NoPerspective |
363 | :: (Floating t) => Interpolated t | 383 | :: (Floating t) => Interpolated t |
@@ -380,16 +400,6 @@ rasterize | |||
380 | rasterizePrimitives ctx is = concatMapStream (rasterize is ctx) | 400 | rasterizePrimitives 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 | ||
383 | checkFragment :: (a -> Bool) -> Fragment n a -> Bool | ||
384 | |||
385 | filterFragments :: (a -> Bool) -> FragmentStream n a -> FragmentStream n a | ||
386 | filterFragments p = filterStream (checkFragment p) | ||
387 | |||
388 | mapFragment :: (a -> b) -> Fragment n a -> Fragment n b | ||
389 | |||
390 | mapFragments :: (a -> b) -> FragmentStream n a -> FragmentStream n b | ||
391 | mapFragments f = mapStream (mapFragment f) | ||
392 | |||
393 | data Image :: Nat -> Type -> Type where | 403 | data 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 ++ | |||
86 | iterate :: (a -> a) -> a -> [a] | 86 | iterate :: (a -> a) -> a -> [a] |
87 | iterate f x = x : iterate f (f x) | 87 | iterate f x = x : iterate f (f x) |
88 | 88 | ||
89 | data Maybe a | ||
90 | = Nothing | ||
91 | | Just a | ||
92 | -- deriving (Eq, Ord, Show) | ||
93 | |||
94 | |||
95 | fst (a, b) = a | 89 | fst (a, b) = a |
96 | snd (a, b) = b | 90 | snd (a, b) = b |
97 | 91 | ||