Skip to content

Instantly share code, notes, and snippets.

@rnagasam
Created June 13, 2018 03:40
Show Gist options
  • Save rnagasam/f839e113b626b5936ac2d20c7891899c to your computer and use it in GitHub Desktop.
Save rnagasam/f839e113b626b5936ac2d20c7891899c to your computer and use it in GitHub Desktop.
svg-builder example2
{-# LANGUAGE OverloadedStrings #-}
-- Translated from https://upload.wikimedia.org/wikipedia/commons/b/b7/Vamos_matroid.svg
-- For an absolutely amazing collection of Mathematical illustrations take a
-- look at https://commons.wikimedia.org/wiki/User:David_Eppstein/Gallery
import Graphics.Svg
svg :: Element -> Element
svg content =
doctype
<> with (svg11_ content) [ Version_ <<- "1.1", Width_ <<- "225", Height_ <<- "315" ]
contents :: Element
contents =
polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#FFFFFF"
, Points_ <<- "95.638,303.453 160.332,267.084 81.413,131.155 16.719,167.523"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#0081CD"
, Points_ <<- "95.638,303.453 160.332,267.084 81.413,131.155 16.719,167.523"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#FFFFFF"
, Points_ <<- "95.638,303.453 160.332,267.084 81.413,131.155 16.719,167.523"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#FFFFFF"
, Points_ <<- "143.587,183.845 95.638,303.453 160.332,267.084 208.281,147.478"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#FFFFFF"
, Points_ <<- "81.413,131.155 208.281,147.478 143.587,183.845 16.719,167.523"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#0081CD"
, Points_ <<- "64.669,47.917 16.719,167.523 81.413,131.155 129.362,11.548"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#0081CD"
, Points_ <<- "143.587,183.845 95.638,303.453 160.332,267.084 208.281,147.478"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#0081CD"
, Points_ <<- "81.413,131.155 208.281,147.478 143.587,183.845 16.719,167.523"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#FFFFFF"
, Points_ <<- "143.587,183.846 208.281,147.478 129.363,11.548 64.669,47.916"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> polygon_ [ Opacity_ <<- "0.5", Fill_ <<- "#0081CD"
, Points_ <<- "143.587,183.846 208.281,147.478 129.363,11.548 64.669,47.916"
, Stroke_ <<- "#000000", Stroke_width_ <<- "2", Stroke_linejoin_ <<- "bevel" ]
<> circle_ [ Fill_ <<- "#BC1E47", Cx_ <<- "129.362", Cy_ <<- "11.548", R_ <<- "6" ]
<> circle_ [ Fill_ <<- "#BC1E47", Cx_ <<- "64.669", Cy_ <<- "47.917", R_ <<- "6" ]
<> circle_ [ Fill_ <<- "#BC1E47", Cx_ <<- "143.587", Cy_ <<- "183.845", R_ <<- "6" ]
<> circle_ [ Fill_ <<- "#BC1E47", Cx_ <<- "208.281", Cy_ <<- "147.478", R_ <<- "6" ]
<> circle_ [ Fill_ <<- "#BC1E47", Cx_ <<- "16.719", Cy_ <<- "167.523", R_ <<- "6" ]
<> circle_ [ Fill_ <<- "#BC1E47", Cx_ <<- "81.413", Cy_ <<- "131.155", R_ <<- "6" ]
<> circle_ [ Fill_ <<- "#BC1E47", Cx_ <<- "160.332", Cy_ <<- "267.084", R_ <<- "6" ]
<> circle_ [ Fill_ <<- "#BC1E47", Cx_ <<- "95.638", Cy_ <<- "303.453", R_ <<- "6" ]
main :: IO ()
main = do
print $ svg contents
renderToFile "./examples/vamos-matroid.svg" $ svg contents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment