summaryrefslogtreecommitdiff
path: root/testsuite/tests/dph/quickhull/SVG.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/dph/quickhull/SVG.hs')
-rw-r--r--testsuite/tests/dph/quickhull/SVG.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/tests/dph/quickhull/SVG.hs b/testsuite/tests/dph/quickhull/SVG.hs
new file mode 100644
index 0000000000..f4183a77d6
--- /dev/null
+++ b/testsuite/tests/dph/quickhull/SVG.hs
@@ -0,0 +1,34 @@
+
+module SVG where
+
+-- Making a SVG diagram of the points and hull
+makeSVG :: [(Int, Int)] -> [(Int, Int)] -> String
+makeSVG points hull
+ = unlines
+ $ [ "<svg width=\"100%\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">" ]
+ ++ [svgPolygon hull]
+ ++ map svgPoint points
+ ++ map svgPointHull hull
+ ++ ["</svg>"]
+
+svgPolygon :: [(Int, Int)] -> String
+svgPolygon points
+ = "<polygon"
+ ++ " points=\"" ++ (concat [show x ++ "," ++ show y ++ " " | (x, y) <- points]) ++ "\""
+ ++ " style=\"fill:#d0d0ff;stroke:#000000;stroke-width:1\""
+ ++ "/>"
+
+svgPoint :: (Int, Int) -> String
+svgPoint (x, y)
+ = "<circle cx=\"" ++ show x ++ "\" cy=\"" ++ show y ++ "\" r=\"0.5\""
+ ++ " style=\"stroke:#000000\""
+ ++ "/>"
+
+svgPointHull :: (Int, Int) -> String
+svgPointHull (x, y)
+ = "<circle cx=\"" ++ show x ++ "\" cy=\"" ++ show y ++ "\" r=\"1\""
+ ++ " style=\"stroke:#ff0000\""
+ ++ "/>"
+
+roundPoints :: [(Double, Double)] -> [(Int, Int)]
+roundPoints ps = [(round x, round y) | (x, y) <- ps]