DIAGRAM: abstract point to text conversion out a little
This commit is contained in:
parent
01e2dd7802
commit
1540bf443e
22
Diagram.hs
22
Diagram.hs
@ -105,17 +105,21 @@ coordPoints = Diag cp
|
|||||||
dot = (circle $ t p :: Diagram Cairo R2) # fc black
|
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
|
||||||
coordPointsText = Diag cpt
|
coordPointsText = Diag cpt
|
||||||
where
|
where
|
||||||
cpt _ vt =
|
cpt _ vt =
|
||||||
position $
|
position $
|
||||||
zip vt
|
zip vt (pointToTextCoord <$> vt) # translate (r2 (0, 10))
|
||||||
((\(x, y) -> (flip (<>) (square 1 # lw none) .
|
|
||||||
text $ ("(" ++ show x ++ ", " ++ show y ++ ")")) #
|
|
||||||
scale 10 # translate (r2 (0, 10))) <$>
|
|
||||||
unp2 <$>
|
|
||||||
vt)
|
|
||||||
|
|
||||||
|
|
||||||
-- |Create a diagram which shows the points of the convex hull.
|
-- |Create a diagram which shows the points of the convex hull.
|
||||||
@ -137,11 +141,7 @@ convexHullPointsText = Diag chpt
|
|||||||
chpt _ vt =
|
chpt _ vt =
|
||||||
position $
|
position $
|
||||||
zip vtch
|
zip vtch
|
||||||
((\(x, y) -> (flip (<>) (square 1 # lw none) .
|
(pointToTextCoord <$> vtch) # translate (r2 (0, 10))
|
||||||
text $ ("(" ++ show x ++ ", " ++ show y ++ ")")) #
|
|
||||||
scale 10 # translate (r2 (0, 10))) <$>
|
|
||||||
unp2 <$>
|
|
||||||
vtch)
|
|
||||||
where
|
where
|
||||||
vtch = grahamGetCH vt
|
vtch = grahamGetCH vt
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user