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


-- | Pretty rendering of Ascii diagram into svg or png.
--   
--   Transform Ascii art diagram like this:
--   
--   <pre>
--   ,               /---------+
--   +---------+     |         |
--   |  ASCII  +----&gt;| Diagram |
--   +---------+     |         |
--   |         |     +--+------/
--   \---*-----/&lt;=======/
--   </pre>
--   
--   Into this:
--   
--   
--   See the documentation of the Text.AsciiDiagram module for the
--   description of the input format.
@package asciidiagram
@version 1.3.3.2


-- | This module gives access to the ascii diagram parser and SVG renderer.
--   
--   Ascii diagram, transform your ASCII art drawing to a nicer
--   representation
--   
--   <pre>
--                   /---------+
--   +---------+     |         |
--   |  ASCII  +----&gt;| Diagram |
--   +---------+     |         |
--   |{flat}   |     +--+------/
--   \---*-----/&lt;=======/
--   ::: .flat .filled_shape { fill: #DDD; }
--   </pre>
--   
--   
--   To render the diagram as a PNG file, you have to use the library
--   rasterific-svg and JuicyPixels.
--   
--   As a sample usage, to save a diagram to png, you can use the following
--   snippet.
--   
--   <pre>
--   import Codec.Picture( writePng )
--   import Text.AsciiDiagram( imageOfDiagram )
--   import Graphics.Rasterific.Svg( loadCreateFontCache )
--   
--   saveDiagramToFile :: FilePath -&gt; Diagram -&gt; IO ()
--   saveDiagramToFile path diag = do
--     cache &lt;- loadCreateFontCache "asciidiagram-fonty-fontcache"
--     imageOfDiagram cache 96 diag
--     writePng path img
--   </pre>
module Text.AsciiDiagram

-- | Transform an Ascii diagram to a SVG document which can be saved or
--   converted to an image.
svgOfDiagram :: Diagram -> Document

-- | Analyze an ascii diagram and extract all it's features.
parseAsciiDiagram :: Text -> Diagram

-- | Helper function helping you save a diagram as a SVG file on disk.
saveAsciiDiagramAsSvg :: FilePath -> Diagram -> IO ()

-- | Render a Diagram as an image. The Dpi is 96. The IO dependency is
--   there to allow loading of the font files used in the document.
imageOfDiagram :: FontCache -> Diagram -> IO (Image PixelRGBA8)

-- | Render a Diagram into a PDF file. IO dependency to allow loading of
--   the font files used in the document.
pdfOfDiagram :: FontCache -> Diagram -> IO ByteString

-- | Transform an Ascii diagram to a SVG document which can be saved or
--   converted to an image, with a customizable grid size.
svgOfDiagramAtSize :: GridSize -> Document -> Diagram -> Document

-- | Simple type describing the grid size used during render.
data GridSize
GridSize :: !Float -> !Float -> !Float -> GridSize

-- | Width of a cell (in pixel)
[_gridCellWidth] :: GridSize -> !Float

-- | Height of a cell (in pixel)
[_gridCellHeight] :: GridSize -> !Float

-- | Coefficient used to space adjacent shapes, set to 0 if you want to
--   remove space between them.
[_gridShapeContraction] :: GridSize -> !Float

-- | Default grid size used in the simple render functions
defaultGridSize :: GridSize

-- | Helper function helping you save a diagram as a SVG file on disk with
--   a customized grid size.
saveAsciiDiagramAsSvgAtSize :: FilePath -> GridSize -> Diagram -> IO ()

-- | Render a Diagram as an image with a custom grid size. The Dpi is 96.
--   The IO dependency is there to allow loading of the font files used in
--   the document.
imageOfDiagramAtSize :: FontCache -> GridSize -> Diagram -> IO (Image PixelRGBA8)

-- | Render a Diagram into a PDF file with a custom grid size. IO
--   dependency to allow loading of the font files used in the document.
pdfOfDiagramAtSize :: FontCache -> GridSize -> Diagram -> IO ByteString
defaultLibrary :: GridSize -> Document

-- | Describe the geomtry of a full Ascii Diagram document
data Diagram
Diagram :: Set Element -> !Int -> !Int -> [Text] -> Diagram

-- | All the extracted tshapes
[_diagramElements] :: Diagram -> Set Element

-- | Width in characters of the document
[_diagramCellWidth] :: Diagram -> !Int

-- | Height in characters of the document
[_diagramCellHeight] :: Diagram -> !Int

-- | CSS styles associated to the document.
[_diagramStyles] :: Diagram -> [Text]

-- | Describe where to place a text snippet.
data TextZone
TextZone :: Point -> Text -> TextZone
[_textZoneOrigin] :: TextZone -> Point
[_textZoneContent] :: TextZone -> Text

-- | Shape extracted from the text
data Shape
Shape :: ![ShapeElement] -> !Bool -> !Set Text -> ![Element] -> Shape

-- | Elements composing the shape.
[shapeElements] :: Shape -> ![ShapeElement]

-- | When False it's just lines possibly with an arrow, when True it's a
--   polygon.
[shapeIsClosed] :: Shape -> !Bool

-- | Tags "{tagname}" placed inside the shape.
[shapeTags] :: Shape -> !Set Text

-- | List of eleents contained in this shape
[shapeChildren] :: Shape -> ![Element]

-- | Describe a composant of shapes. Can be composed of anchors like "+*/\"
--   or segments.
data ShapeElement
ShapeAnchor :: !Point -> !Anchor -> ShapeElement
ShapeSegment :: !Segment -> ShapeElement

-- | Define the different connection points between the segments.
data Anchor

-- | Associated to <a>+</a>
AnchorMulti :: Anchor

-- | Associated to <a>/</a>
AnchorFirstDiag :: Anchor

-- | Associated to '\'
AnchorSecondDiag :: Anchor

-- | Kind of "end anchor", without continuation.
AnchorPoint :: Anchor

-- | Used as a <a>*</a>
AnchorBullet :: Anchor

-- | Associated to <a>^</a>
AnchorArrowUp :: Anchor

-- | Associated to <tt>V</tt>
AnchorArrowDown :: Anchor

-- | Associated to <a>&lt;</a>
AnchorArrowLeft :: Anchor

-- | Associated to <a>&gt;</a>
AnchorArrowRight :: Anchor

-- | Define an horizontal or vertical segment.
data Segment
Segment :: {-# UNPACK #-} !Point -> {-# UNPACK #-} !Point -> !SegmentKind -> !SegmentDraw -> Segment
[_segStart] :: Segment -> {-# UNPACK #-} !Point
[_segEnd] :: Segment -> {-# UNPACK #-} !Point
[_segKind] :: Segment -> !SegmentKind
[_segDraw] :: Segment -> !SegmentDraw

-- | Helper data for segment composed of only one character
data SegmentKind
SegmentHorizontal :: SegmentKind
SegmentVertical :: SegmentKind

-- | Differentiate between elements drawn with a solid line or with dashed
--   lines.
data SegmentDraw
SegmentSolid :: SegmentDraw
SegmentDashed :: SegmentDraw

-- | Position of a an element in the character grids
type Point = V2 Int
instance GHC.Show.Show Text.AsciiDiagram.CharBoard
instance GHC.Classes.Eq Text.AsciiDiagram.CharBoard
instance Text.AsciiDiagram.RangeDecomposable Text.AsciiDiagram.Geometry.Shape
instance Text.AsciiDiagram.RangeDecomposable Text.AsciiDiagram.Geometry.TextZone
