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


-- | Rasterific backend for diagrams.
--   
--   A full-featured backend for rendering diagrams using the Rasterific
--   rendering engine.
@package diagrams-rasterific
@version 1.4.1.1


-- | Experimental module to create text with an envelope and trace. The
--   texterifc functions build diagrams with text size of <tt><a>local</a>
--   1</tt> and a s specified slant and weight. The size should be changed
--   only with the scale functions and changing the slant and/or weight
--   after the text has benn created can result in an slightly incorrect
--   envelope.
module Diagrams.Backend.Rasterific.Text

-- | Create a primitive text diagram from the given <a>FontSlant</a>,
--   <a>FontWeight</a>, and string, with baseline alignment, envelope and
--   trace based on the <a>BoundingBox</a> of the text.
texterific' :: (TypeableFloat n, Renderable (Text n) b) => FontSlant -> FontWeight -> String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given string, with baseline
--   alignment, envelope and trace based on the <a>BoundingBox</a> of the
--   text. Designed to be a replacement for the function <a>text</a> in
--   Diagrams.TwoD.Text.
texterific :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Get an OpenSans font with the given <a>FontSlant</a> and
--   <a>FontWeight</a>.
fromFontStyle :: FontSlant -> FontWeight -> Font

-- | Get the <a>BoundingBox</a> for some font with the origin at the start
--   of the baseline.
textBoundingBox :: RealFloat n => Font -> PointSize -> String -> BoundingBox V2 n


-- | 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.
--   
--   <ul>
--   <li>You can use the <a>Diagrams.Backend.Rasterific.CmdLine</a> module
--   to create standalone executables which output images when
--   invoked.</li>
--   <li>You can use the <a>renderRasterific</a> 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).</li>
--   <li>For the most flexibility (<i>e.g.</i> if you want access to the
--   resulting Rasterific value directly in memory without writing it to
--   disk), you can manually invoke the <a>renderDia</a> method from the
--   <a>Backend</a> instance for <tt>Rasterific</tt>. In particular,
--   <a>renderDia</a> has the generic type</li>
--   </ul>
--   
--   <pre>
--   renderDia :: b -&gt; Options b v n -&gt; QDiagram b v n m -&gt; Result b v n
--   </pre>
--   
--   (omitting a few type class constraints). <tt>b</tt> represents the
--   backend type, <tt>v</tt> the vector space, <tt>n</tt> the numeric
--   field, and <tt>m</tt> the type of monoidal query annotations on the
--   diagram. <a>Options</a> and <a>Result</a> are associated data and type
--   families, respectively, which yield the type of option records and
--   rendering results specific to any particular backend. For <tt>b ~
--   Rasterific</tt>, <tt>v ~ V2</tt>, and <tt>n ~ n</tt>, we have
--   
--   <pre>
--   data Options Rasterific V2 n = RasterificOptions
--          { _size      :: SizeSpec2D n -- ^ The requested size of the output
--          }
--   </pre>
--   
--   <pre>
--   type family Result Rasterific V2 n = 'Image PixelRGBA8'
--   </pre>
--   
--   So the type of <a>renderDia</a> resolves to
--   
--   <pre>
--   renderDia :: Rasterific -&gt; Options Rasterific V2 n -&gt; QDiagram Rasterific V2 n m -&gt; 'Image PixelRGBA8'
--   </pre>
--   
--   which you could call like <tt>renderDia Rasterific (RasterificOptions
--   (mkWidth 250)) myDiagram</tt>.
module Diagrams.Backend.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 <a>Backend</a> and
--   <a>Renderable</a> type classes.
data Rasterific
Rasterific :: Rasterific
type B = Rasterific

-- | Backend-specific rendering options.
data family Options b (v :: Type -> Type) n :: Type

