Přejít na soubor
rhiannon morris 39bb6a4e04 update for ghc 9.4.7 2023-12-23 18:27:14 +01:00
examples Initial Commit 2016-02-15 09:41:04 -05:00
src/Graphics update for ghc 9.4.7 2023-12-23 18:27:14 +01:00
.gitignore Support GHC-8.2 2017-06-17 00:53:12 +03:00
.travis.yml Add 8.6 and 8.8 travis jobs 2019-11-02 12:46:17 +02:00
CHANGELOG.md CHANGELOG for 0.1.1-r2 2019-12-06 06:11:33 -06:00
LICENSE Initial Commit 2016-02-15 09:41:04 -05:00
README.md Ready badge 2016-02-15 09:45:48 -05:00
Setup.hs Initial Commit 2016-02-15 09:41:04 -05:00
stack.yaml replace old stack.yaml 2018-05-09 21:41:50 -05:00
svg-builder.cabal update for ghc 9.4.7 2023-12-23 18:27:14 +01:00

README.md

svg-builder Hackage

Simple DSL for writing fast SVG.

Example

{-# LANGUAGE OverloadedStrings #-}

import Graphics.Svg

svg :: Element -> Element
svg content =
     doctype
  <> with (svg11_ content) [Version_ <<- "1.1", Width_ <<- "300", Height_ <<- "200"]

contents :: Element
contents =
     rect_   [ Width_ <<- "100%", Height_ <<- "100%", "red" ->> Fill_]
  <> circle_ [ Cx_ <<- "150", Cy_ <<- "100", R_ <<- "80", Fill_ <<- "green"]
  <> text_   [ X_ <<- "150", Y_ <<- "125", Font_size_ <<- "60"
             , Text_anchor_ <<- "middle", Fill_ <<- "white"] "SVG"

main :: IO ()
main = do
  print $ svg contents

SVG

{-# LANGUAGE OverloadedStrings #-}

import Graphics.Svg

svg :: Element -> Element
svg content =
     doctype
  <> with (svg11_ content) [Version_ <<- "1.1", Width_ <<- "482", Height_ <<- "340"]

logo :: Element
logo =
     path_ [ Fill_ <<- "#352950"
           , D_ <<- ( mA 0 340 <> lA 113 170 <> lA 0 0 <> lA 85 0
                   <> lA 198 170 <> lA 85 340 <> lA 0 340 <> z <> mA 0 340 ) ]
  <> path_ [ Fill_ <<- "#4A3A74"
           , D_ <<- ( mA 113 340 <> lA 226 170 <> lA 113 0 <> lA 198 0
                   <> lA 425 340 <> lA 340 340 <> lA 269 234 <> lA 198 340
                   <> lA 113 340 <> z <> mA 113 340 ) ]
  <> path_ [ Fill_ <<- "#7C3679"
           , D_ <<- ( mA 387 241 <> lA 350 184 <> lA 482 184 <> lA 482 241
                   <> lA 387 241 <> z <> mA 387 241 ) ]
  <> path_ [ Fill_ <<- "#7C3679"
           , D_ <<- ( mA 331 156 <> lA 293 99 <> lA 482 99 <> lA 482 156
                   <> lA 331 156 <> z <> mA 331 156 ) ]

main :: IO ()
main = do
  print $ svg logo

Logo