Abstract out block placement
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
module Bound where
|
||||
import Geometry
|
||||
|
||||
import Control.Lens
|
||||
import Streaming
|
||||
import qualified Streaming.Prelude as S
|
||||
import qualified Control.Foldl as L
|
||||
|
||||
boundPoints :: Stream (Of Point2) Identity () -> Maybe (Float,Float,Float,Float)
|
||||
boundPoints = f . runIdentity . L.purely S.fold_ ((,,,)
|
||||
<$> L.premap (^?! _2) L.maximum
|
||||
<*> L.premap (^?! _2) L.minimum
|
||||
<*> L.premap (^?! _1) L.maximum
|
||||
<*> L.premap (^?! _1) L.minimum
|
||||
)
|
||||
where
|
||||
f (mn,ms,me,mw) = (,,,) <$> mn <*> ms <*> me <*> mw
|
||||
Reference in New Issue
Block a user