Copyright | Copyright (c) 2015 Yun-Yan Chi |
---|---|
License | MIT |
Maintainer | jaiyalas@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
This module provides functions for directly/indirectly
rendering a JuicyPixel's Image
onto a sdl2's Texture
.
This module is actually implemented with both of Render
and Canvas
,
therefore it provides functions in both way.
In fact, There are three simple ways to use this module.
Assume we alread have following code,
import SDL import Linear.V2 (V2(..)) import SDL.Cairo import SDL.Cairo.Canvas import SDL.Cairo.Image.Renderer import Codec.Picture main :: IO () main = do initialize [InitEverything] window <- createWindow "SDL2 Cairo Canvas" defaultWindow renderer <- createRenderer window (-1) defaultRenderer texture <- createCairoTexture' renderer window withCanvas texture $ do background $ gray 102 -- location A Right (ImageRGB8 img) <- readPng "pic.png" -- location B copy renderer texture Nothing Nothing present renderer delay 5000
- using
renderImgCanvas
The first way to draw image is replacing
-- location A
by
renderImgCanvas (V2 50 50) img
- using
drawImg
ordrawImgC
The other ways are replacing
-- location B
by
drawImg texture (V2 50 50) img
or
drawImgC texture (V2 50 50) img
- drawImg :: RenderablePixel a => Texture -> V2 Int -> Image a -> IO ()
- drawImgC :: RenderablePixelC a => Texture -> V2 Int -> Image a -> IO ()
- renderImgCanvas :: RenderablePixel a => V2 Int -> Image a -> Canvas ()
- renderImgCairo :: RenderablePixelC a => V2 Int -> Image a -> Render ()
- renderOnTexture :: Texture -> Render () -> IO ()
- class Pixel px => RenderablePixel px where
- class Pixel px => RenderablePixelC px where
draw Image
in IO
()
draw Image
in Canvas
()
draw Image
in Render
()
:: RenderablePixelC a | |
=> V2 Int | a |
-> Image a | a JuicyPixel |
-> Render () | an Cairo |
render an Image
through Cairo Render
perform a Render
action on the given Texture
Type class
class Pixel px => RenderablePixel px where Source
A pixel structure is RenderablePixel
if
how to draw on Canvas
is defined.
class Pixel px => RenderablePixelC px where Source
A pixel structure is RenderablePixelC
if
how to render on Render
can be provided.