-- | Render a <a>Rasterific</a> diagram to a file with the given size. The
--   format is determined by the extension (<tt>.png</tt>, <tt>.tif</tt>,
--   <tt>.bmp</tt>, <tt>.jpg</tt> and <tt>.pdf</tt> supported. (jpeg
--   quality is 80, use <a>writeJpeg</a> to choose quality).
renderRasterific :: TypeableFloat n => FilePath -> SizeSpec V2 n -> QDiagram Rasterific V2 n Any -> IO ()

-- | Render a <a>Rasterific</a> diagram to a pdf file with given width and
--   height
renderPdf :: TypeableFloat n => Int -> Int -> FilePath -> SizeSpec V2 n -> QDiagram Rasterific V2 n Any -> IO ()

-- | The smallest positive <i>axis-parallel</i> vector that bounds the
--   envelope of an object.
size :: (V a ~ v, N a ~ n, Enveloped a, HasBasis v) => a -> v n

-- | Render a <a>Rasterific</a> diagram to a jpeg file with given quality
--   (between 0 and 100).
writeJpeg :: Word8 -> FilePath -> Result Rasterific V2 n -> IO ()

-- | Delay to wait before showing the next Gif image. The delay is
--   expressed in 100th of seconds.
type GifDelay = Int

-- | Help to control the behaviour of GIF animation looping.
data GifLooping

-- | The animation will stop once the end is reached
LoopingNever :: GifLooping

-- | The animation will restart once the end is reached
LoopingForever :: GifLooping

-- | The animation will repeat n times before stoping
LoopingRepeat :: Word16 -> GifLooping

-- | Render a <a>Rasterific</a> diagram to an animated gif with the given
--   size and uniform delay. Diagrams should be the same size.
animatedGif :: TypeableFloat n => FilePath -> SizeSpec V2 n -> GifLooping -> GifDelay -> [QDiagram Rasterific V2 n Any] -> IO ()

-- | Create a primitive text diagram from the given string, with baseline
--   alignment, envelope and trace based on the <a>BoundingBox</a> of the
--   text. Designed to be a replacement for the function <a>text</a> in
--   Diagrams.TwoD.Text.
texterific :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any

-- | Create a primitive text diagram from the given <a>FontSlant</a>,
--   <a>FontWeight</a>, and string, with baseline alignment, envelope and
--   trace based on the <a>BoundingBox</a> of the text.
texterific' :: (TypeableFloat n, Renderable (Text n) b) => FontSlant -> FontWeight -> String -> QDiagram b V2 n Any

-- | To specify how the palette will be created.
data PaletteOptions
PaletteOptions :: PaletteCreationMethod -> Bool -> Int -> PaletteOptions

-- | Algorithm used to find the palette
[paletteCreationMethod] :: PaletteOptions -> PaletteCreationMethod

-- | Do we want to apply the dithering to the image. Enabling it often
--   reduce compression ratio but enhance the perceived quality of the
--   final image.
[enableImageDithering] :: PaletteOptions -> Bool

-- | Maximum number of color we want in the palette
[paletteColorCount] :: PaletteOptions -> Int

-- | Default palette option, which aim at the best quality and maximum
--   possible colors (256)
defaultPaletteOptions :: PaletteOptions

-- | Turn a list of diagrams into a gif.
rasterGif :: TypeableFloat n => SizeSpec V2 n -> GifLooping -> PaletteOptions -> [(QDiagram Rasterific V2 n Any, Int)] -> Either String ByteString

-- | Render a <a>Rasterific</a> diagram without an alpha channel.
rasterRgb8 :: TypeableFloat n => SizeSpec V2 n -> QDiagram Rasterific V2 n Any -> Image PixelRGB8
instance GHC.Show.Show Diagrams.Backend.Rasterific.Rasterific
instance GHC.Read.Read Diagrams.Backend.Rasterific.Rasterific
instance GHC.Classes.Ord Diagrams.Backend.Rasterific.Rasterific
instance GHC.Classes.Eq Diagrams.Backend.Rasterific.Rasterific
instance GHC.Show.Show n => GHC.Show.Show (Diagrams.Core.Types.Options Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n)
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Core.Types.Backend Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n
instance GHC.Base.Semigroup (Diagrams.Core.Types.Render Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n)
instance GHC.Base.Monoid (Diagrams.Core.Types.Render Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n)
instance Data.Hashable.Class.Hashable n => Data.Hashable.Class.Hashable (Diagrams.Core.Types.Options Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n)
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Core.Types.Renderable (Diagrams.Path.Path Linear.V2.V2 n) Diagrams.Backend.Rasterific.Rasterific
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Text.Text n) Diagrams.Backend.Rasterific.Rasterific
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Image.DImage n Diagrams.TwoD.Image.Embedded) Diagrams.Backend.Rasterific.Rasterific


