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
|
2014-10-02 12:30:08 +00:00
|
|
|
diagFromVTable prop vt
|
|
|
|
= position (zip (map mkPoint . filter (inRange 0 500) $ vt)
|
2014-10-02 11:13:58 +00:00
|
|
|
(repeat dot)) # moveTo (p2(-250, -250))
|
|
|
|
`atop` square 500 # lwG 0.05 # bg white
|
|
|
|
where dot = (circle $
|
|
|
|
getThickness prop :: Diagram Cairo R2) # fc black
|
|
|
|
mkPoint (x,y) = p2 (x,y)
|
2014-09-30 22:05:29 +00:00
|
|
|
|
|
|
|
-- |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
|