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
()
:: RenderablePixel a | |
=> Texture | a |
-> V2 Int | a |
-> Image a | an |
-> IO () |
draw a JuicyPixel Image
on the given SDL Texture
(at the specified coordinate).
:: 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
()
:: RenderablePixel a | |
=> V2 Int | a |
-> Image a | an |
-> Canvas () | a |
render an JuicyPixel Image
through Cairo Canvas
draw Image
in Render
()
:: RenderablePixelC a | |
=> V2 Int | a |
-> Image a | a JuicyPixel |
-> Render () | an Cairo |
render an Image
through Cairo Render
:: Texture | target |
-> Render () | a |
-> IO () |
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.
RenderablePixel PixelRGBA8 Source | |
RenderablePixel PixelRGBA16 Source | |
RenderablePixel PixelRGB8 Source | |
RenderablePixel PixelRGB16 Source |
class Pixel px => RenderablePixelC px where Source
A pixel structure is RenderablePixelC
if
how to render on Render
can be provided.
RenderablePixelC PixelRGBA8 Source | |
RenderablePixelC PixelRGBA16 Source | |
RenderablePixelC PixelRGB8 Source | |
RenderablePixelC PixelRGB16 Source |