| Copyright | Copyright (c) 2015 Yun-Yan Chi |
|---|---|
| License | MIT |
| Maintainer | jaiyalas@gmail.com |
| Safe Haskell | None |
| Language | Haskell2010 |
SDL.Cairo.Image.Renderer
Description
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
drawImgordrawImgC
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 ()
Arguments
| :: RenderablePixel a | |
| => Texture | a |
| -> V2 Int | a |
| -> Image a | an |
| -> IO () |
draw a JuicyPixel Image on the given SDL Texture
(at the specified coordinate).
Arguments
| :: RenderablePixelC a | |
| => Texture | a |
| -> V2 Int | a |
| -> Image a | an |
| -> IO () |
draw a JuicyPixel Image on the given SDL Texture
(at the specified coordinate).
Using Cairo's Render underneath.
draw Image in Canvas ()
Arguments
| :: RenderablePixel a | |
| => V2 Int | a |
| -> Image a | an |
| -> Canvas () | a |
render an JuicyPixel Image through Cairo Canvas
draw Image in Render ()
Arguments
| :: RenderablePixelC a | |
| => V2 Int | a |
| -> Image a | a JuicyPixel |
| -> Render () | an Cairo |
render an Image through Cairo Render
Arguments
| :: Texture | target |
| -> Render () | a |
| -> IO () |
perform a Render action on the given Texture
Type class
class Pixel px => RenderablePixel px where
A pixel structure is RenderablePixel if
how to draw on Canvas is defined.
Instances
| RenderablePixel PixelRGBA8 | |
| RenderablePixel PixelRGBA16 | |
| RenderablePixel PixelRGB8 | |
| RenderablePixel PixelRGB16 |
class Pixel px => RenderablePixelC px where
A pixel structure is RenderablePixelC if
how to render on Render can be provided.
Instances
| RenderablePixelC PixelRGBA8 | |
| RenderablePixelC PixelRGBA16 | |
| RenderablePixelC PixelRGB8 | |
| RenderablePixelC PixelRGB16 |