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

Copyright(c) 2011-2013 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Align

Contents

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

Alignable class

class Alignable a where Source #

Class of things which can be aligned.

Minimal complete definition

defaultBoundary

Methods

alignBy' :: (InSpace v n a, Fractional n, HasOrigin a) => (v n -> a -> Point v n) -> v n -> n -> a -> a Source #

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 boundary in the direction of v; if d = -1, it moves to the edge of the boundary 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).

defaultBoundary :: (V a ~ v, N a ~ n) => v n -> a -> Point v n Source #

alignBy :: (InSpace v n a, Fractional n, HasOrigin a) => v n -> n -> a -> a Source #

Instances

((~) (* -> *) (V b) v, (~) * (N b) n, Metric v, OrderedField n, Alignable b) => Alignable [b] Source # 

Methods

alignBy' :: (InSpace v n [b], Fractional n, HasOrigin [b]) => (v n -> [b] -> Point v n) -> v n -> n -> [b] -> [b] Source #

defaultBoundary :: (((* -> *) ~ V [b]) v, (* ~ N [b]) n) => v n -> [b] -> Point v n Source #

alignBy :: (InSpace v n [b], Fractional n, HasOrigin [b]) => v n -> n -> [b] -> [b] Source #

((~) (* -> *) (V b) v, (~) * (N b) n, Metric v, OrderedField n, Alignable b) => Alignable (Set b) Source # 

Methods

alignBy' :: (InSpace v n (Set b), Fractional n, HasOrigin (Set b)) => (v n -> Set b -> Point v n) -> v n -> n -> Set b -> Set b Source #

defaultBoundary :: (((* -> *) ~ V (Set b)) v, (* ~ N (Set b)) n) => v n -> Set b -> Point v n Source #

alignBy :: (InSpace v n (Set b), Fractional n, HasOrigin (Set b)) => v n -> n -> Set b -> Set b Source #

Alignable a => Alignable (Located a) Source # 

Methods

alignBy' :: (InSpace v n (Located a), Fractional n, HasOrigin (Located a)) => (v n -> Located a -> Point v n) -> v n -> n -> Located a -> Located a Source #

defaultBoundary :: (((* -> *) ~ V (Located a)) v, (* ~ N (Located a)) n) => v n -> Located a -> Point v n Source #

alignBy :: (InSpace v n (Located a), Fractional n, HasOrigin (Located a)) => v n -> n -> Located a -> Located a Source #

(InSpace v n a, HasOrigin a, Alignable a) => Alignable (b -> a) Source #

Although the alignBy method for the (b -> a) instance is sensible, there is no good implementation for defaultBoundary. Instead, we provide a total method, but one that is not sensible. This should not present a serious problem as long as your use of Alignable happens through alignBy.

Methods

alignBy' :: (InSpace v n (b -> a), Fractional n, HasOrigin (b -> a)) => (v n -> (b -> a) -> Point v n) -> v n -> n -> (b -> a) -> b -> a Source #

defaultBoundary :: (((* -> *) ~ V (b -> a)) v, (* ~ N (b -> a)) n) => v n -> (b -> a) -> Point v n Source #

alignBy :: (InSpace v n (b -> a), Fractional n, HasOrigin (b -> a)) => v n -> n -> (b -> a) -> b -> a Source #

((~) (* -> *) (V b) v, (~) * (N b) n, Metric v, OrderedField n, Alignable b) => Alignable (Map k b) Source # 

Methods

alignBy' :: (InSpace v n (Map k b), Fractional n, HasOrigin (Map k b)) => (v n -> Map k b -> Point v n) -> v n -> n -> Map k b -> Map k b Source #

defaultBoundary :: (((* -> *) ~ V (Map k b)) v, (* ~ N (Map k b)) n) => v n -> Map k b -> Point v n Source #

alignBy :: (InSpace v n (Map k b), Fractional n, HasOrigin (Map k b)) => v n -> n -> Map k b -> Map k b Source #

(Metric v, OrderedField n) => Alignable (Envelope v n) Source # 

Methods

alignBy' :: (InSpace v n (Envelope v n), Fractional n, HasOrigin (Envelope v n)) => (v n -> Envelope v n -> Point v n) -> v n -> n -> Envelope v n -> Envelope v n Source #

defaultBoundary :: (((* -> *) ~ V (Envelope v n)) v, (* ~ N (Envelope v n)) n) => v n -> Envelope v n -> Point v n Source #

