module Wumpus.Drawing.Grids
(
grid
, interiorGrid
) where
import Wumpus.Drawing.Chains
import Wumpus.Basic.Kernel
import Wumpus.Core
grid :: Fractional u => (Int,Int) -> u -> LocGraphic u
grid (nx,ny) incr
| nx < 1 || ny < 1 = emptyLocGraphic
| otherwise = promoteR1 $ \sw ->
let rw = incr * fromIntegral nx
rh = incr * fromIntegral ny
xchn = horizontalPoints incr
ychn = verticalPoints incr
vline1 = straightLine (vvec rh)
hline1 = straightLine (hvec rw)
vlines = unchain nx emptyLocGraphic vline1 xchn
hlines = unchain ny emptyLocGraphic hline1 ychn
in (hlines `oplus` vlines `oplus` strokedRectangle rw rh) `at` sw
interiorGrid :: RealFrac u => u -> ConnectorGraphic u
interiorGrid incr = promoteR2 $ \sw ne ->
let xcc = innerHorizontals incr
ycc = innerVerticals incr
(V2 vx vy) = pvec sw ne
hline1 = straightLine (hvec vx)
vline1 = straightLine (vvec vy)
vlines = unconnectorChain emptyConnectorGraphic vline1 xcc
hlines = unconnectorChain emptyConnectorGraphic hline1 ycc
in connect (hlines `oplus` vlines) sw ne