reanimate-1.1.2.0: Animation library based on SVGs.

CopyrightWritten by David Himmelstrup
LicenseUnlicense
Maintainerlemmih@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Reanimate.Raster

Description

Tools for generating, manipulating, and embedding raster images.

Synopsis

Documentation

mkImage Source #

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.

embedDynamicImage :: DynamicImage -> SVG Source #

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.

embedPng Source #

Arguments

:: Double

Width

-> Double

Height

-> ByteString

Raw PNG data

-> SVG 

Embed in-memory PNG bytestring without parsing it.

raster :: SVG -> DynamicImage Source #

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.

rasterSized Source #

Arguments

:: Width

X resolution in pixels

-> Height

Y resolution in pixels

-> SVG

SVG object

-> DynamicImage 

Convert an SVG object to a pixel-based image.

vectorize :: FilePath -> SVG Source #

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'.

svgAsPngFile :: SVG -> FilePath Source #

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.

svgAsPngFile' Source #

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.