module Diagrams.Lens
(
_corners
, _location
, _Loc
, _mkFixedSeg
, _straight
, _bezier3
, _lineSegments
) where
#if __GLASGOW_HASKELL__ < 710
import Control.Applicative
import Data.Foldable
#endif
import Diagrams.BoundingBox
import Diagrams.Prelude
_corners
:: (Additive v', Foldable v', Ord n')
=> Traversal (BoundingBox v n) (BoundingBox v' n') (Point v n) (Point v' n')
_corners f (getCorners -> Just (l, t)) = fromCorners <$> f l <*> f t
_corners _ _ = pure emptyBox
_location
:: (HasLinearMap v, Metric v, OrderedField n)
=> Lens' (Subdiagram b v n m) (Point v n)
_location = lens location (flip Diagrams.Prelude.moveTo)
_Loc :: Iso (Located a) (Located a') (Point (V a) (N a), a) (Point (V a') (N a'), a')
_Loc = iso viewLoc (uncurry $ flip Diagrams.Prelude.at)
_mkFixedSeg
:: (Additive v, Additive v', Num n, Num n')
=> Iso
(Located (Segment Closed v n))
(Located (Segment Closed v' n'))
(FixedSegment v n)
(FixedSegment v' n')
_mkFixedSeg = iso mkFixedSeg fromFixedSeg
_straight :: Prism' (Segment Closed v n) (v n)
_straight = prism' straight fromStraight
where
fromStraight :: Segment c v n -> Maybe (v n)
fromStraight (Linear (OffsetClosed x)) = Just x
fromStraight _ = Nothing
_bezier3 :: Prism' (Segment Closed v n) (v n, v n, v n)
_bezier3 = prism' (\(c1, c2, c3) -> bezier3 c1 c2 c3) fromBezier3
where
fromBezier3 :: Segment c v n -> Maybe (v n, v n, v n)
fromBezier3 (Cubic c1 c2 (OffsetClosed c3)) = Just (c1, c2, c3)
fromBezier3 _ = Nothing
_lineSegments
:: (Metric v', OrderedField n')
=> Iso
(Trail' Line v n) (Trail' Line v' n')
[Segment Closed v n] [Segment Closed v' n']
_lineSegments = iso lineSegments lineFromSegments