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

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone

Diagrams.TwoD.Align

Contents

Description

Alignment combinators specialized for two dimensions. See Diagrams.Align for more general alignment combinators.

The basic idea is that alignment is achieved by moving diagrams' local origins relative to their envelopes. For example, to align several diagrams along their tops, we first move their local origins to the upper edge of their envelopes (using e.g. map alignTop), and then put them together with their local origins along a horizontal line (using e.g. hcat from Diagrams.TwoD.Combinators).

Synopsis

Absolute alignment

alignL :: (Alignable a, V a ~ R2) => a -> aSource

Align along the left edge, i.e. translate the diagram in a horizontal direction so that the local origin is on the left edge of the envelope.

alignR :: (Alignable a, V a ~ R2) => a -> aSource

Align along the right edge.

alignT :: (Alignable a, V a ~ R2) => a -> aSource

Align along the top edge.

alignB :: (Alignable a, V a ~ R2) => a -> aSource

Align along the bottom edge.

alignTL :: (Alignable a, V a ~ R2) => a -> aSource

alignTR :: (Alignable a, V a ~ R2) => a -> aSource

alignBL :: (Alignable a, V a ~ R2) => a -> aSource

alignBR :: (Alignable a, V a ~ R2) => a -> aSource

Relative alignment

alignX :: (Alignable a, V a ~ R2) => Double -> a -> aSource

alignX moves the local origin horizontally as follows:

  • alignX (-1) moves the local origin to the left edge of the envelope;
  • align 1 moves the local origin to the right edge;
  • any other argument interpolates linearly between these. For example, alignX 0 centers, alignX 2 moves the origin one "radius" to the right of the right edge, and so on.

alignY :: (Alignable a, V a ~ R2) => Double -> a -> aSource

Like alignX, but moving the local origin vertically, with an argument of 1 corresponding to the top edge and (-1) corresponding to the bottom edge.

Centering

centerX :: (Alignable a, V a ~ R2) => a -> aSource

Center the local origin along the X-axis.

centerY :: (Alignable a, V a ~ R2) => a -> aSource

Center the local origin along the Y-axis.

centerXY :: (Alignable a, V a ~ R2) => a -> aSource

Center along both the X- and Y-axes.