Rm useless filterValidCoords, refactor inRange
This commit is contained in:
parent
eaaa699035
commit
aec00c7e4d
@ -9,7 +9,7 @@ import Util
|
|||||||
-- |Create the Diagram from the VTable.
|
-- |Create the Diagram from the VTable.
|
||||||
diagFromVTable :: VTable -> Diagram Cairo R2
|
diagFromVTable :: VTable -> Diagram Cairo R2
|
||||||
diagFromVTable meshArr
|
diagFromVTable meshArr
|
||||||
= position (zip (map mkPoint . filterValidCoords 0 500 $ meshArr)
|
= position (zip (map mkPoint . filter (inRange 0 500) $ meshArr)
|
||||||
(repeat dot)) # moveTo (p2(-250, -250))
|
(repeat dot)) # moveTo (p2(-250, -250))
|
||||||
`atop` square 500 # lwG 0.05 # bg white
|
`atop` square 500 # lwG 0.05 # bg white
|
||||||
where dot = (circle 2 :: Diagram Cairo R2) # fc black
|
where dot = (circle 2 :: Diagram Cairo R2) # fc black
|
||||||
|
12
Util.hs
12
Util.hs
@ -2,18 +2,12 @@ module Util where
|
|||||||
|
|
||||||
|
|
||||||
-- |Checks whether the Coordinates are in a given range.
|
-- |Checks whether the Coordinates are in a given range.
|
||||||
inRange :: (Double, Double) -- ^ Coordinates to check
|
inRange :: Double -- ^ min
|
||||||
-> Double -- ^ min
|
|
||||||
-> Double -- ^ max
|
-> Double -- ^ max
|
||||||
|
-> (Double, Double) -- ^ Coordinates to check
|
||||||
-> Bool -- ^ result
|
-> Bool -- ^ result
|
||||||
inRange (x, y) min' max'
|
inRange min' max' (x, y)
|
||||||
| x <= max' && x >= min' && y <= max' && y >= min' = True
|
| x <= max' && x >= min' && y <= max' && y >= min' = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
|
|
||||||
|
|
||||||
-- |Filter the valid coordinates.
|
|
||||||
filterValidCoords :: Double -- ^ min
|
|
||||||
-> Double -- ^ max
|
|
||||||
-> [(Double, Double)] -- ^ unfiltered
|
|
||||||
-> [(Double, Double)] -- ^ filtered
|
|
||||||
filterValidCoords min' max' = filter (\(x, y) -> inRange (x, y) min' max')
|
|
||||||
|
Loading…
Reference in New Issue
Block a user