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


-- | SVG backend for diagrams drawing EDSL.
--   
--   This package provides a modular backend for rendering diagrams created
--   with the diagrams EDSL to SVG files. It uses <tt>svg-builder</tt> to
--   be a native Haskell backend, making it suitable for use on any
--   platform.
--   
--   The package provides the following modules:
--   
--   <ul>
--   <li><a>Diagrams.Backend.SVG.CmdLine</a> - if you're just getting
--   started with diagrams, begin here.</li>
--   <li><a>Diagrams.Backend.SVG</a> - look at this next. The general API
--   for the SVG backend.</li>
--   </ul>
--   
--   Additional documentation can be found in the README file distributed
--   with the source tarball or viewable on GitHub:
--   <a>https://github.com/diagrams/diagrams-svg/blob/master/README.md</a>.
@package diagrams-svg
@version 1.5


-- | A full-featured rendering backend for diagrams producing SVG files,
--   implemented natively in Haskell (making it easy to use on any
--   platform).
--   
--   To invoke the SVG backend, you have three options.
--   
--   <ul>
--   <li>You can use the <a>Diagrams.Backend.SVG.CmdLine</a> module to
--   create standalone executables which output SVG images when
--   invoked.</li>
--   <li>You can use the <a>renderSVG</a> or <a>renderPretty</a> functions
--   provided by this module, which give 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). The
--   only difference between the two functions is that <a>renderPretty</a>,
--   pretty prints the SVG output.</li>
--   <li>For the most flexibility (<i>e.g.</i> if you want access to the
--   resulting SVG 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>SVG</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 numerical
--   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 ~
--   SVG</tt>, <tt>v ~ V2</tt>, we have
--   
--   <pre>
--   data    Options SVG V2 n = SVGOptions
--       { _size            :: SizeSpec V2 n   -- ^ The requested size.
--       , _svgDefinitions  :: Maybe Element
--                             -- ^ Custom definitions that will be added to the @defs@
--                             --   section of the output.
--       , _idPrefix        :: T.Text
--       , _svgAttributes   :: [Attribute]
--                             -- ^ Attributes to apply to the entire svg element.
--       , _generateDoctype :: Bool
--       }
--   </pre>
--   
--   <pre>
--   data family Render SVG V2 n = R 'SvgRenderM n'
--   </pre>
--   
--   <pre>
--   type family Result SVG V2 n = <a>Element</a>
--   </pre>
--   
--   So the type of <a>renderDia</a> resolves to
--   
--   <pre>
--   renderDia :: SVG -&gt; Options SVG V2 n -&gt; QDiagram SVG V2 n m -&gt; <a>Element</a>
--   </pre>
--   
--   which you could call like <tt>renderDia SVG (SVGOptions (mkWidth 250)
--   Nothing "" [] True) myDiagram</tt> (if you have the
--   <tt>OverloadedStrings</tt> extension enabled; otherwise you can use
--   'Text.pack ""'). (In some situations GHC may not be able to infer the
--   type <tt>m</tt>, in which case you can use a type annotation to
--   specify it; it may be useful to simply use the type synonym
--   <tt>Diagram SVG = QDiagram SVG V2 Double Any</tt>.) This returns an
--   <a>Element</a> value, which you can, <i>e.g.</i> render to a
--   <tt>ByteString</tt> using <a>renderBS</a> from the 'svg-builder'
--   package.
module Diagrams.Backend.SVG

-- | <tt>SVG</tt> is simply a token used to identify this rendering backend
--   (to aid type inference).
data SVG
SVG :: SVG
type B = SVG

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

-- | Lens onto the size of the svg options.
sizeSpec :: forall n f. Functor f => (SizeSpec V2 n -> f (SizeSpec V2 n)) -> Options SVG V2 n -> f (Options SVG V2 n)

-- | Lens onto the svg definitions of the svg options.
svgDefinitions :: forall n f. Functor f => (Maybe Element -> f (Maybe Element)) -> Options SVG V2 n -> f (Options SVG V2 n)

-- | Lens onto the idPrefix of the svg options. This is the prefix given to
--   clipping paths to distinguish them from other svg files in the same
--   web page.
idPrefix :: forall n f. Functor f => (Text -> f Text) -> Options SVG V2 n -> f (Options SVG V2 n)

-- | Lens onto the svgAttributes field of the svg options. This field is
--   provided to supply SVG attributes to the entire diagram.
svgAttributes :: forall n f. Functor f => ([Attribute] -> f [Attribute]) -> Options SVG V2 n -> f (Options SVG V2 n)

-- | Lens onto the generateDoctype field of the svg options. Set to False
--   if you don't want a doctype tag included in the output.
generateDoctype :: forall n f. Functor f => (Bool -> f Bool) -> Options SVG V2 n -> f (Options SVG V2 n)

-- | Set the class for a particular SVG diagram
svgClass :: SVGFloat n => String -> QDiagram SVG V2 n Any -> QDiagram SVG V2 n Any

-- | Set the id for a particular SVG diagram
svgId :: SVGFloat n => String -> QDiagram SVG V2 n Any -> QDiagram SVG V2 n Any

-- | Set the title text for a particular SVG diagram
svgTitle :: SVGFloat n => String -> QDiagram SVG V2 n Any -> QDiagram SVG V2 n Any

-- | Set an arbitrary attribute for a particular SVG diagram
svgAttr :: SVGFloat n => String -> String -> QDiagram SVG V2 n Any -> QDiagram SVG V2 n Any

-- | Constaint on number type that diagrams-svg can use to render an SVG.
--   This includes the common number types: Double, Float
type SVGFloat n = (Show n, TypeableFloat n)

-- | Render a diagram as an SVG, writing to the specified output file and
--   using the requested size.
renderSVG :: SVGFloat n => FilePath -> SizeSpec V2 n -> QDiagram SVG V2 n Any -> IO ()

-- | Render a diagram as an SVG, writing to the specified output file and
--   using the backend options. The id prefix is derived from the basename
--   of the output file.
renderSVG' :: SVGFloat n => FilePath -> Options SVG V2 n -> QDiagram SVG V2 n Any -> IO ()

-- | Render a diagram as a pretty printed SVG.
renderPretty :: SVGFloat n => FilePath -> SizeSpec V2 n -> QDiagram SVG V2 n Any -> IO ()

-- | Render a diagram as a pretty printed SVG to the specified output file
--   and using the backend options. The id prefix is derived from the
--   basename of the output file.
renderPretty' :: SVGFloat n => FilePath -> Options SVG V2 n -> QDiagram SVG V2 n Any -> IO ()

-- | Load images (JPG<i>PNG</i>...) in a SVG specific way.
loadImageSVG :: SVGFloat n => FilePath -> IO (QDiagram SVG V2 n Any)
instance Graphics.Rendering.SVG.SVGFloat n => Diagrams.Core.Types.Backend Diagrams.Backend.SVG.SVG Linear.V2.V2 n
instance GHC.Classes.Eq Graphics.Svg.Core.Element
instance GHC.Classes.Eq n => GHC.Classes.Eq (Diagrams.Core.Types.Options Diagrams.Backend.SVG.SVG Linear.V2.V2 n)
instance Data.Hashable.Class.Hashable n => Data.Hashable.Class.Hashable (Diagrams.Core.Types.Options Diagrams.Backend.SVG.SVG Linear.V2.V2 n)
instance GHC.Internal.Base.Monoid (Diagrams.Core.Types.Render Diagrams.Backend.SVG.SVG Linear.V2.V2 n)
instance Graphics.Rendering.SVG.SVGFloat n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Image.DImage n (Diagrams.TwoD.Image.Native Diagrams.Backend.SVG.Img)) Diagrams.Backend.SVG.SVG
instance Graphics.Rendering.SVG.SVGFloat n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Image.DImage n Diagrams.TwoD.Image.Embedded) Diagrams.Backend.SVG.SVG
instance Graphics.Rendering.SVG.SVGFloat n => Diagrams.Core.Types.Renderable (Diagrams.Path.Path Linear.V2.V2 n) Diagrams.Backend.SVG.SVG
instance Graphics.Rendering.SVG.SVGFloat n => Diagrams.Core.Types.Renderable (Diagrams.TwoD.Text.Text n) Diagrams.Backend.SVG.SVG
instance GHC.Internal.Base.Semigroup (Diagrams.Core.Types.Render Diagrams.Backend.SVG.SVG Linear.V2.V2 n)
instance GHC.Internal.Show.Show Diagrams.Backend.SVG.SVG


