packages feed

gloss-raster 1.7.4.1 → 1.7.4.2

raw patch · 2 files changed

+62/−37 lines, 2 filesdep ~repaPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependency ranges changed: repa

API changes (from Hackage documentation)

+ Graphics.Gloss.Raster.Field: makeFrame :: Int -> Int -> (Point -> Color) -> Array (I D) DIM2 (Word8, Word8, Word8)
+ Graphics.Gloss.Raster.Field: makePicture :: Int -> Int -> Int -> Int -> (Point -> Color) -> Picture

Files

Graphics/Gloss/Raster/Field.hs view
@@ -24,7 +24,11 @@         , Display       (..)         , Point         , animateField-        , playField)+        , playField++         -- * Frame creation+        , makePicture+        , makeFrame) where import Graphics.Gloss.Data.Color import Graphics.Gloss.Data.Picture@@ -38,6 +42,7 @@ import Data.Bits import Data.Array.Repa                          as R import Data.Array.Repa.Repr.ForeignPtr          as R+import Data.Array.Repa.Repr.HintInterleave      as R import Prelude                                  as P  -- Color ----------------------------------------------------------------------@@ -88,7 +93,7 @@         {-# INLINE frame #-}         frame !time                 = return-                $ makeFrame winSizeX winSizeY zoomX zoomY (makePixel time)+                $ makePicture winSizeX winSizeY zoomX zoomY (makePixel time)     in   animateFixedIO display black frame {-# INLINE animateField #-}@@ -124,48 +129,33 @@                    initWorld                    (\world ->                        world `seq` -                      makeFrame winSizeX winSizeY zoomX zoomY (makePixel world))+                      makePicture winSizeX winSizeY zoomX zoomY (makePixel world))                    handleEvent                    stepWorld {-# INLINE playField #-}  --- Frame -----------------------------------------------------------------------{-# INLINE sizeOfDisplay #-} sizeOfDisplay :: Display -> (Int, Int) sizeOfDisplay display  = case display of         InWindow _ s _  -> s         FullScreen s    -> s+{-# INLINE sizeOfDisplay #-} -{-# INLINE makeFrame #-}-makeFrame -        :: Int -> Int -> Int -> Int -        -> (Point -> Color) -> Picture-makeFrame !winSizeX !winSizeY !zoomX !zoomY !makePixel++-- Picture --------------------------------------------------------------------+makePicture+        :: Int                  -- Window Size X+        -> Int                  -- Window Size Y+        -> Int                  -- Pixels X+        -> Int                  -- Pixels Y+        -> (Point -> Color)+        -> Picture+makePicture !winSizeX !winSizeY !zoomX !zoomY !makePixel  = let  -- Size of the raw image to render.         sizeX = winSizeX `div` zoomX         sizeY = winSizeY `div` zoomY -        fsizeX, fsizeY  :: Float-        !fsizeX          = fromIntegral sizeX-        !fsizeY          = fromIntegral sizeY--        fsizeX2, fsizeY2 :: Float-        !fsizeX2        = fsizeX / 2-        !fsizeY2        = fsizeY / 2--        -- Midpoint of image.-        midX, midY :: Int-        !midX           = sizeX `div` 2-        !midY           = sizeY `div` 2--        {-# INLINE pixelOfIndex #-}-        pixelOfIndex (Z :. y :. x)-         = let  x'      = fromIntegral (x - midX) / fsizeX2-                y'      = fromIntegral (y - midY) / fsizeY2-           in   makePixel (x', y')-         {-# INLINE conv #-}          conv (r, g, b)          = let  r'      = fromIntegral r@@ -183,14 +173,12 @@          -- Define the image, and extract out just the RGB color components.         -- We don't need the alpha because we're only drawing one image.-        traceEventIO "Gloss.Raster[makeFrame]: start frame evaluation."+        traceEventIO "Gloss.Raster[makePicture]: start frame evaluation."         (arrRGB :: Array F DIM2 Word32)                 <- R.computeP  -                        $ R.map conv-                        $ R.map unpackColor -                        $ R.fromFunction (Z :. sizeY  :. sizeX)-                        $ pixelOfIndex-        traceEventIO "Gloss.Raster[makeFrame]: done, returning picture."+                $  R.map conv+                $  makeFrame sizeX sizeY makePixel+        traceEventIO "Gloss.Raster[makePicture]: done, returning picture."          -- Wrap the ForeignPtr from the Array as a gloss picture.         let picture     @@ -202,6 +190,43 @@                         False           -- don't cache this in texture memory.          return picture+{-# INLINE makePicture #-}+++-- Frame ----------------------------------------------------------------------+makeFrame+        :: Int                  -- Array Size X+        -> Int                  -- Array Size Y+        -> (Point -> Color)+        -> Array (I D) DIM2 (Word8, Word8, Word8)++makeFrame !sizeX !sizeY !makePixel+ = let  -- Size of the raw image to render.+        fsizeX, fsizeY  :: Float+        !fsizeX          = fromIntegral sizeX+        !fsizeY          = fromIntegral sizeY++        fsizeX2, fsizeY2 :: Float+        !fsizeX2        = fsizeX / 2+        !fsizeY2        = fsizeY / 2++        -- Midpoint of image.+        midX, midY :: Int+        !midX           = sizeX `div` 2+        !midY           = sizeY `div` 2++        {-# INLINE pixelOfIndex #-}+        pixelOfIndex (Z :. y :. x)+         = let  x'      = fromIntegral (x - midX) / fsizeX2+                y'      = fromIntegral (y - midY) / fsizeY2+           in   makePixel (x', y')++   in   R.hintInterleave+         $ R.map unpackColor +         $ R.fromFunction (Z :. sizeY  :. sizeX)+         $ pixelOfIndex+{-# INLINE makeFrame #-}+   -- | Float to Word8 conversion because the one in the GHC libraries
gloss-raster.cabal view
@@ -1,5 +1,5 @@ Name:                gloss-raster-Version:             1.7.4.1+Version:             1.7.4.2 License:             MIT License-file:        LICENSE Author:              Ben Lippmeier@@ -24,7 +24,7 @@         ghc-prim   == 0.2.*,         containers >= 0.3.0 &&   < 0.5.0,         gloss      == 1.7.4.*,-        repa       >= 3.1.2.1 && < 3.2+        repa       >= 3.1.4 && < 3.2    ghc-options:      -Odph -fno-liberate-case -fllvm -optlo-O3