module Picture.Composite where
import Picture.Data
import Picture.Base
import Geometry

import Data.Foldable

arrowPath :: [Point2] -> Picture
arrowPath xs = mconcat $ zipWith arrow xs $ tail xs

multiArrow :: Foldable t => Point2 -> Point2 -> Color -> t Color -> Picture
multiArrow sp ep col' cols
    | null cols = color col' (arrow sp ep)
    | otherwise = foldl' f mempty cols
  where
    f pic col = uncurryV translate offset pic <> color col (arrow sp ep)
    offset = normalizeV (vNormal (ep -.- sp))

arrow :: Point2 -> Point2 -> Picture
arrow a b = line [a,b]
    <> line [b +.+ n -.- v,b]
    <> line [b -.- n -.- v,b]
  where
    v = 5 *.* normalizeV (b -.- a)
    n = vNormal v
