sdl2-cairo-image 1.0 → 1.0.0.1
raw patch · 3 files changed
+4/−91 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +3/−0
- sdl2-cairo-image.cabal +1/−15
- src/Main.hs +0/−76
README.md view
@@ -1,5 +1,8 @@ # sdl2-cairo-image +[](https://en.wikipedia.org/wiki/MIT_licenses)+[](http://haskell.org)+ An image loading and rendering library for sdl2 / sdl2-cairo ## Installation
sdl2-cairo-image.cabal view
@@ -1,7 +1,7 @@ Name: sdl2-cairo-image Synopsis: An image loading and rendering library for sdl2 / sdl2-cairo Description: An image loading and rendering library for sdl2 / sdl2-cairo-Version: 1.0+Version: 1.0.0.1 Author: Yun-Yan Chi <jaiyalas@gmail.com> Maintainer: Yun-Yan Chi <jaiyalas@gmail.com> License: MIT@@ -22,20 +22,6 @@ Exposed-Modules: SDL.Cairo.Image SDL.Cairo.Image.Load SDL.Cairo.Image.Render- Build-Depends: base >= 4 && < 5- , vector >= 0.11- , linear >= 1.19- , JuicyPixels >= 3.2- , sdl2 >= 2.0- , sdl2-cairo >= 0.1- , cairo >= 0.13- , convertible >= 1.1----executable main- default-language: Haskell2010- hs-source-dirs: src- main-is: Main.hs- ghc-options: -w -threaded Build-Depends: base >= 4 && < 5 , vector >= 0.11 , linear >= 1.19
− src/Main.hs
@@ -1,76 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-module Main where--import qualified SDL-import SDL.Cairo (createCairoTexture)-import SDL.Cairo.Canvas----import Linear.V2 (V2(..))----import Data.Maybe (catMaybes)-import Control.Concurrent (threadDelay)-import Control.Monad (unless,void,mapM)-import Control.Monad.Fix (fix)----import qualified SDL.Cairo.Image as I----main :: IO ()-main = do- --- SDL.initialize [SDL.InitEverything]- window <- SDL.createWindow "Hello!" winConfig- renderer <- SDL.createRenderer window (-1) rdrConfig- texture <- createCairoTexture renderer (V2 640 480)- --- -- img1 <- L.loadPNGRGBA "/Users/jaiyalas/img/xd.png"- -- img2 <- L.loadPNGRGBA "/Users/jaiyalas/img/char.png"- img3 <- I.loadRGBA8 I.PNG "./img/newton.png"- img4 <- I.loadRGB8 I.PNG "./img/newton.png"- --- fix $ \loop -> do- threadDelay 100000- withCanvas texture $ do- background $ gray 102- I.renderImgCanvas (V2 10 50) img3- I.renderImgCanvas (V2 10 200) img4- -- R.drawImg texture (V2 50 120) img3- -- R.drawImgC texture (V2 50 220) img3- SDL.copy renderer texture Nothing Nothing- SDL.present renderer- qb <- quitPredicate- unless qb loop------ ################################----quitPredicate :: IO Bool-quitPredicate = do- events <- SDL.pollEvents- return $ elem SDL.KeycodeEscape $ events2Kcodes events----events2Kcodes :: [SDL.Event] -> [SDL.Keycode]-events2Kcodes = catMaybes . map event2Kcode----event2Kcode :: SDL.Event -> Maybe SDL.Keycode-event2Kcode e = case SDL.eventPayload e of- SDL.KeyboardEvent edata -> if isPressed edata- then return $ getKeycode edata- else Nothing- otherwise -> Nothing----isPressed :: SDL.KeyboardEventData -> Bool-isPressed edata = SDL.keyboardEventKeyMotion edata == SDL.Pressed----getKeycode :: SDL.KeyboardEventData -> SDL.Keycode-getKeycode = SDL.keysymKeycode . SDL.keyboardEventKeysym------ ##################################----winConfig = SDL.defaultWindow- { SDL.windowPosition = SDL.Centered- , SDL.windowInitialSize = V2 640 480- }--rdrConfig = SDL.RendererConfig- { SDL.rendererType = SDL.AcceleratedVSyncRenderer- , SDL.rendererTargetTexture = True- }