www.idziorek.net | blog | contact
May 2018

A Minimalistic SVG Generator

A minimalistic SVG generator for my humble requirements. They might grow someday however…

The SVG in the following screenshot was generated from the following code to demonstrate a simple use case.

The source code below was auto-fetched from: https://gitweb.softwarefools.com/?p=miguel/haskell.git;a=blob;f=simpleSVG/TestSvg.hs

-- can be run simply via: stack runghc TestSvg.hs > example1.svg

import SimpleSvg

svgExample1      = svgAddList (svgEmpty (svgShGray 200) 300 200) $
                    [ svgRedLine (0,0) (200,200)
                     ,svgRedLine (300,0) (100,200)
                     ,svgBluePoint (33,133)
                     ,svgBluePoint (33,22)
                     ,svgBluePoint (66,25)
                     ,svgFilledTriangle svgBlack svgWhite (20,20) (100,100) (10,90)
                     ,svgFilledCircle svgWhite svgGreen (150,120) 30
                    ]++
                    map (svgBluePoint . (,) 250) [50,60..150]

main = putStr $ svgGenerate svgExample1

Source Files