DIAGRAM: add maybeDiag convenience function
This commit is contained in:
parent
5d5d0b7643
commit
cb7d5269a0
17
Diagram.hs
17
Diagram.hs
@ -92,6 +92,15 @@ yuD :: DiagProp -> Double
|
|||||||
yuD = snd . dY
|
yuD = snd . dY
|
||||||
|
|
||||||
|
|
||||||
|
-- |Returns the specified diagram if True is passed,
|
||||||
|
-- otherwise returns the empty diagram. This is just for convenience
|
||||||
|
-- to avoid if else constructs.
|
||||||
|
maybeDiag :: Bool -> Diag -> Diag
|
||||||
|
maybeDiag b d
|
||||||
|
| b = d
|
||||||
|
| otherwise = mempty
|
||||||
|
|
||||||
|
|
||||||
-- |Creates a Diagram that shows the coordinates from the points
|
-- |Creates a Diagram that shows the coordinates from the points
|
||||||
-- as dots. The points and thickness of the dots can be controlled
|
-- as dots. The points and thickness of the dots can be controlled
|
||||||
-- via DiagProp.
|
-- via DiagProp.
|
||||||
@ -253,17 +262,17 @@ diag :: DiagProp -> [PT] -> Diagram Cairo R2
|
|||||||
diag p = case alg p of
|
diag p = case alg p of
|
||||||
0 ->
|
0 ->
|
||||||
mkDiag
|
mkDiag
|
||||||
(mconcat [if ct p then coordPointsText else mempty,
|
(mconcat [maybeDiag (ct p) coordPointsText,
|
||||||
coordPoints, xAxis, yAxis,
|
coordPoints, xAxis, yAxis,
|
||||||
(if gd p then grid else mempty),whiteRectB])
|
maybeDiag (gd p) grid, whiteRectB])
|
||||||
p
|
p
|
||||||
1 ->
|
1 ->
|
||||||
mkDiag
|
mkDiag
|
||||||
(mconcat
|
(mconcat
|
||||||
[if ct p then convexHullPointsText else mempty,
|
[maybeDiag (ct p) convexHullPointsText,
|
||||||
convexHullPoints, convexHullLines,
|
convexHullPoints, convexHullLines,
|
||||||
coordPoints, xAxis, yAxis,
|
coordPoints, xAxis, yAxis,
|
||||||
(if gd p then grid else mempty), whiteRectB])
|
maybeDiag (gd p) grid, whiteRectB])
|
||||||
p
|
p
|
||||||
_ -> mempty
|
_ -> mempty
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user