-- | Convenient creation of command-line-driven executables for rendering
--   diagrams using the SVG backend.
--   
--   <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>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 subtable 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>renderSVG</a> to render a diagram to a file
--   directly; see <a>Diagrams.Backend.SVG</a>.</li>
--   <li>A more flexible approach is to directly call <a>renderDia</a>; see
--   <a>Diagrams.Backend.SVG</a> for more information.</li>
--   </ul>
--   
--   For a tutorial on command-line diagram creation see
--   <a>https://diagrams.github.io/doc/cmdline.html</a>.
module Diagrams.Backend.SVG.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 ()
defaultMain :: SVGFloat n => QDiagram SVG V2 n Any -> IO ()
multiMain :: SVGFloat n => [(String, QDiagram SVG V2 n Any)] -> IO ()

-- | <tt>SVG</tt> is simply a token used to identify this rendering backend
--   (to aid type inference).
data SVG
type B = SVG
instance Graphics.Rendering.SVG.SVGFloat n => Diagrams.Backend.CmdLine.Mainable [(GHC.Internal.Base.String, Diagrams.Core.Types.QDiagram Diagrams.Backend.SVG.SVG Linear.V2.V2 n GHC.Internal.Data.Semigroup.Internal.Any)]
instance Graphics.Rendering.SVG.SVGFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Core.Types.QDiagram Diagrams.Backend.SVG.SVG Linear.V2.V2 n GHC.Internal.Data.Semigroup.Internal.Any)
instance Diagrams.Backend.CmdLine.Parseable Diagrams.Backend.SVG.CmdLine.PrettyOpt