alignBy :: (InSpace v n (Envelope v n), Fractional n, HasOrigin (Envelope v n)) => v n -> n -> Envelope v n -> Envelope v n Source #

(Metric v, OrderedField n) => Alignable (Trace v n) Source # 

Methods

alignBy' :: (InSpace v n (Trace v n), Fractional n, HasOrigin (Trace v n)) => (v n -> Trace v n -> Point v n) -> v n -> n -> Trace v n -> Trace v n Source #

defaultBoundary :: (((* -> *) ~ V (Trace v n)) v, (* ~ N (Trace v n)) n) => v n -> Trace v n -> Point v n Source #

alignBy :: (InSpace v n (Trace v n), Fractional n, HasOrigin (Trace v n)) => v n -> n -> Trace v n -> Trace v n Source #

(Metric v, OrderedField n) => Alignable (Path v n) Source # 

Methods

alignBy' :: (InSpace v n (Path v n), Fractional n, HasOrigin (Path v n)) => (v n -> Path v n -> Point v n) -> v n -> n -> Path v n -> Path v n Source #

defaultBoundary :: (((* -> *) ~ V (Path v n)) v, (* ~ N (Path v n)) n) => v n -> Path v n -> Point v n Source #

alignBy :: (InSpace v n (Path v n), Fractional n, HasOrigin (Path v n)) => v n -> n -> Path v n -> Path v n Source #

(Metric v, Traversable v, OrderedField n) => Alignable (BoundingBox v n) Source # 

Methods

alignBy' :: (InSpace v n (BoundingBox v n), Fractional n, HasOrigin (BoundingBox v n)) => (v n -> BoundingBox v n -> Point v n) -> v n -> n -> BoundingBox v n -> BoundingBox v n Source #

defaultBoundary :: (((* -> *) ~ V (BoundingBox v n)) v, (* ~ N (BoundingBox v n)) n) => v n -> BoundingBox v n -> Point v n Source #

alignBy :: (InSpace v n (BoundingBox v n), Fractional n, HasOrigin (BoundingBox v n)) => v n -> n -> BoundingBox v n -> BoundingBox v n Source #

(Metric v, OrderedField n, Monoid' m) => Alignable (QDiagram b v n m) Source # 

Methods

alignBy' :: (InSpace v n (QDiagram b v n m), Fractional n, HasOrigin (QDiagram b v n m)) => (v n -> QDiagram b v n m -> Point v n) -> v n -> n -> QDiagram b v n m -> QDiagram b v n m Source #

defaultBoundary :: (((* -> *) ~ V (QDiagram b v n m)) v, (* ~ N (QDiagram b v n m)) n) => v n -> QDiagram b v n m -> Point v n Source #

alignBy :: (InSpace v n (QDiagram b v n m), Fractional n, HasOrigin (QDiagram b v n m)) => v n -> n -> QDiagram b v n m -> QDiagram b v n m Source #

alignBy'Default :: (InSpace v n a, Fractional n, HasOrigin a) => (v n -> a -> Point v n) -> v n -> n -> a -> a Source #

Default implementation of alignBy for types with HasOrigin and AdditiveGroup instances.

envelopeBoundary :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Point v n Source #

Some standard functions which can be used as the boundary argument to alignBy'.

traceBoundary :: (V a ~ v, N a ~ n, Num n, Traced a) => v n -> a -> Point v n Source #

General alignment functions

align :: (InSpace v n a, Fractional n, Alignable a, HasOrigin a) => v n -> a -> a Source #

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".)

snug :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> a -> a Source #

Like align but uses trace.

centerV :: (InSpace v n a, Fractional n, Alignable a, HasOrigin a) => v n -> a -> a Source #

centerV v centers an enveloped object along the direction of v.

center :: (InSpace v n a, Fractional n, Traversable v, Alignable a, HasOrigin a) => a -> a Source #

center centers an enveloped object along all of its basis vectors.

snugBy :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> n -> a -> a Source #

Version of alignBy specialized to use traceBoundary

snugCenterV :: (InSpace v n a, Fractional n, Alignable a, Traced a, HasOrigin a) => v n -> a -> a Source #

Like centerV using trace.

snugCenter :: (InSpace v n a, Traversable v, Fractional n, Alignable a, HasOrigin a, Traced a) => a -> a Source #

Like center using trace.