2014-09-30 22:05:29 +00:00
|
|
|
module Diagram where
|
|
|
|
|
|
|
|
import Diagrams.Prelude
|
|
|
|
import Diagrams.Backend.Cairo
|
|
|
|
import Meshparser
|
|
|
|
import Util
|
|
|
|
|
|
|
|
|
2014-10-01 21:02:43 +00:00
|
|
|
-- |Holds the properties for a Diagram, like thickness of 2d points etc.
|
2014-10-01 19:48:31 +00:00
|
|
|
data DiagProp = MkProp {
|
|
|
|
-- |Get the thickness of the dot.
|
|
|
|
getThickness :: Double
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 22:05:29 +00:00
|
|
|
-- |Create the Diagram from the VTable.
|
2014-10-01 19:48:31 +00:00
|
|
|
diagFromVTable :: DiagProp -> VTable -> Diagram Cairo R2
|
|
|
|
diagFromVTable prop meshArr
|
2014-10-01 18:17:59 +00:00
|
|
|
= position (zip (map mkPoint . filter (inRange 0 500) $ meshArr)
|
2014-09-30 22:05:29 +00:00
|
|
|
(repeat dot)) # moveTo (p2(-250, -250))
|
2014-10-01 01:03:09 +00:00
|
|
|
`atop` square 500 # lwG 0.05 # bg white
|
2014-10-01 19:48:31 +00:00
|
|
|
where dot = (circle $ getThickness prop :: Diagram Cairo R2) # fc black
|
2014-09-30 22:05:29 +00:00
|
|
|
mkPoint (x,y) = p2 (x,y)
|
|
|
|
|
|
|
|
-- |Create the Diagram from a String.
|
2014-10-01 19:48:31 +00:00
|
|
|
diagFromString :: DiagProp -> String -> Diagram Cairo R2
|
|
|
|
diagFromString prop mesh
|
|
|
|
= diagFromVTable prop .
|
|
|
|
meshToArr $
|
|
|
|
mesh
|