module Dodge.Render.Connectors
    ( zConnect
    , bConnect
    , lConnect
    ) where
import Picture
import Geometry

zConnect :: Point2 -> Point2 -> Picture
zConnect (V2 x y) (V2 a b) = line $ map toV2
    [(x,y)
    ,(0.5 * (x+a), y)
    ,(0.5 * (x+a), b)
    ,(a, b)
    ]

bConnect :: Point2 -> Point2 -> Picture
bConnect (V2 x y) (V2 z w) = pictures 
    [ bline 0.2 0.050 0.010
    , bline 0.5 0.045 0.005
    , bline 0.5 0.035 0.002
    ] --cheapo antialiasing
  where
    bline alph lwidth rwidth
        = bezierQuad (withAlpha 0.0 white) (withAlpha alph white) lwidth rwidth (V2 x y) (V2 0 y) (V2 z w)

lConnect :: Point2 -> Point2 -> Picture
lConnect sp@(V2 _ y) ep@(V2 x _) = line 
    [ sp
    , V2 x y
    , ep
    ]
