1
Fork 0
This repository has been archived on 2023-12-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2022FuncProg-project2-patience/lib/PNGRenderer.hs
2022-11-15 23:33:12 +01:00

40 lines
1.1 KiB
Haskell

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 a picture by moving it along two axis.
translate :: Float -> Float -> Picture -> Picture
translate = Gloss.translate
-- Compose multiple pictures into a single picture.
compose :: [Picture] -> Picture
compose = Gloss.Pictures