diagrams-rasterific-1.4.1.1: Rasterific backend for diagrams.

Copyright(c) 2014-2015 diagrams-rasterific team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Backend.Rasterific

Contents

Description

A full-featured rendering backend for diagrams using Rasterific, implemented natively in Haskell (making it easy to use on any platform). Can create png, tif, bmp, jpg, pdf, and animated GIFs.

To invoke the Rasterific backend, you have three options.

  • You can use the Diagrams.Backend.Rasterific.CmdLine module to create standalone executables which output images when invoked.
  • You can use the renderRasterific function provided by this module, which gives you more flexible programmatic control over when and how images are output (making it easy to, for example, write a single program that outputs multiple images, or one that outputs images dynamically based on user input, and so on).
  • For the most flexibility (e.g. if you want access to the resulting Rasterific value directly in memory without writing it to disk), you can manually invoke the renderDia method from the Backend instance for Rasterific. In particular, renderDia has the generic type
renderDia :: b -> Options b v n -> QDiagram b v n m -> Result b v n

(omitting a few type class constraints). b represents the backend type, v the vector space, n the numeric field, and m the type of monoidal query annotations on the diagram. Options and Result are associated data and type families, respectively, which yield the type of option records and rendering results specific to any particular backend. For b ~ Rasterific, v ~ V2, and n ~ n, we have

data Options Rasterific V2 n = RasterificOptions
       { _size      :: SizeSpec2D n -- ^ The requested size of the output
       }
type family Result Rasterific V2 n = 'Image PixelRGBA8'

So the type of renderDia resolves to

renderDia :: Rasterific -> Options Rasterific V2 n -> QDiagram Rasterific V2 n m -> 'Image PixelRGBA8'

which you could call like renderDia Rasterific (RasterificOptions (mkWidth 250)) myDiagram.

Synopsis

Rasterific backend

data Rasterific #

This data declaration is simply used as a token to distinguish the Rasterific backend: (1) when calling functions where the type inference engine would otherwise have no way to know which backend you wanted to use, and (2) as an argument to the Backend and Renderable type classes.

Constructors

Rasterific 
Instances
Eq Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

Ord Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

Read Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

Show Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

TypeableFloat n => Backend Rasterific V2 n # 
Instance details

Defined in Diagrams.Backend.Rasterific

Associated Types

data Render Rasterific V2 n :: Type #

type Result Rasterific V2 n :: Type #

data Options Rasterific V2 n :: Type #

ToResult [(QDiagram Rasterific V2 n Any, GifDelay)] #

An animated GIF can be a result.

Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

Associated Types

type Args [(QDiagram Rasterific V2 n Any, GifDelay)] :: Type #

type ResultOf [(QDiagram Rasterific V2 n Any, GifDelay)] :: Type #

TypeableFloat n => Mainable [(String, QDiagram Rasterific V2 n Any)] # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

Associated Types

type MainOpts [(String, QDiagram Rasterific V2 n Any)] :: Type #

TypeableFloat n => Mainable [(QDiagram Rasterific V2 n Any, GifDelay)] # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

Associated Types

type MainOpts [(QDiagram Rasterific V2 n Any, GifDelay)] :: Type #

TypeableFloat n => Renderable (Text n) Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

Methods

render :: Rasterific -> Text n -> Render Rasterific (V (Text n)) (N (Text n)) #

TypeableFloat n => Renderable (DImage n Embedded) Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

TypeableFloat n => Renderable (Path V2 n) Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

Methods

render :: Rasterific -> Path V2 n -> Render Rasterific (V (Path V2 n)) (N (Path V2 n)) #

Show n => Show (Options Rasterific V2 n) # 
Instance details

Defined in Diagrams.Backend.Rasterific

Semigroup (Render Rasterific V2 n) # 
Instance details

Defined in Diagrams.Backend.Rasterific

Monoid (Render Rasterific V2 n) # 
Instance details

Defined in Diagrams.Backend.Rasterific

TypeableFloat n => Mainable (Animation Rasterific V2 n) # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

Associated Types

type MainOpts (Animation Rasterific V2 n) :: Type #

Hashable n => Hashable (Options Rasterific V2 n) # 
Instance details

Defined in Diagrams.Backend.Rasterific

TypeableFloat n => Mainable (QDiagram Rasterific V2 n Any) # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

Associated Types

type MainOpts (QDiagram Rasterific V2 n Any) :: Type #

type V Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

type V Rasterific = V2
type N Rasterific # 
Instance details

Defined in Diagrams.Backend.Rasterific

