Copyright | (c) Jonatan H Sundqvist 2015 |
---|---|
License | MIT |
Maintainer | Jonatan H Sundqvist |
Stability | experimental|stable |
Portability | POSIX (not sure) |
Safe Haskell | None |
Language | Haskell2010 |
Cartesian.Lenses
Description
- pinnedAxis :: Num n => n -> Simple Lens (Axis n) (Axis n)
- pinned :: (Applicative v, Num n) => v n -> Simple Lens (BoundingBox (v n)) (Axes v n)
- axis :: (Applicative v, Num n) => Simple Lens (Axes v n) (Axis n) -> Simple Lens (BoundingBox (v n)) (Axis n)
- axes :: Applicative v => Lens (BoundingBox (v a)) (BoundingBox (v b)) (Axes v a) (Axes v b)
- extents :: (Applicative v, Num a, Num b) => Lens (BoundingBox (v a)) (BoundingBox (v b)) (Axes v a) (Axes v b)
- side :: (Applicative v, Num n) => Simple Lens (Axes v n) (Axis n) -> Simple Lens (Axis n) n -> Simple BoxLens v n
- corner :: forall v. Lens' (BoundingBox v) v
- size :: forall v. Lens' (BoundingBox v) v
- begin :: Lens (Line v) (Line v) v v
- end :: Lens (Line v) (Line v) v v
- width :: HasX (v f) f => Simple Lens (BoundingBox (v f)) f
- height :: HasY (v f) f => Simple BoxLens v f
- depth :: HasZ (v f) f => Simple BoxLens v f
- left :: (Applicative v, HasX (Axes v n) (Axis n), Num n) => Simple BoxLens v n
- right :: (Applicative v, HasX (Axes v n) (Axis n), Num n) => Simple BoxLens v n
- bottom :: (Applicative v, HasY (Axes v n) (Axis n), Num n) => Simple BoxLens v n
- top :: (Applicative v, HasY (Axes v n) (Axis n), Num n) => Simple BoxLens v n
- front :: (Applicative v, HasZ (Axes v n) (Axis n), Num n) => Simple BoxLens v n
- back :: (Applicative v, HasZ (Axes v n) (Axis n), Num n) => Simple BoxLens v n
- centre :: (Applicative v, Fractional f) => Simple Lens (BoundingBox (v f)) (Axes v f)
- x :: HasX a f => Simple Lens a f
- y :: HasY a f => Simple Lens a f
- z :: HasZ a f => Simple Lens a f
Documentation
pinnedAxis :: Num n => n -> Simple Lens (Axis n) (Axis n) Source #
pad :: (Getter v f) -> f -> f -> BoundingBox v pad axis by direction = _
Like pinned, except it operates on a single axis and only focuses on the position (not size)
TODO: Change the type to make it play more nicely with pinned
(?)
TODO: - What's the proper way of lifting
lenses (such as pinnedAxis
), so they work on multiple fields.
This is not mucher better than it used to be when we didn't have the pinnedAxis
helper...
pinned :: (Applicative v, Num n) => v n -> Simple Lens (BoundingBox (v n)) (Axes v n) Source #
Creates a lens where a pin is placed on a given point (to
), so that
the box can be placed or resized relative to the pin. It is also useful for
retrieving points within the box (such as the centre).
The pin is assumed to be normalised with respect to the corner and size of the box.
let box = BoundingBox { cornerOf = V2 10 24, sizeOf = V2 6 18 } box^.pinned (V2 0.5 0.5) -- Anchored to the centre > V2 (13.0,6.0) (33.0,18.0)
axis :: (Applicative v, Num n) => Simple Lens (Axes v n) (Axis n) -> Simple Lens (BoundingBox (v n)) (Axis n) Source #
Focuses on a single axis of the box
axes :: Applicative v => Lens (BoundingBox (v a)) (BoundingBox (v b)) (Axes v a) (Axes v b) Source #
extents :: (Applicative v, Num a, Num b) => Lens (BoundingBox (v a)) (BoundingBox (v b)) (Axes v a) (Axes v b) Source #
side :: (Applicative v, Num n) => Simple Lens (Axes v n) (Axis n) -> Simple Lens (Axis n) n -> Simple BoxLens v n Source #
TODO: Turn this into a lens function (?) TODO: Polish description TODO: Loosen constraint on n (✓) axes which.pinned (V1 step).x._1 -- lens get set
corner :: forall v. Lens' (BoundingBox v) v Source #
size :: forall v. Lens' (BoundingBox v) v Source #
Ugh...
centre :: (Applicative v, Fractional f) => Simple Lens (BoundingBox (v f)) (Axes v f) Source #
TODO: This should probably yield a vector (rename or redesign)