cga/Diagram.hs

31 lines
872 B
Haskell
Raw Normal View History

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.
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.
diagFromVTable :: DiagProp -> VTable -> Diagram Cairo R2
diagFromVTable prop meshArr
= position (zip (map mkPoint . filter (inRange 0 500) $ meshArr)
2014-09-30 22:05:29 +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
2014-09-30 22:05:29 +00:00
mkPoint (x,y) = p2 (x,y)
-- |Create the Diagram from a String.
diagFromString :: DiagProp -> String -> Diagram Cairo R2
diagFromString prop mesh
= diagFromVTable prop .
meshToArr $
mesh