data Options Rasterific V2 n # 
Instance details

Defined in Diagrams.Backend.Rasterific

newtype Render Rasterific V2 n # 
Instance details

Defined in Diagrams.Backend.Rasterific

newtype Render Rasterific V2 n = R (RenderM n ())
type Result Rasterific V2 n # 
Instance details

Defined in Diagrams.Backend.Rasterific

type ResultOf [(QDiagram Rasterific V2 n Any, GifDelay)] # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

type Args [(QDiagram Rasterific V2 n Any, GifDelay)] # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

type MainOpts [(String, QDiagram Rasterific V2 n Any)] # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

type MainOpts [(QDiagram Rasterific V2 n Any, GifDelay)] # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

type MainOpts (Animation Rasterific V2 n) # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

type MainOpts (QDiagram Rasterific V2 n Any) # 
Instance details

Defined in Diagrams.Backend.Rasterific.CmdLine

type B = Rasterific #

data family Options b (v :: Type -> Type) n :: Type #

Backend-specific rendering options.

Instances
Show n => Show (Options Rasterific V2 n) # 
Instance details

Defined in Diagrams.Backend.Rasterific

Hashable n => Hashable (Options Rasterific V2 n) # 
Instance details

Defined in Diagrams.Backend.Rasterific

data Options NullBackend v n 
Instance details

Defined in Diagrams.Core.Types

data Options Rasterific V2 n # 
Instance details

Defined in Diagrams.Backend.Rasterific

Rendering

renderRasterific :: TypeableFloat n => FilePath -> SizeSpec V2 n -> QDiagram Rasterific V2 n Any -> IO () #

Render a Rasterific diagram to a file with the given size. The format is determined by the extension (.png, .tif, .bmp, .jpg and .pdf supported. (jpeg quality is 80, use writeJpeg to choose quality).

renderPdf :: TypeableFloat n => Int -> Int -> FilePath -> SizeSpec V2 n -> QDiagram Rasterific V2 n Any -> IO () #

Render a Rasterific diagram to a pdf file with given width and height

size :: (V a ~ v, N a ~ n, Enveloped a, HasBasis v) => a -> v n #

The smallest positive axis-parallel vector that bounds the envelope of an object.

writeJpeg :: Word8 -> FilePath -> Result Rasterific V2 n -> IO () #

Render a Rasterific diagram to a jpeg file with given quality (between 0 and 100).

type GifDelay = Int #

Delay to wait before showing the next Gif image. The delay is expressed in 100th of seconds.

data GifLooping #

Help to control the behaviour of GIF animation looping.

Constructors

LoopingNever

The animation will stop once the end is reached

LoopingForever

The animation will restart once the end is reached

LoopingRepeat Word16

The animation will repeat n times before stoping

animatedGif #

Arguments

:: TypeableFloat n 
=> FilePath 
-> SizeSpec V2 n 
-> GifLooping 
-> GifDelay

Delay in 100th of seconds (Int)

-> [QDiagram Rasterific V2 n Any] 
-> IO () 

Render a Rasterific diagram to an animated gif with the given size and uniform delay. Diagrams should be the same size.

Text with envelopes

texterific :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any #

Create a primitive text diagram from the given string, with baseline alignment, envelope and trace based on the BoundingBox of the text. Designed to be a replacement for the function text in Diagrams.TwoD.Text.

texterific' :: (TypeableFloat n, Renderable (Text n) b) => FontSlant -> FontWeight -> String -> QDiagram b V2 n Any #

Create a primitive text diagram from the given FontSlant, FontWeight, and string, with baseline alignment, envelope and trace based on the BoundingBox of the text.

Internals

These are low level functions whose implimentaion may change in the future. They're exported because they can sometimes be useful.

data PaletteOptions #

To specify how the palette will be created.

Constructors

PaletteOptions 

Fields

defaultPaletteOptions :: PaletteOptions #

Default palette option, which aim at the best quality and maximum possible colors (256)

rasterGif #

Arguments

:: TypeableFloat n 
=> SizeSpec V2 n

Size of output (in pixels)

-> GifLooping

looping options

-> PaletteOptions

palette options

-> [(QDiagram Rasterific V2 n Any, Int)]

Diagram zipped with its delay (100th of seconds)

-> Either String ByteString 

Turn a list of diagrams into a gif.

rasterRgb8 :: TypeableFloat n => SizeSpec V2 n -> QDiagram Rasterific V2 n Any -> Image PixelRGB8 #

Render a Rasterific diagram without an alpha channel.