module Wumpus.Drawing.Connectors.BoxConnectors
(
ConnectorBox
, connbox
, conntube
) where
import Wumpus.Drawing.Connectors.ConnectorProps
import Wumpus.Basic.Kernel
import Wumpus.Core
import Data.Monoid
type ConnectorBox u = ConnectorGraphic u
connbox :: (Real u, Floating u, InterpretUnit u)
=> ConnectorProps -> ConnectorBox u
connbox props = promoteConn $ \p0 p1 ->
connectorBoxHalfSize props >>= \sz ->
applyLoc (drawPlacedTrail CSTROKE $ cfconnbox sz (pvec p0 p1)) p0
conntube :: (Real u, Floating u, InterpretUnit u)
=> ConnectorProps -> ConnectorBox u
conntube props = promoteConn $ \p0 p1 ->
connectorBoxHalfSize props >>= \sz ->
applyLoc (drawPlacedTrail CSTROKE $ cfconntube sz (pvec p0 p1)) p0
cfconnbox :: (Real u, Floating u) => u -> Vec2 u -> PlacedTrail u
cfconnbox du v1 =
placeCatTrail (orthoVec (du) (du) ang) $ mconcat $
[ trail_theta_right w ang
, trail_theta_up h ang
, trail_theta_left w ang
, trail_theta_down h ang
]
where
ang = vdirection v1
w = (2*du) + vlength v1
h = 2*du
cfconntube :: (Real u, Floating u) => u -> Vec2 u -> PlacedTrail u
cfconntube du v1 =
placeCatTrail (orthoVec 0 (du) ang) $ mconcat $
[ trail_theta_right w ang
, semicircleCCW vup
, trail_theta_left w ang
, semicircleCCW vdown
]
where
ang = vdirection v1
w = vlength v1
vup = avec (ang + half_pi) (2*du)
vdown = avec (ang half_pi) (2*du)