diagrams-lib-0.7.1.1: Embedded domain-specific language for declarative graphics

Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | None

Diagrams.Align

Contents

- Alignable class
- General alignment functions

Description

The alignment of an object refers to the position of its local origin with respect to its envelope. This module defines the `Alignable` class for things which can be aligned, as well as a default implementation in terms of `HasOrigin` and `Enveloped`, along with several utility methods for alignment.

Synopsis

- class Alignable a where
  - alignBy :: V a -> Scalar (V a) -> a -> a
- alignByDefault :: (HasOrigin a, Enveloped a, Num (Scalar (V a))) => V a -> Scalar (V a) -> a -> a
- align :: (Alignable a, Num (Scalar (V a))) => V a -> a -> a
- center :: (Alignable a, Num (Scalar (V a))) => V a -> a -> a

# Alignable class

class Alignable a where Source

Class of things which can be aligned.

Methods

alignBy :: V a -> Scalar (V a) -> a -> aSource

`alignBy v d a` moves the origin of `a` along the vector `v`. If `d = 1`, the origin is moved to the edge of the envelope in the direction of `v`; if `d = -1`, it moves to the edge of the envelope in the direction of the negation of `v`. Other values of `d` interpolate linearly (so for example, `d = 0` centers the origin along the direction of `v`).

Instances

(Enveloped b, HasOrigin b) => Alignable [b] |
Alignable a => Alignable (Active a) |
(Enveloped b, HasOrigin b, Ord b) => Alignable (Set b) |
(InnerSpace v, OrderedField (Scalar v)) => Alignable (Envelope v) |
(InnerSpace v, OrderedField (Scalar v)) => Alignable (Path v) |
(Enveloped b, HasOrigin b) => Alignable (Map k b) |
(HasLinearMap v, InnerSpace v, OrderedField (Scalar v), Monoid' m) => Alignable (QDiagram b v m) |

alignByDefault :: (HasOrigin a, Enveloped a, Num (Scalar (V a))) => V a -> Scalar (V a) -> a -> aSource

Default implementation of `alignBy` for types with `HasOrigin` and `Enveloped` instances.

# General alignment functions

align :: (Alignable a, Num (Scalar (V a))) => V a -> a -> aSource

`align v` aligns an enveloped object along the edge in the direction of `v`. That is, it moves the local origin in the direction of `v` until it is on the edge of the envelope. (Note that if the local origin is outside the envelope to begin with, it may have to move "backwards".)

center :: (Alignable a, Num (Scalar (V a))) => V a -> a -> aSource

`center v` centers an enveloped object along the direction of `v`.