DIAGRAM: abstract point to text conversion out a little

This commit is contained in:
hasufell 2014-10-10 15:34:18 +02:00
parent 01e2dd7802
commit 1540bf443e
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020

View File

@ -105,17 +105,21 @@ coordPoints = Diag cp
dot = (circle $ t p :: Diagram Cairo R2) # fc black
-- |Creates a Diagram from a point that shows the coordinates
-- in text format, such as "(1.0, 2.0)".
pointToTextCoord :: PT -> Diagram Cairo R2
pointToTextCoord pt =
text ("(" ++ show x ++ ", " ++ show y ++ ")") # scale 10
where
(x, y) = unp2 pt
coordPointsText :: Diag
coordPointsText = Diag cpt
where
cpt _ vt =
position $
zip vt
((\(x, y) -> (flip (<>) (square 1 # lw none) .
text $ ("(" ++ show x ++ ", " ++ show y ++ ")")) #
scale 10 # translate (r2 (0, 10))) <$>
unp2 <$>
vt)
zip vt (pointToTextCoord <$> vt) # translate (r2 (0, 10))
-- |Create a diagram which shows the points of the convex hull.
@ -137,11 +141,7 @@ convexHullPointsText = Diag chpt
chpt _ vt =
position $
zip vtch
((\(x, y) -> (flip (<>) (square 1 # lw none) .
text $ ("(" ++ show x ++ ", " ++ show y ++ ")")) #
scale 10 # translate (r2 (0, 10))) <$>
unp2 <$>
vtch)
(pointToTextCoord <$> vtch) # translate (r2 (0, 10))
where
vtch = grahamGetCH vt