reanimate-0.4.2.0: Animation library based on SVGs.

Reanimate.Raster

Description

Tools for generating, manipulating, and embedding raster images.

Synopsis

# Documentation

Arguments

 :: Double Desired image width. -> Double Desired image height. -> FilePath Path to external image file. -> SVG

Load an external image. Width and height must be specified, ignoring the image's aspect ratio. The center of the image is placed at position (0,0).

For security reasons, must SVG renderer do not allow arbitrary image links. For some renderers, we can get around this by placing the images in the same root directory as the parent SVG file. Other renderers (like Chrome and ffmpeg) requires that the image is inlined as base64 data. External SVG files are an exception, though, as must always be inlined directly. mkImage attempts to hide all the complexity but edge-cases may exist.

Example:

mkImage screenWidth screenHeight "../data/haskell.svg"

cacheImage :: (PngSavable pixel, Hashable a) => a -> Image pixel -> FilePath Source #

Write in-memory image to cache file if (and only if) such cache file doesn't already exist.

prerenderSvg :: Hashable a => a -> SVG -> SVG Source #

Render SVG node to a PNG file and return a new node containing that image. For static SVG nodes, this can hugely improve performance. The first argument is the key that determines SVG uniqueness. It is entirely your responsibility to ensure that all keys are unique. If they are not, you will be served stale results from the cache.

prerenderSvgFile :: Hashable a => a -> Width -> Height -> SVG -> FilePath Source #

Same as prerenderSvg but returns the location of the rendered image as a FilePath.

embedImage :: PngSavable a => Image a -> SVG Source #

Embed an in-memory PNG image. Note, the pixel size of the image is used as the dimensions. As such, embedding a 100x100 PNG will result in an image 100 units wide and 100 units high. Consider using with scaleToSize.

Embed an in-memory image. Note, the pixel size of the image is used as the dimensions. As such, embedding a 100x100 image will result in an image 100 units wide and 100 units high. Consider using with scaleToSize.

Arguments

 :: Double Width -> Double Height -> ByteString Raw PNG data -> SVG

Embed in-memory PNG bytestring without parsing it.

Convert an SVG object to a pixel-based image. The default resolution is 2560x1440. See also rasterSized. Multiple raster engines are supported and are selected using the '--raster' flag in the driver.

Arguments

 :: Width X resolution in pixels -> Height Y resolution in pixels -> SVG SVG object -> DynamicImage

Convert an SVG object to a pixel-based image.

Use 'potrace' to trace edges in a raster image and convert them to SVG polygons.

vectorize_ :: [String] -> FilePath -> SVG Source #

Same as vectorize but takes a list of arguments for 'potrace'.

Convert an SVG object to a pixel-based image and save it to disk, returning the filepath. The default resolution is 2560x1440. See also svgAsPngFile'. Multiple raster engines are supported and are selected using the '--raster' flag in the driver.

Arguments

 :: Width Width -> Height Height -> SVG SVG object -> FilePath

Convert an SVG object to a pixel-based image and save it to disk, returning the filepath.