Polish PNGRenderer
This commit is contained in:
parent
fd92ba9d8f
commit
31ddddeded
1 changed files with 38 additions and 0 deletions
38
lib/PNGRenderer.hs
Normal file
38
lib/PNGRenderer.hs
Normal file
|
@ -0,0 +1,38 @@
|
|||
module PNGRenderer
|
||||
( Picture
|
||||
|
||||
, renderPNG
|
||||
, compose
|
||||
, translate
|
||||
, blank
|
||||
) where
|
||||
|
||||
import Data.Maybe
|
||||
import System.IO.Unsafe
|
||||
import qualified Graphics.Gloss as Gloss
|
||||
import Graphics.Gloss.Juicy
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- Render a file using Gloss.Picture. Compose multiple images into --
|
||||
-- one. --
|
||||
----------------------------------------------------------------------
|
||||
|
||||
----------------------------- Constants ------------------------------
|
||||
|
||||
type Picture = Gloss.Picture
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
-- Turn a path to a .png file into a Picture.
|
||||
renderPNG :: FilePath -> Picture
|
||||
renderPNG = fromJust . unsafePerformIO . loadJuicyPNG
|
||||
|
||||
-- An empty picture
|
||||
blank :: Picture
|
||||
blank = Gloss.Blank
|
||||
|
||||
translate :: Float -> Float -> Picture -> Picture
|
||||
translate = Gloss.translate
|
||||
|
||||
compose :: [Picture] -> Picture
|
||||
compose = Gloss.Pictures
|
Reference in a new issue