Turn Shape into a stream

This commit is contained in:
2022-06-27 18:31:25 +01:00
parent 673e9b11fc
commit c7e720248d
11 changed files with 42 additions and 32 deletions
+17 -13
View File
@@ -1,3 +1,5 @@
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
module ShapePicture
( emptyBlank
@@ -10,23 +12,25 @@ module ShapePicture
, noShape
, _spShape
, _spPicture
, mirrorSPyz
, mirrorSPxz
-- , mirrorSPyz
-- , mirrorSPxz
) where
import Shape
import Picture
import Geometry
import qualified Data.Vector.Fusion.Stream.Monadic as VS
import Data.Bifunctor
--import Control.Lens
type SPic = (Shape, Picture)
type SPic = (Shape, Picture)
-- should all this be inlined/inlinable?
noPic :: Shape -> SPic
noPic = (,mempty)
noShape :: Picture -> SPic
noShape = (mempty,)
noShape = (VS.empty,)
_spShape :: SPic -> Shape
_spShape = fst
@@ -48,12 +52,12 @@ translateSP v = bimap (translateSH v) (translate3 v)
rotateSP :: Float -> SPic -> SPic
rotateSP a = bimap (rotateSH a) (rotate a)
mirrorSPxz :: SPic -> SPic
mirrorSPxz = bimap (reverse . overPosSH flipy) mirrorxz
where
flipy (V3 x y z) = V3 x (negate y) z
mirrorSPyz :: SPic -> SPic
mirrorSPyz = bimap (reverse . overPosSH flipx) mirroryz
where
flipx (V3 x y z) = V3 (negate x) y z
--mirrorSPxz :: SPic -> SPic
--mirrorSPxz = bimap (reverse . overPosSH flipy) mirrorxz
-- where
-- flipy (V3 x y z) = V3 x (negate y) z
--
--mirrorSPyz :: SPic -> SPic
--mirrorSPyz = bimap (reverse . overPosSH flipx) mirroryz
-- where
-- flipx (V3 x y z) = V3 (negate x) y z