From 31ddddeded37bc0e68af688b37b6e1c0e8117bb6 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Mon, 14 Nov 2022 19:19:02 +0100 Subject: [PATCH] Polish PNGRenderer --- lib/PNGRenderer.hs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/PNGRenderer.hs diff --git a/lib/PNGRenderer.hs b/lib/PNGRenderer.hs new file mode 100644 index 0000000..8c342dd --- /dev/null +++ b/lib/PNGRenderer.hs @@ -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