-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | SVG renderer based on Rasterific.
--   
--   SVG renderer that will let you render svg-tree parsed SVG file to a
--   JuicyPixel image or Rasterific Drawing.
@package rasterific-svg
@version 0.3.3.1


-- | Svg renderer based on Rasterific.
--   
--   Here is a simple example of loading a SVG file (using svg-tree)
--   rendering it to a picture, and saving it to a PNG (using Juicy.Pixels)
--   
--   <pre>
--   import Codec.Picture( writePng )
--   import Graphics.Svg( loadSvgFile )
--   import Graphics.Rasterific.Svg( loadCreateFontCache
--                                 , renderSvgDocument
--                                 )
--   loadRender :: FilePath -&gt; FilePath -&gt; IO ()
--   loadRender svgfilename pngfilename = do
--     f &lt;- loadSvgFile svgfilename
--     case f of
--       Nothing -&gt; putStrLn "Error while loading SVG"
--       Just doc -&gt; do
--         cache &lt;- loadCreateFontCache "fonty-texture-cache"
--         (finalImage, _) &lt;- renderSvgDocument cache Nothing 96 doc
--         writePng pngfilename finalImage
--   </pre>
module Graphics.Rasterific.Svg

-- | Render an svg document to a Rasterific Drawing. If you provide a size,
--   the document will be stretched to match the provided size.
--   
--   The DPI parameter really should depend of your screen, but a good
--   default value is 96
--   
--   The use of the IO Monad is there to allow loading of fonts and
--   referenced images.
drawingOfSvgDocument :: FontCache -> Maybe (Int, Int) -> Dpi -> Document -> IO (DrawResult, LoadedElements)

-- | Render an svg document to an image. If you provide a size, the
--   document will be stretched to match the provided size.
--   
--   The DPI parameter really should depend of your screen, but a good
--   default value is 96
--   
--   The use of the IO Monad is there to allow loading of fonts and
--   referenced images.
renderSvgDocument :: FontCache -> Maybe (Int, Int) -> Dpi -> Document -> IO (Image PixelRGBA8, LoadedElements)
pdfOfSvgDocument :: FontCache -> Maybe (Int, Int) -> Dpi -> Document -> IO (ByteString, LoadedElements)

-- | This function will create a font cache, a structure allowing to
--   quickly match a font family name and style to a specific true type
--   font on disk.
--   
--   The cache is saved on disk at the filepath given as parameter. If a
--   cache is found it is automatically loaded from the file.
--   
--   Creating the cache is a rather long operation (especially on Windows),
--   that's why you may want to keep the cache around.
loadCreateFontCache :: FilePath -> IO FontCache
data LoadedElements
LoadedElements :: Map FilePath Font -> Map FilePath (Image PixelRGBA8) -> LoadedElements
[_loadedFonts] :: LoadedElements -> Map FilePath Font
[_loadedImages] :: LoadedElements -> Map FilePath (Image PixelRGBA8)

-- | Rendering status.
data Result

-- | No problem found
ResultSuccess :: Result

-- | Error with message
ResultError :: String -> Result

-- | Represent a Rasterific drawing with the associated image size.
data DrawResult
DrawResult :: Drawing PixelRGBA8 () -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> DrawResult

-- | Rasterific drawing, can be reused and composed with other elements for
--   scene drawing.
[_drawAction] :: DrawResult -> Drawing PixelRGBA8 ()

-- | Supposed drawing width of the drawing, ideally represent the final
--   image width.
[_drawWidth] :: DrawResult -> {-# UNPACK #-} !Int

-- | Supposed drawing height of the drawing, ideally represent the final
--   image height.
[_drawHeight] :: DrawResult -> {-# UNPACK #-} !Int

-- | Express device resolution in dot per inch.
type Dpi = Int

-- | Convert an SVG file to a PNG file, return True if the operation went
--   without problems.
--   
--   This function will call loadCreateFontCache with the filename
--   "fonty-texture-cache"
renderSvgFile :: FilePath -> FilePath -> IO Result
instance GHC.Show.Show Graphics.Rasterific.Svg.Result
instance GHC.Classes.Eq Graphics.Rasterific.Svg.Result