-- | Convenient creation of command-line-driven executables for rendering
--   diagrams using the Rasterific backend. Create png, tif, bmp, jpg, pdf,
--   or animated GIF files.
--   
--   <ul>
--   <li><a>defaultMain</a> creates an executable which can render a single
--   diagram at various options.</li>
--   <li><a>multiMain</a> is like <a>defaultMain</a> but allows for a list
--   of diagrams from which the user can choose one to render.</li>
--   <li><a>animMain</a> is like <a>defaultMain</a> but for animations
--   instead of diagrams.</li>
--   <li><a>gifMain</a> creates an executable to generate an animated
--   GIF.</li>
--   <li><a>mainWith</a> is a generic form that does all of the above but
--   with a slightly scarier type. See <a>Diagrams.Backend.CmdLine</a>.
--   This form can also take a function type that has a suitable final
--   result (any of arguments to the above types) and <a>Parseable</a>
--   arguments.</li>
--   </ul>
--   
--   If you want to generate diagrams programmatically---<i>i.e.</i> if you
--   want to do anything more complex than what the below functions
--   provide---you have several options.
--   
--   <ul>
--   <li>Use a function with <a>mainWith</a>. This may require making
--   <a>Parseable</a> instances for custom argument types.</li>
--   <li>Make a new <a>Mainable</a> instance. This may require a newtype
--   wrapper on your diagram type to avoid the existing instances. This
--   gives you more control over argument parsing, intervening steps, and
--   diagram creation.</li>
--   <li>Build option records and pass them along with a diagram to
--   <a>mainRender</a> from <a>Diagrams.Backend.CmdLine</a>.</li>
--   <li>You can use <a>renderRasterific</a> to render a diagram to a file
--   directly; see <a>Diagrams.Backend.Rasterific</a>.</li>
--   <li>A more flexible approach is to directly call <a>renderDia</a>; see
--   <a>Diagrams.Backend.Rasterific</a> for more information.</li>
--   </ul>
--   
--   For a tutorial on command-line diagram creation see
--   <a>http://projects.haskell.org/diagrams/doc/cmdline.html</a>.
module Diagrams.Backend.Rasterific.CmdLine

-- | Main entry point for command-line diagram creation. This is the method
--   that users will call from their program <tt>main</tt>. For instance an
--   expected user program would take the following form.
--   
--   <pre>
--   import Diagrams.Prelude
--   import Diagrams.Backend.TheBestBackend.CmdLine
--   
--   d :: Diagram B R2
--   d = ...
--   
--   main = mainWith d
--   </pre>
--   
--   Most backends should be able to use the default implementation. A
--   different implementation should be used to handle more complex
--   interactions with the user.
mainWith :: Mainable d => d -> IO ()

-- | <a>mainWith</a> specialised to <a>Diagram</a> <a>Rasterific</a>.
defaultMain :: Diagram Rasterific -> IO ()
multiMain :: [(String, Diagram Rasterific)] -> IO ()

-- | <tt>animMain</tt> is like <a>defaultMain</a>, but renders an animation
--   instead of a diagram. It takes as input an animation and produces a
--   command-line program which will crudely "render" the animation by
--   rendering one image for each frame, named by extending the given
--   output file name by consecutive integers. For example if the given
--   output file name is <tt>foo/blah.png</tt>, the frames will be saved in
--   <tt>foo/blah001.png</tt>, <tt>foo/blah002.png</tt>, and so on (the
--   number of padding digits used depends on the total number of frames).
--   It is up to the user to take these images and stitch them together
--   into an actual animation format (using, <i>e.g.</i> <tt>ffmpeg</tt>).
--   
--   Of course, this is a rather crude method of rendering animations; more
--   sophisticated methods will likely be added in the future.
--   
--   The <tt>--fpu</tt> option can be used to control how many frames will
--   be output for each second (unit time) of animation.
animMain :: Animation Rasterific V2 Double -> IO ()

-- | Make an animated gif main by pairing diagrams with a delay (<a>Int</a>
--   measured in 100th seconds).
gifMain :: [(Diagram Rasterific, GifDelay)] -> IO ()

-- | Make an animated gif main with the same delay for each diagram.
uniformGifMain :: GifDelay -> [Diagram Rasterific] -> IO ()

-- | Extra options for animated GIFs.
data GifOpts
GifOpts :: Bool -> Bool -> Maybe Int -> GifOpts
[_dither] :: GifOpts -> Bool
[_noLooping] :: GifOpts -> Bool
[_loopRepeat] :: GifOpts -> Maybe Int

-- | 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 <a>Backend</a> and
--   <a>Renderable</a> type classes.
data Rasterific
type B = Rasterific
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.Rasterific.CmdLine.GifOpts
instance Diagrams.Backend.CmdLine.ToResult [(Diagrams.Core.Types.QDiagram Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n Data.Semigroup.Internal.Any, Codec.Picture.Gif.GifDelay)]
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable [(Diagrams.Core.Types.QDiagram Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n Data.Semigroup.Internal.Any, Codec.Picture.Gif.GifDelay)]
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Core.Types.QDiagram Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n Data.Semigroup.Internal.Any)
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable [(GHC.Base.String, Diagrams.Core.Types.QDiagram Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n Data.Semigroup.Internal.Any)]
instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Animation.Animation Diagrams.Backend.Rasterific.Rasterific Linear.V2.V2 n)
