(C) Roger Whittaker 2015
roger@disruptive.org.uk
Free software licenced under the GPL

> module Svg (processsvg)

> where

> import Penrose
> import Utils

> col "0"  = "#0000FF" -- blue
> col "1"  = "#FFFF00" -- yellow
> col "2"  = "#00FF00" -- green
> col "3"  = "#FF00FF" -- magenta
> col "4"  = "#FF0000" -- red
> col "5"  = "#00FFFF" -- aqua

> col "6"  = "#000066" -- navy
> col "7"  = "#666600" -- dirty green?
> col "8"  = "#006600" -- pakistan green
> col "9"  = "#660066" -- purple
> col "10" = "#660000" -- maroon
> col "11" = "#006666" -- blue green

> col "12" = "#9999FF" -- 
> col "13" = "#FFFF99"
> col "14" = "#99FF99"
> col "15" = "#FF99FF"
> col "16" = "#FF9999"
> col "17" = "#99FFFF"

> col  _   = "none"


> svglines :: [Char] -> [Char]
> svglines x = "<polygon points=\"" ++
>              (coordinates x)!!0    ++ " " ++
>              (coordinates x)!!1    ++ " " ++
>              (coordinates x)!!2    ++ " " ++
>              (coordinates x)!!3    ++
>              "\""                 ++

--> cut out for no fill

>              " style=\"fill:"     ++
>              col (kind x)         ++

--> / and add next line
-- >              " style=\"fill:white"     ++

>              ";stroke:black;stroke-width:0.01\" />"

> svgheader :: [[Char]]
> svgheader = ["<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"1000px\" " ++ 
>                "height=\"1000px\" viewBox=\"-200 -200 200 210 \" style=\"background: white\">"
>              ,"<g transform=\"translate(-100 -100)\">"
>              ,"<g transform=\"scale(5)\">"
>              ]

> svgfooter :: ([[Char]], b) -> [[Char]]
> svgfooter x = ["<polygon points=\"-21,22 21,22 21,20 -21,20\" style=\"fill:white;stroke:black;stroke-width:0.1\" />"
>               ,"<text x=\"-20\" y=\"20.8\" fill=\"black\" style=\"font-size:0.75pt\">" ++ format (fst x)!!0 ++ "</text>"
>               ,"<text x=\"-20\" y=\"21.8\" fill=\"black\" style=\"font-size:0.75pt\">" ++ format (fst x)!!1 ++ "</text>"
>               ,"<text x=\"13\" y = \"21.8\" fill=\"black\" style=\"font-size:0.4pt\">" ++ genby "gppg" (fst x) ++ "</text>"
>               ,"</g>"
>               ,"</g>"
>               ,"</svg>"
>               ]

> tosvg :: ([[Char]], [[Char]]) -> [Char]
> tosvg x = unlines (svgheader) ++ unlines (map svglines (snd x)) ++ unlines (svgfooter x)

> processsvg :: ([[Char]], [[Char]]) -> [Char]
> processsvg = tosvg

