svg-builder-0.1.0.2: DSL for building SVG.

Copyright | (c) 2015 Jeffrey Rosenbluth
License | BSD-style (see LICENSE)
Maintainer | jeffrey.rosenbluth@gmail.com
Safe Haskell | None
Language | Haskell2010

Graphics.Svg.Core

Contents

- Types
- Combinators
- Rendering

Description

svg-builder Core types and functions.

Synopsis

- data Attribute
- data Element
- class ToElement a where
- class Term result where
- makeAttribute :: Text -> Text -> Attribute
- makeElement :: Text -> Element -> Element
- makeElementNoEnd :: Text -> Element
- makeElementDoctype :: Text -> Element
- with :: Element -> [Attribute] -> Element
- renderBS :: Element -> ByteString
- renderToFile :: FilePath -> Element -> IO ()
- renderText :: Element -> Text

# Types

data Attribute Source #

Attribute name value.

Instances

Eq Attribute Source # |
Methods (==) :: Attribute -> Attribute -> Bool # (/=) :: Attribute -> Attribute -> Bool #
Show Attribute Source # |
Methods showsPrec :: Int -> Attribute -> ShowS # show :: Attribute -> String # showList :: [Attribute] -> ShowS #
Hashable Attribute Source # |
Methods hashWithSalt :: Int -> Attribute -> Int # hash :: Attribute -> Int #

data Element Source #

Type of an SVG element.

Instances

Show Element Source # |
Methods showsPrec :: Int -> Element -> ShowS # show :: Element -> String # showList :: [Element] -> ShowS #
IsString Element Source # |
Methods fromString :: String -> Element #
Monoid Element Source # |
Methods mempty :: Element # mappend :: Element -> Element -> Element # mconcat :: [Element] -> Element #
Term Element Source # |
Methods term :: Text -> [Attribute] -> Element Source #
(~) * e Element => Term (e -> Element) Source # |
Methods term :: Text -> [Attribute] -> e -> Element Source #

class ToElement a where Source #

Things that can be converted to SVG elements.

Minimal complete definition

toElement

Methods

toElement :: a -> Element Source #

Instances

ToElement String Source # |
Methods toElement :: String -> Element Source #
ToElement Text Source # |
Methods toElement :: Text -> Element Source #
ToElement Text Source # |
Methods toElement :: Text -> Element Source #

class Term result where Source #

Used to make specific SVG element builders.

Minimal complete definition

term

Methods

term :: Text -> [Attribute] -> result Source #

Used for constructing elements e.g. `term "circle"` yields `circle_`.

Instances

Term Element Source # |
Methods term :: Text -> [Attribute] -> Element Source #
(~) * e Element => Term (e -> Element) Source # |
Methods term :: Text -> [Attribute] -> e -> Element Source #

# Combinators

makeAttribute Source #

Arguments

:: Text | Attribute name.
-> Text | Attribute value.
-> Attribute |

Make an attribute.

makeElement :: Text -> Element -> Element Source #

Make an SVG element builder

makeElementNoEnd :: Text -> Element Source #

Make an SVG element with no end tag, contains only attributes.

makeElementDoctype :: Text -> Element Source #

Make an SVG doctype element builder.

with :: Element -> [Attribute] -> Element Source #

Add a list of attributes to an element

# Rendering

renderBS :: Element -> ByteString Source #

Render a `Element` to lazy bytestring.

renderToFile :: FilePath -> Element -> IO () Source #

Render a `Element` to a file.

renderText :: Element -> Text Source #

Reder an `Element` to lazy text.